BitFaster.Caching 2.1.1

.NET 6.0 .NET Core 3.1 .NET Standard 2.0
dotnet add package BitFaster.Caching --version 2.1.1
NuGet\Install-Package BitFaster.Caching -Version 2.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BitFaster.Caching" Version="2.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitFaster.Caching --version 2.1.1
#r "nuget: BitFaster.Caching, 2.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BitFaster.Caching as a Cake Addin
#addin nuget:?package=BitFaster.Caching&version=2.1.1

// Install BitFaster.Caching as a Cake Tool
#tool nuget:?package=BitFaster.Caching&version=2.1.1

⚡ BitFaster.Caching

High performance, thread-safe in-memory caching primitives for .NET.


ConcurrentLru is a light weight drop in replacement for ConcurrentDictionary, but with bounded size enforced by the TU-Q eviction policy (based on 2Q). There are no background threads, no global locks, concurrent throughput is high, lookups are fast and hit rate outperforms a pure LRU in all tested scenarios.

Choose a capacity and use just like ConcurrentDictionary, but with bounded size:

int capacity = 128;
var lru = new ConcurrentLru<string, SomeItem>(capacity);

var value = lru.GetOrAdd("key", (key) => new SomeItem(key));


ConcurrentLfu is a drop in replacement for ConcurrentDictionary, but with bounded size enforced by the W-TinyLFU admission policy. ConcurrentLfu has near optimal hit rate and high scalability. Reads and writes are buffered then replayed asynchronously to mitigate lock contention.

Choose a capacity and use just like ConcurrentDictionary, but with bounded size:

int capacity = 128;
var lfu = new ConcurrentLfu<string, SomeItem>(capacity);

var value = lfu.GetOrAdd("key", (key) => new SomeItem(key));


Please refer to the wiki for full API documentation, and a complete analysis of hit rate, latency and throughput.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on BitFaster.Caching:

Package Downloads
NServiceBus.RabbitMQ The ID prefix of this package has been reserved for one of the owners of this package by

RabbitMQ support for NServiceBus


DataObjects.Net is the object-relational mapper (ORM) and business logic layer (BLL) framework


HarmonyCore package that provides base runtime functionality


BitFaster.Caching extensions for Microsoft.Extensions.DependencyInjection.


支持 C# A/B Testing

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 22,943 10/14/2022
2.1.0 5,712 9/11/2022
2.0.0 114,903 7/29/2022
1.1.0 3,992 7/1/2022
1.0.7 100,055 2/13/2022
1.0.6 19,234 11/17/2021
1.0.5 6,133 11/10/2021
1.0.4 24,459 9/11/2021
1.0.3 30,402 5/31/2021
1.0.2 65,130 1/12/2021
1.0.1 23,529 7/9/2020
1.0.0 704 7/2/2020
0.9.4 710 6/19/2020
0.9.3 420 6/16/2020
0.9.2 380 6/15/2020
0.9.1 554 6/14/2020