{"id":13350926,"url":"https://github.com/bitfaster/BitFaster.Caching","last_synced_at":"2025-03-12T10:30:51.724Z","repository":{"id":39968841,"uuid":"271437357","full_name":"bitfaster/BitFaster.Caching","owner":"bitfaster","description":"High performance, thread-safe in-memory caching primitives for .NET","archived":false,"fork":false,"pushed_at":"2025-02-13T21:13:41.000Z","size":1540,"stargazers_count":505,"open_issues_count":18,"forks_count":32,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-02-13T21:19:41.878Z","etag":null,"topics":["cache","dotnet","lfu","lru","threadsafe"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T02:55:49.000Z","updated_at":"2025-02-13T20:00:28.000Z","dependencies_parsed_at":"2024-02-06T04:44:16.036Z","dependency_job_id":"7791dc3c-06cc-45bb-95b0-1f8be1a5ccc8","html_url":"https://github.com/bitfaster/BitFaster.Caching","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfaster%2FBitFaster.Caching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfaster%2FBitFaster.Caching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfaster%2FBitFaster.Caching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfaster%2FBitFaster.Caching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfaster","download_url":"https://codeload.github.com/bitfaster/BitFaster.Caching/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243199992,"owners_count":20252521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","dotnet","lfu","lru","threadsafe"],"created_at":"2024-07-29T21:00:43.439Z","updated_at":"2025-03-12T10:30:51.015Z","avatar_url":"https://github.com/bitfaster.png","language":"C#","funding_links":[],"categories":["Caching"],"sub_categories":[],"readme":"# ⚡ BitFaster.Caching\n\nHigh performance, thread-safe in-memory caching primitives for .NET.\n\n[![NuGet version](https://badge.fury.io/nu/BitFaster.Caching.svg)](https://badge.fury.io/nu/BitFaster.Caching) ![Nuget](https://img.shields.io/nuget/dt/bitfaster.caching) ![main](https://github.com/BitFaster/BitFaster.Caching/actions/workflows/gate.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/bitfaster/BitFaster.Caching/badge.svg?branch=main)](https://coveralls.io/github/bitfaster/BitFaster.Caching?branch=main)\n\n# Features\n\n- [ConcurrentLru](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLru), a lightweight pseudo LRU based on the [2Q](https://www.vldb.org/conf/1994/P439.PDF) eviction policy. Also with [time based eviction](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLru:-Time%E2%80%90based-eviction).\n- [ConcurrentLfu](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLfu), an approximate LFU based on the [W-TinyLFU](https://arxiv.org/pdf/1512.00727.pdf) admission policy.\n- Configurable [atomic valueFactory](https://github.com/bitfaster/BitFaster.Caching/wiki/Atomic-GetOrAdd) to mitigate [cache stampede](https://en.wikipedia.org/wiki/Cache_stampede).\n- Configurable [thread-safe wrappers for IDisposable](https://github.com/bitfaster/BitFaster.Caching/wiki/IDisposable-and-Scoped-values) cache values.\n- A [builder API](https://github.com/bitfaster/BitFaster.Caching/wiki/Cache-Builders) to easily configure cache features.\n- [SingletonCache](https://github.com/bitfaster/BitFaster.Caching/wiki/SingletonCache) for caching single instance values, such as lock objects.\n- High performance [concurrent counters](https://github.com/bitfaster/BitFaster.Caching/wiki/Metrics).\n\n# Documentation\n\nPlease refer to the [wiki](https://github.com/bitfaster/BitFaster.Caching/wiki) for full API documentation, and a complete analysis of hit rate, latency and throughput.\n\n# Getting started\n    \nBitFaster.Caching is installed from NuGet:\n\n`dotnet add package BitFaster.Caching`\n\n## ConcurrentLru\n\n`ConcurrentLru` is a light weight drop in replacement for `ConcurrentDictionary`, but with bounded size enforced by the TU-Q eviction policy (derived from [2Q](https://www.vldb.org/conf/1994/P439.PDF)). 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.\n\nChoose a capacity and use just like `ConcurrentDictionary`, but with bounded size:\n\n```csharp\nint capacity = 128;\nvar lru = new ConcurrentLru\u003cstring, SomeItem\u003e(capacity);\n\nvar value = lru.GetOrAdd(\"key\", (key) =\u003e new SomeItem(key));\n```\n\n## ConcurrentLfu\n\n`ConcurrentLfu` is a drop in replacement for `ConcurrentDictionary`, but with bounded size enforced by the [W-TinyLFU eviction policy](https://arxiv.org/pdf/1512.00727.pdf). `ConcurrentLfu` has near optimal hit rate and high scalability. Reads and writes are buffered then replayed asynchronously to mitigate lock contention.\n\nChoose a capacity and use just like `ConcurrentDictionary`, but with bounded size:\n\n```csharp\nint capacity = 128;\nvar lfu = new ConcurrentLfu\u003cstring, SomeItem\u003e(capacity);\n\nvar value = lfu.GetOrAdd(\"key\", (key) =\u003e new SomeItem(key));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfaster%2FBitFaster.Caching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfaster%2FBitFaster.Caching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfaster%2FBitFaster.Caching/lists"}