![]() |
VOOZH | about |
dotnet add package ZiggyCreatures.FusionCache --version 1.2.0-preview1
NuGet\Install-Package ZiggyCreatures.FusionCache -Version 1.2.0-preview1
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.2.0-preview1" />
<PackageVersion Include="ZiggyCreatures.FusionCache" Version="1.2.0-preview1" />Directory.Packages.props
<PackageReference Include="ZiggyCreatures.FusionCache" />Project file
paket add ZiggyCreatures.FusionCache --version 1.2.0-preview1
#r "nuget: ZiggyCreatures.FusionCache, 1.2.0-preview1"
#:package ZiggyCreatures.FusionCache@1.2.0-preview1
#addin nuget:?package=ZiggyCreatures.FusionCache&version=1.2.0-preview1&prereleaseInstall as a Cake Addin
#tool nuget:?package=ZiggyCreatures.FusionCache&version=1.2.0-preview1&prereleaseInstall as a Cake Tool
It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
It uses a memory cache (any impl of the standard IMemoryCache interface) as the primary backing store and optionally a distributed, 2nd level cache (any impl of the standard IDistributedCache interface) as a secondary backing store for better resilience and higher performance, for example in a multi-node scenario or to avoid the typical effects of a cold start (initial empty cache, maybe after a restart).
Optionally, it can also use a backplane: in a multi-node scenario this will send notifications to the other nodes to keep each node's memory cache perfectly synchronized, without any additional work.
FusionCache also includes some advanced resiliency features like a fail-safe mechanism, cache stampede prevention, fine grained soft/hard timeouts with background factory completion, customizable extensive logging and more (see below).
On August 2021, FusionCache received the Google Open Source Peer Bonus Award: here is the official blogpost.
With 🦄 A Gentle Introduction you'll get yourself comfortable with the overall concepts.
Want to start using it immediately? There's a ⭐ Quick Start for you.
Curious about what you can achieve from start to finish? There's a 👩🏫 Step By Step guide.
In search of all the docs? There's a page for that, too.
More into videos? The fine folks at On .NET have been kind enough to invite me on the show and listen to me mumbling random caching stuff.
These are the key features of FusionCache:
IDistributedCacheILogger interfaceFusionCache can be installed via the nuget UI (search for the ZiggyCreatures.FusionCache package) or via the nuget package manager console:
PM> Install-Package ZiggyCreatures.FusionCache
As an example, imagine having a method that retrieves a product from your database:
Product GetProductFromDb(int id) {
// YOUR DATABASE CALL HERE
}
💡 This is using the sync programming model, but it would be equally valid with the newer async one for even better performance.
To start using FusionCache the first thing is create a cache instance:
var cache = new FusionCache(new FusionCacheOptions());
If instead you are using DI (Dependency Injection) use this:
services.AddFusionCache();
We can also specify some global options, like a default FusionCacheEntryOptions object to serve as a default for each call we'll make, with a duration of 2 minutes and a Low priority:
var cache = new FusionCache(new FusionCacheOptions() {
DefaultEntryOptions = new FusionCacheEntryOptions {
Duration = TimeSpan.FromMinutes(2),
Priority = CacheItemPriority.Low
}
});
Or, using DI, like this:
services.AddFusionCache()
.WithDefaultEntryOptions(new FusionCacheEntryOptions {
Duration = TimeSpan.FromMinutes(2),
Priority = CacheItemPriority.Low
})
;
Now, to get the product from the cache and, if not there, get it from the database in an optimized way and cache it for 30 sec simply do this:
var id = 42;
cache.GetOrSet<Product>(
$"product:{id}",
_ => GetProductFromDb(id),
TimeSpan.FromSeconds(30)
);
That's it 🎉
Distributed systems are, in general, quite complex to understand.
When using FusionCache with the distributed cache, the backplane and auto-recovery the Simulator can help us seeing the whole picture.
FusionCache targets .NET Standard 2.0 so any compatible .NET implementation is fine: this means .NET Framework (the old one), .NET Core 2+ and .NET 5/6+ (the new ones), Mono 5.4+ and more (see here for a complete rundown).
NOTE: if you are running on .NET Framework 4.6.1 and want to use .NET Standard packages Microsoft suggests to upgrade to .NET Framework 4.7.2 or higher (see the .NET Standard Documentation) to avoid some known dependency issues.
Yes!
FusionCache is being used in production on real world projects for years, happily handling millions of requests.
Considering that the FusionCache packages have been downloaded more than 4 million times (thanks everybody!) it may very well be used even more.
And again, if you are using it please ✉ drop me a line, I'd like to know!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on ZiggyCreatures.FusionCache:
| Package | Downloads |
|---|---|
|
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
FusionCache serializer based on Newtonsoft Json.NET |
|
|
ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis
FusionCache backplane for Redis based on the StackExchange.Redis library |
|
|
ZiggyCreatures.FusionCache.Serialization.SystemTextJson
FusionCache serializer based on System.Text.Json |
|
|
ZiggyCreatures.FusionCache.Chaos
Chaos-related utilities and implementations of various componenets (like a distributed cache or a backplane), useful for things like testing dependent components' behavior in a controlled failing environment. |
|
|
ZiggyCreatures.FusionCache.OpenTelemetry
Add native OpenTelemetry support to FusionCache. |
Showing the top 17 popular GitHub repositories that depend on ZiggyCreatures.FusionCache:
| Repository | Stars |
|---|---|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
|
oqtane/oqtane.framework
Oqtane is an open-source developer productivity platform for building modern .NET applications and websites that run on Web, Desktop and Mobile.
|
|
|
Azure/data-api-builder
Data API builder provides modern REST, GraphQL endpoints and MCP tools to your Azure Databases and on-prem stores.
|
|
|
VahidN/EFCoreSecondLevelCacheInterceptor
EF Core Second Level Cache Interceptor
|
|
|
TurnerSoftware/CacheTower
An efficient multi-layered caching system for .NET
|
|
|
YSGStudyHards/DotNetExercises
⚔【DotNetGuide专栏C#/.NET/.NET Core编程技巧练习集】C#/.NET/.NET Core编程常用语法、算法、技巧、中间件、类库、工作业务实操练习集,配套详细的文章教程和代码示例,助力快速掌握C#/.NET/.NET Core中各种编程常用语法、算法、技巧、中间件、类库、工作业务实操等等。
|
|
| LANCommander/LANCommander | |
|
Corsinvest/cv4pve-admin
Web management platform for Proxmox VE clusters — like vCenter but for Proxmox
|
|
|
JasonBock/Rocks
A mocking library based on the Compiler APIs (Roslyn + Mocks)
|
|
|
dotnet/dotnet-operator-sdk
KubeOps is a Kubernetes operator sdk in dotnet. Strongly inspired by kubebuilder.
|
|
|
ikyriak/IdempotentAPI
A .NET library that handles the HTTP write operations (POST and PATCH) that can affect only once for the given request data and idempotency-key by using an ASP.NET Core attribute (filter).
|
|
|
neozhu/cleanaspire
CleanAspire is a cloud-native template built on Aspire, using .NET 10 Minimal APIs and Blazor WebAssembly to deliver lightweight, scalable PWAs with offline support.
|
|
|
DuendeSoftware/foss
Duende's Free and Open Source software.
|
|
|
DamianMorozov/OpenTgResearcher
OpenTgResearcher - tool for analyzing Telegram chats and downloading their content
|
|
|
ncosentino/DevLeader
Projects referred to by my blog, Dev Leader
|
|
|
neon-sunset/fast-cache
The fastest cache library written in C# for items with set expiration time. Easy to use, thread-safe and light on memory.
|
|
|
dr-marek-jaskula/DomainDrivenDesignUniversity
This project was made for tutorial purpose - to clearly present the domain driven design concept.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.6.0 | 1,779,703 | 3/14/2026 |
| 2.5.0 | 2,864,368 | 12/22/2025 |
| 2.4.0 | 3,945,068 | 8/17/2025 |
| 2.3.0 | 2,449,018 | 6/9/2025 |
| 2.2.0 | 1,599,372 | 4/18/2025 |
| 2.2.0-preview-1 | 11,587 | 4/6/2025 |
| 2.1.0 | 1,808,937 | 2/2/2025 |
| 2.0.2 | 790,936 | 4/18/2025 |
| 2.0.1 | 335,272 | 2/23/2025 |
| 2.0.0 | 1,001,454 | 1/19/2025 |
| 2.0.0-preview-4 | 6,184 | 1/1/2025 |
| 2.0.0-preview-3 | 52,520 | 12/9/2024 |
| 2.0.0-preview-2 | 3,603 | 11/14/2024 |
| 2.0.0-preview-1 | 1,950 | 11/10/2024 |
| 1.4.1 | 2,107,038 | 10/27/2024 |
| 1.4.0 | 1,729,249 | 9/15/2024 |
| 1.3.0 | 3,280,972 | 8/4/2024 |
| 1.2.0 | 834,638 | 6/2/2024 |
| 1.2.0-preview1 | 1,269 | 5/19/2024 |
| 1.1.0 | 639,841 | 4/24/2024 |
- Add: full support for DI keyed services
- Add: new PreferSyncSerialization option