NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet
NuGet, #1552 most downloaded on NuGet
High performance, thread-safe in-memory caching primitives for .NET.
Latest stable
2.6.1
Last release 3 months ago
27 Aug 2026
Release timing varies
gaps range from 2 weeks to 10 months
Most releases are documented
notes for 28 of 33 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
33 releases · first in 2020
Drag across the ruler to compare, or tap a release to open it.
Fixed a ConcurrentLfu.Trim thread safety bug that could corrupt internal data structures when called concurrently with write operations.
ConcurrentLfu.Trim thread safety bug that could corrupt internal data structures when called concurrently with write operations.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.6.0...v2.6.1
Added Alternate Lookup support across ICache, IAsyncCache, IScopedCache, and IAsyncScopedCache, enabling allocation free alternate key lookups via Rea
ICache, IAsyncCache, IScopedCache, and IAsyncScopedCache, enabling allocation free alternate key lookups via ReadOnlySpan<char> on caches with a string primary key.ref struct support for the TArg generic type parameter in synchronous GetOrAdd methods, allowing stack-only arguments to be passed in.ConcurrentLfu, configured by calling builder WithEvents. ConcurrentLfu now has events enabled by default.ConcurrentLfu for a minor performance optimization.ScopedAtomicFactory, where scope initialization/disposal could observe stale state under contention.BackgroundThreadScheduler completion task to return completed when it is immediately disposed prior to executing any work.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.4...v2.6.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Eagerly purge deleted items from internal ConcurrentLru queues. Previously, deleted items remain in the internal queues until fully cycled out of cold
ConcurrentLru queues. Previously, deleted items remain in the internal queues until fully cycled out of cold. Instead, purge them as items transition from queue to queue (e.g. from hot to warm) as part of cycle.UnobservedTaskException for value creation when using AsAsyncCache()/AsyncAtomicFactory/ScopedAsyncAtomicFactory. If there is an exception when invoking the value factory delegate, the internal TaskCompletionSource has an exception set that previously was not observed unless another thread concurrently evaluated the result. Fixed by @advdotnet.ConcurrentLru.Trim() avoid incorrectly trimming an extra warm item when values are trimmed from cold but not warm.ConcurrentLru.TrimExpired() is now thread safe.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.3...v2.5.4
Eliminate volatile writes in ConcurrentLru internal bookkeeping code for pure reads, improving concurrent read throughput by 175%.
ConcurrentLru internal bookkeeping code for pure reads, improving concurrent read throughput by 175%.CmSketch using Neon intrinsics for ARM CPUs. This results in slightly better ConcurrentLfu cache throughput measured on Apple M series and Azure Cobalt 100 CPUs.CmSketch. This results in slightly better ConcurrentLfu throughput on CPUs without vector support (i.e. neither x86 AVX2 nor Arm Neon).CmSketch allocates the internal buffer using the pinned object heap on .NET6 or newer. Use of the fixed statement is removed, eliminating a very small overhead. Sketch block pointers are then aligned to 64 bytes, guaranteeing each block is always on the same CPU cache line. This provides a small speedup for the ConcurrentLfu maintenance thread by reducing CPU cache misses.MethodImpl(MethodImplOptions.AggressiveInlining) and removal of local variables to improve performance on .NET8/9 and dynamic PGO.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.2...v2.5.3
Fix race between update and TryRemove(KeyValuePair) for both ConcurrentLru and Fix ConcurrentLfu. Prior to this fix, values may be deleted if the valu
TryRemove(KeyValuePair) for both ConcurrentLru and Fix ConcurrentLfu. Prior to this fix, values may be deleted if the value is updated to no longer match the TryRemove input argument while TryRemove is executing.ConcurrentLfu torn writes for large structs using SeqLock.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.1...v2.5.2
Fix ConcurrentLfu time-based expiry policy failing to update the entry's expiry on read. Prior to this fix, expiry is only updated when the read buffe
ConcurrentLfu time-based expiry policy failing to update the entry's expiry on read. Prior to this fix, expiry is only updated when the read buffer is processed (following a cache write, or when the read buffer is full).ConcurrentLru torn writes for large structs using SeqLock.ConcurrentLru AfterAccessPolicy and DiscretePolicy.TickCount64 to evaluate current time for .NET Standard on Windows, Duration.SinceEpoch is 5x faster resulting in lower latency lookups for ConcurrentTLru/ConcurrentTLfu.Stopwatch.GetTimestamp to evaluate current time on MacOS, Duration.SinceEpoch is about 20% faster resulting in slightly lower latency lookups for ConcurrentTLru/ConcurrentTLfu.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.5.0...v2.5.1
These new methods are excluded in the base interfaces for .NET Standard, since adding them would be a breaking change.
ConcurrentLfu, matching ConcurrentLru. This closely follows the implementation in Java's Caffeine, using a port of Caffeine's hierarchical timer wheel to perform all operations in O(1) time. Expire after write, expire after access and expire after using IExpiryCalculator can be configured via ConcurrentLfuBuilder extension methods.ICacheExt and IAsyncCacheExt to enable client code compiled against .NET Standard to use the builder APIs and cache methods added since v2.0. These new methods are excluded in the base interfaces for .NET Standard, since adding them would be a breaking change.Duration convenience methods FromHours and FromDays.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.4.1...v2.5.0
Fixed a race condition in ConcurrentLfu for add-remove-add of the same key.
ConcurrentLfu for add-remove-add of the same key.MpscBoundedBuffer.Clear() is now thread safe, fixing a race in ConcurrentLfu clear.ConcurrentLru Count and IEnumerable<KeyValuePair<K,V>> to filter out expired items when used with time-based expiry.<nullable>enable</nullable>, and APIs are annotated to support null reference type static analysis.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.4.0...v2.4.1
Provide two new time-based expiry schemes for ConcurrentLru:
ConcurrentLru:
IExpiryCalculator. Expiry time may be set independently at creation, after a read and after a write.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.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.AtomicFactory value initialization logic modified to mitigate lock convoys, based on the approach given here.ConcurrentLru.Clear to correctly handle removed items present in the internal bookkeeping data structures.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.3.3...v2.4.0
Eliminated all races in ConcurrentLru eviction logic, and the transition between the cold cache and warm cache eviction routines. This prevents a vari
ConcurrentLru eviction logic, and the transition between the cold cache and warm cache eviction routines. This prevents a variety of rare 'off by one item count' situations that could needlessly evict items when the cache is within bounds.ConcurrentLru.Clear() to always clear the cache when items in the warm queue are marked as accessed.ConcurrentLfu drain buffers logic to give ~5% better throughput (measured by the eviction throughput test).ConcurrentLfu drain buffers delegate to prevent allocating a closure when scheduling maintenance.BackgroundThreadScheduler and ThreadPoolScheduler now use TaskScheduler.Default, instead of implicitly using TaskScheduler.Current (fixes CA2008).ScopedAsyncCache now internally calls ConfigureAwait(false) when awaiting tasks (fixes CA2007).ConcurrentLru debugger display on .NET Standard.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.3.2...v2.3.3
Fix ConcurrentLru NullReferenceException when expiring and disposing null values (i.e. the cached value is a reference type, and the caller cached a n
ConcurrentLru NullReferenceException when expiring and disposing null values (i.e. the cached value is a reference type, and the caller cached a null value).ConcurrentLfu handling of updates to detached nodes, caused by concurrent reads and writes. Detached nodes could be re-attached to the probation LRU pushing out fresh items prematurely, but would eventually expire since they can no longer be accessed.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.3.1...v2.3.2
Introduce a simple heuristic to estimate the optimal ConcurrentDictionary bucket count for ConcurrentLru/ConcurrentLfu/ClassicLru based on the capacit
ConcurrentDictionary bucket count for ConcurrentLru/ConcurrentLfu/ClassicLru based on the capacity constructor arg. When the cache is at capacity, the ConcurrentDictionary will have a prime number bucket count and a load factor of 0.75.
ConcurrentDictionary capacity that is a prime number 33% larger than cache capacity. Initial size is large enough to avoid resizing.ConcurrentDictionary initial size using a lookup table. Initial size is approximately 10% of the cache capacity such that 4 ConcurrentDictionary grow operations will arrive at a hash table size that is a prime number approximately 33% larger than cache capacity.SingletonCache sets the internal ConcurrentDictionary capacity to the next prime number greater than the capacity constructor argument.Scoped by changing ReferenceCount to use reference equality (via object.ReferenceEquals).SkipLocalsInit. Minor performance gains.AtomicFactory/AsyncAtomicFactory/ScopedAtomicFactory/ScopedAsyncAtomicFactory by removing redundant reads, reducing code size.ConcurrentLfu.Count now does not lock the underlying ConcurrentDictionary, matching ConcurrentLru.Count.CollectionsMarshal.AsSpan to enumerate candidates within ConcurrentLfu.Trim on .NET6.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.3.0...v2.3.1
Align TryRemove overloads with ConcurrentDictionary for ICache (including WithAtomicGetOrAdd). This adds two new overloads:
TryRemove overloads with ConcurrentDictionary for ICache (including WithAtomicGetOrAdd). 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.ConcurrentLfu.Clear() to remove all values when using BackgroundThreadScheduler. Previously values may be left behind after clear was called due to removed items present in window/protected/probation polluting the list of candidates to remove.ConcurrentLru.Clear() to reset the isWarm flag. Now cache warmup behaves the same for a new instance of ConcurrentLru vs an existing instance that was full then cleared. Previously ConcurrentLru could have reduced capacity during warmup after calling clear, depending on the access pattern.AtomicFactory with a plain ConcurrentDictionary. This is similar to storing a Lazy<T> instead of T, but with the same exception propagation semantics and API as ConcurrentDictionary.GetOrAdd.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.2.1...v2.3.0
Fix a ConcurrentLru bug where a repeated pattern of sequential key access could lead to unbounded growth.
ConcurrentLru bug where a repeated pattern of sequential key access could lead to unbounded growth.MpscBoundedBuffer/StripedMpscBuffer/ConcurrentLfu on .NET6/.NETCore3.1 build targets. Reduces ConcurrentLfu lookup latency by about 5-7% in the lookup benchmark.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.2.0...v2.2.1
Implement build time package validation to prevent breaking changes going forward. Fixed all breaking changes introduced since v2.0.0. The v2.2.0 NET6…
ICache.GetOrAdd enabling the value factory delegate to accept an input argument. <br/>
TValue GetOrAdd<TArg> (TKey key, Func<TKey,TArg,TValue> valueFactory, TArg factoryArgument)<br/>
If additional data is required to construct/fetch cached values, this provides a mechanism to pass data into the factory without allocating a new closure on the heap. Passing a CancellationToken into to an async value factory delegate is a common use case.IAsyncCache, IScopedCache and IAsyncScopedCache.IValueFactory and IAsyncValueFactory value types.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.1.3...v2.2.0
Fix bug preventing ConcurrentTLru from expiring items if the host machine runs for longer than 49 days (on .NET Core 3/.NET6 only). This was a regress
Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.1.2...v2.1.3
Added an ItemUpdated event for all LRU classes, including the scoped and atomic cache decorators.
Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.1.1...v2.1.2
Update CmSketch to use block-based indexing, matching Caffeine. The 64-byte blocks are the same size as x86 cache lines. This scheme exploits the hard
CmSketch to use block-based indexing, matching Caffeine. The 64-byte blocks are the same size as x86 cache lines. This scheme exploits the hardware by reducing L1 cache misses, since each increment or frequency call is guaranteed to use data from the same cache line.CmSketch using AVX2 intrinsics. When combined with block indexing, this is 2x faster than the original implementation in benchmarks and gives 20% better ConcurrentLfu throughput when tested end to end.ConcurrentLfu uses a Running value cache when comparing frequency. In the best case this reduces the number of sketch frequency calls by 50%. Improves throughput.CmSketch.Reset, reduces reset execution time by about 40%. This is called periodically so reduces worst case rather than average ConcurrentLfu maintenance time.ConcurrentLfu hot path, minor latency reduction when benchmarked.ConcurrentLru cycle count when evicting items. Prevents runaway growth when stress tested on AMD CPUs.ConcurrentLfu disposes items created but not cached when races occur during GetOrAdd.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.1.0...v2.1.1
Added ConcurrentLfu, a .NET implementation of the W-TinyLfu admission policy. This closely follows the approach taken by the Caffeine library by Ben M
ConcurrentLfu, a .NET implementation of the W-TinyLfu admission policy. This closely follows the approach taken by the Caffeine library by Ben Manes - including buffered reads/writes and hill climbing to optimize hit rate. A ConcurrentLfuBuilder provides integration with the existing atomic value factory and scoped value features.ConcurrentLfu added the MpscBoundedBuffer and StripedMpscBuffer classes.ConcurrentLfu added the ThreadPoolScheduler, BackgroundThreadScheduler and ForegroundScheduler classes.Counter class for fast concurrent counting, based on LongAdder by Doug Lea.ConcurrentLru to use Counter for all metrics and added padding to internal queue counters. This improved throughput by about 2.5x with about 10% worse latency.FastConcurrentLru, ConcurrentLru, FastConcurrentTLru, ConcurrentTLru and ConcurrentLfu.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v2.0.0...v2.1.0
Split ICache into ICache, IAsyncCache, IScopedCache and IScopedAsyncCache interfaces. Mixing sync and async code paths is problematic and generally di
ICache into ICache, IAsyncCache, IScopedCache and IScopedAsyncCache interfaces. Mixing sync and async code paths is problematic and generally discouraged. Splitting sync/async enables the most optimized code for each case. Scoped caches return Lifetime<T> instead of values, and internally have all the boilerplate code to safely resolve races.ConcurrentLruBuilder, providing a fluent builder API to ease creation of different cache configurations. Each cache option comes with a small performance overhead. The builder enables the developer to choose the exact combination of options needed, without any penalty from unused features.ICapacityPartition. Default partition scheme changed from equal to 80% warm via FavorWarmPartition, improving hit rate across all tests.ValueTask, reducing memory allocations.Full changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v1.1.0...v2.0.0
Added Trim(int itemCount) to ICache and all derived classes
Trim(int itemCount) to ICache and all derived classesTrimExpired() to TLRU classesCleared and Trimmed to ItemRemovedReasonClear() now has ItemRemovedReason.Cleared instead of EvictedFull changelog: https://github.com/bitfaster/BitFaster.Caching/compare/v1.0.7...v1.1.0
Added diagnostic features to dump cache contents:
Added diagnostic features to dump cache contents:
Implement ItemRemoved event on ConcurrentLru and ConcurrentTLru
Wrap LRU dispose logic in a static class
Add Clear method to ICache and LRUs (ClassicLru, ConcurrentLru, ConcurrentTLru)
Fixed ObjectDisposedException in SingletonCache.Release()
Added TryUpdate and AddOrUpdate methods to LRU classes to support updating cached values.
Added TryUpdate and AddOrUpdate methods to LRU classes to support updating cached values.
Added .NET 5 target. Included target frameworks:
Now includes multiple target frameworks:
Now includes multiple target frameworks:
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.