BitFaster.Caching 2.1.0

.NET 6.0 .NET Core 3.1 .NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package BitFaster.Caching --version 2.1.0
NuGet\Install-Package BitFaster.Caching -Version 2.1.0
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.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitFaster.Caching --version 2.1.0
#r "nuget: BitFaster.Caching, 2.1.0"
#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.0

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

⚡ BitFaster.Caching

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

ConcurrentLru

ConcurrentLru is a light weight drop in replacement for ConcurrentDictionary, but with bounded size enforced by the TU-Q eviction policy (similar to 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 = 666;
var lru = new ConcurrentLru<string, SomeItem>(capacity);

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

ConcurrentLfu

ConcurrentLfu is a drop in replacement for ConcurrentDictionary, but with bounded size enforced by the W-TinyLFU eviction policy. ConcurrentLfu has near optimal hit rate. 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 = 666;
var lfu = new ConcurrentLfu<string, SomeItem>(capacity);

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

Documentation

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
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 NuGet.org.

RabbitMQ support for NServiceBus

Xtensive.Orm

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

Harmony.Core

HarmonyCore package that provides base runtime functionality

SensorsData.ABTesting

支持 C# A/B Testing

BitFaster.Caching.DependencyInjection

BitFaster.Caching extensions for Microsoft.Extensions.DependencyInjection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 4,902 10/14/2022
2.1.0 5,291 9/11/2022
2.0.0 58,301 7/29/2022
1.1.0 3,368 7/1/2022
1.0.7 87,731 2/13/2022
1.0.6 18,961 11/17/2021
1.0.5 5,857 11/10/2021
1.0.4 23,752 9/11/2021
1.0.3 27,494 5/31/2021
1.0.2 64,608 1/12/2021
1.0.1 23,169 7/9/2020
1.0.0 690 7/2/2020
0.9.4 696 6/19/2020
0.9.3 406 6/16/2020
0.9.2 366 6/15/2020
0.9.1 533 6/14/2020