百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

BitFaster.Caching

> 编程语言
开源

适用于 .NET 的高性能、线程安全的内存缓存原语

604 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

适用于 .NET 的高性能、线程安全的内存缓存原语

⚡ BitFaster.Caching

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

Features

  • ConcurrentLru, a lightweight pseudo LRU based on the 2Q eviction policy. Also with time based eviction.
  • ConcurrentLfu, an approximate LFU based on the W-TinyLFU admission policy.
  • Configurable atomic valueFactory to mitigate cache stampede.
  • Configurable thread-safe wrappers for IDisposable cache values.
  • A builder API to easily configure cache features.
  • SingletonCache for caching single instance values, such as lock objects.
  • High performance concurrent counters.

Documentation

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

Getting started

BitFaster.Caching is installed from NuGet:

dotnet add package BitFaster.Caching

ConcurrentLru

ConcurrentLru is a light weight drop in replacement for ConcurrentDictionary, but with bounded size enforced by the TU-Q eviction policy (derived from 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:

csharp
int capacity = 128;
var lru = new ConcurrentLru(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 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:

csharp
int capacity = 128;
var lfu = new ConcurrentLfu(capacity);

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#cachedotnetlfulru

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言