Skip to content

v2.4.0

Compare
Choose a tag to compare
@bitfaster bitfaster released this 24 Nov 22:26
· 114 commits to main since this release
87aad5b

What's changed

  • Provide two new time-based expiry schemes for ConcurrentLru:
    • Expire after access: evict after a fixed duration since an entry's most recent read or write. This is equivalent to MemoryCache's sliding expiry, and is useful for data bound to a session that expires due to inactivity.
    • Per item expiry time: evict after a duration calculated for each item using the specified IExpiryCalculator. Expiry time may be set independently at creation, after a read and after a write.
  • Align TryRemove overloads with ConcurrentDictionary for IAsyncCache and AsyncAtomicFactory, matching the implementation for ICache added in v2.3.0. This adds two new overloads:
    • bool TryRemove(K key, out V value) - enables getting the value that was removed.
    • bool TryRemove(KeyValuePair<K, V> item) - enables removing an item only when the key and value are the same.
  • Add extension methods to make it more convenient to use AsyncAtomicFactory with a plain ConcurrentDictionary. This is similar to storing an AsyncLazy<T> instead of T, but with the same exception propagation semantics and API as ConcurrentDictionary.GetOrAdd.
  • BitFaster.Caching assembly marked as trim compatible to enable trimming when used in native AOT applications.
  • AtomicFactory value initialization logic modified to mitigate lock convoys, based on the approach given here.
  • Fixed ConcurrentLru.Clear to correctly handle removed items present in the internal bookkeeping data structures.

Full changelog: v2.3.3...v2.4.0