ZiggyCreatures.FusionCache 2.7.0
FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
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 tried to put together these experiences and came up with FusionCache.

Being a hybrid cache means it can transparently work as either a normal memory cache (L1) or as a multi-level cache (L1+L2), where the distributed 2nd level (L2) can be any implementation of the standard IDistributedCache interface: this will get us better cold starts, better horizontal scalability, more resiliency and overall better performance.
FusionCache also includes an optional backplane for realtime sync between multiple nodes and advanced resiliency features like cache stampede protection, a fail-safe mechanism, soft/hard timeouts, eager refresh, full observability via logging and OpenTelemetry, tagging and much more.
It's being used in production on real-world projects with huge volumes for years, and is even used by Microsoft itself in its products like Data API Builder.
It's also compatible with the new HybridCache from Microsoft, thanks to a powerful integration.
๐ Award
On August 2021, FusionCache received the Google Open Source Peer Bonus Award: here is the official blogpost.
๐ Getting Started
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.
๐งโ๐ซ Courses (more and more)
If you are interested in all things caching, I published 2 courses on Dometrain: Caching in .NET, Getting Started & Deep Dive.
If you like the FusionCache docs, you may like it too.
But mind you, it's not just about FusionCache but about caching as a whole: we'll go from the very foundations to pretty advanced topics and scenarios. We'll cover performance, robustness, resiliency and we'll see different real-world problems and, most importantly, solutions for them.
I tried condensing 20+ years dealing with caching in one place, all in an approachable way.
One journey, two chapters, filled with everything you can ask for about caching.
๐บ Talks (more)
Are you more into videos?
Along the years I've been lucky enough to be invited to some conferences, shows or podcasts both online and around the world, of course to talk about all things caching and FusionCache.
A good example is when the fine folks at On .NET invited me on the show to allow me to mumbling random caching stuff.
You can find most of them, sometimes with the related slides, in the dedicated repo here.
โ Features
FusionCache has a lot of features, let's see them grouped together:
Resiliency
- ๐ก๏ธ Cache Stampede: automatic protection, both local (single node) and distributed (multiple nodes)
- ๐ฃ Fail-Safe: a mechanism to avoids transient failures, by reusing an expired entry as a temporary fallback
- โฉ๏ธ Auto-Recovery: self-healing for the entire cache, all automatically
Performance & Scalability
- ๐ L1+L2: any implementation of
IDistributedCachecan be used as an optional 2nd level, all transparently - ๐ข Backplane: in a multi-node scenario, it can notify the other nodes about changes in the cache, so all will be in-sync
- โฑ Soft/Hard Timeouts: a slow factory (or distributed cache) will not slow down your application, and no data will be wasted
- ๐ฆ Eager Refresh: start a non-blocking background refresh before the expiration occurs
- ๐ Conditional Refresh: like HTTP Conditional Requests, but for caching
- ๐ Background Distributed Operations: distributed operations can easily be executed in the background, safely, for better performance
Flexibility
- ๐ Named Caches: easily work with multiple named caches, even if differently configured
- ๐ท๏ธ Tagging: tags can be associated to entries, to later expire them all at once
- ๐งผ Clear: clear an entire cache, even with shared L2, cache key prefix, etc
- โ๏ธ Microsoft HybridCache: can be used as an implementation of the new HybridCache abstraction from Microsoft, all while adding extra features
- ๐งโโ๏ธ Adaptive Caching: for when you don't know upfront the entry options (eg:
Duration), since they depends on the value being cached itself - ๐ Dependency Injection + Builder: native support for Dependency Injection, with a nice fluent interface including a Builder support
- โ Auto-Clone: be sure that cached values returned can be safely modified
- ๐ซ Fully sync/async: native support for both the synchronous and asynchronous programming model
- ๐งฉ Plugins: extend FusionCache with additional behavior like adding support for metrics, statistics, etc...
Observability
- ๐ญ OpenTelemetry: native observability support via OpenTelemetry
- ๐ Logging: comprehensive, structured and customizable, via the standard
ILoggerinterface - ๐ Events: a comprehensive set of events, both at a high level and at lower levels (memory/distributed)
โ๏ธ Microsoft HybridCache
We've probably all heard about the new kid on the block introduced by Microsoft with .NET 9: HybridCache.
So what does it mean for FusionCache? Does one replace the other? Or can they somehow work together?
It's pretty cool actually, so let's find out!
โญ Quick Start
Just install the ZiggyCreatures.FusionCache Nuget package:
PM> Install-Package ZiggyCreatures.FusionCache
Then, let's say we have a method that loads a product from the database:
Product GetProductFromDb(int id) {
// DATABASE CALL HERE
}
(This is using the sync programming model, but it would be equally valid with the newer async one)
Then we create a FusionCache instance:
var cache = new FusionCache(new FusionCacheOptions());
or, if using dependency injection:
services.AddFusionCache();
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:
var id = 42;
cache.GetOrSet<Product>(
$"product:{id}",
_ => GetProductFromDb(id),
TimeSpan.FromSeconds(30)
);
That's it.
๐ฅ๏ธ Simulator
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.
๐งฐ Supported Platforms
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.
๐ Comparison
There are various alternatives out there with different features, different performance characteristics (cpu/memory) and in general a different set of pros/cons.
A feature comparison between existing .NET caching solutions may help you choose which one to use.
๐ผ Is it Production Ready :tm: ?
Yes!
FusionCache is being used in production on real world projects for years, happily handling billions of requests.
Considering that the FusionCache packages have been downloaded more than 72 million times (thanks everybody!) it may very well be used even more.
Oh, and it is being used in products by Microsoft itself, like Data API Builder!
๐ Are you using it?
If you find FusionCache useful please let me know, I'm interested in knowing your use case!
This is the only way for me to know how it is helping people.
๐ฐ Support
Nothing to do here.
After years of using a lot of open source stuff for free, this is just me trying to give something back to the community.
Will FusionCache one day switch to a commercial model? Nope, not gonna happen.
Mind you: nothing against other projects making the switch, if done in a proper way, but no thanks not interested. And FWIW I don't even accept donations, which are btw a great thing: that should tell you how much I'm into this for the money.
Again, this is me trying to give something back to the community.
If you really want to talk about money, please consider making ๐ฉท a donation to a good cause of your choosing, and let me know about that.
No packages depend on ZiggyCreatures.FusionCache.
- Add: new DistributedLockerErrorsLogLevel option - Change: better handling of parent traces with observability - Change: now the tag is included in the trace when doing a RemoveByTag(tag) operation - Change: in the Advisor, add warning for System.Text.Json serialization issues related (mainly) to value tuples - Add: new SerializationIssuesLogLevel option - Change: in the Advisor, better check for a missing CacheKeyPrefix - Fix: better temporal checks during an L2 to L1 copy - Fix: the OperationId is now automatically generated even without a logger if there are listeners for activities (e.g.: OTEL traces) - Fix: better exception handling for user-initiated cancellations while using the distributed locker - Fix: updated dependency to OpenTelemetry.Api to ensure a vulnerability fix in downstream dependencies - Perf: minor performance improvements, particularly in some commonly used internal checks - Update: package dependencies
.NET 8.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
.NET 9.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
.NET Standard 2.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- System.Collections.Immutable (>= 10.0.1)
- System.Diagnostics.DiagnosticSource (>= 10.0.1)
- System.Threading.Tasks.Extensions (>= 4.6.3)
| Version | Downloads | Last updated |
|---|---|---|
| 2.8.0 | 2 | 09/16/2026 |
| 2.7.2 | 10 | 08/29/2026 |
| 2.7.1 | 14 | 08/21/2026 |
| 2.7.0 | 13 | 08/19/2026 |
| 2.6.0 | 1,233 | 03/26/2026 |
| 2.5.0 | 36 | 03/26/2026 |
| 2.4.0 | 37 | 03/26/2026 |
| 2.3.0 | 38 | 03/26/2026 |
| 2.2.0 | 253 | 03/23/2026 |
| 2.2.0-preview-1 | 38 | 03/26/2026 |
| 2.1.0 | 39 | 03/26/2026 |
| 2.0.2 | 31 | 03/26/2026 |
| 2.0.1 | 35 | 03/26/2026 |
| 2.0.0 | 39 | 03/26/2026 |
| 2.0.0-preview-4 | 32 | 03/26/2026 |
| 2.0.0-preview-3 | 34 | 03/26/2026 |
| 2.0.0-preview-2 | 33 | 03/26/2026 |
| 2.0.0-preview-1 | 32 | 03/26/2026 |
| 1.4.1 | 24 | 03/26/2026 |
| 1.4.0 | 26 | 03/26/2026 |
| 1.3.0 | 37 | 03/26/2026 |
| 1.2.0 | 36 | 03/26/2026 |
| 1.2.0-preview1 | 35 | 03/26/2026 |
| 1.1.0 | 37 | 03/26/2026 |
| 1.0.0 | 34 | 03/26/2026 |
| 1.0.0-preview2 | 33 | 03/26/2026 |
| 1.0.0-preview1 | 32 | 03/26/2026 |
| 0.26.0 | 25 | 03/26/2026 |
| 0.25.0 | 27 | 03/26/2026 |
| 0.25.0-preview1 | 30 | 03/26/2026 |
| 0.24.0 | 38 | 03/26/2026 |
| 0.24.0-preview1 | 34 | 03/26/2026 |
| 0.23.0 | 36 | 03/26/2026 |
| 0.22.0 | 34 | 03/26/2026 |
| 0.21.0 | 36 | 03/26/2026 |
| 0.21.0-preview2 | 37 | 03/26/2026 |
| 0.21.0-preview1 | 29 | 03/26/2026 |
| 0.20.0 | 31 | 03/26/2026 |
| 0.20.0-preview2 | 30 | 03/26/2026 |
| 0.20.0-preview1 | 35 | 03/26/2026 |
| 0.19.0 | 39 | 03/26/2026 |
| 0.18.0 | 40 | 03/26/2026 |
| 0.17.0 | 29 | 03/26/2026 |
| 0.16.0 | 32 | 03/26/2026 |
| 0.15.0 | 35 | 03/26/2026 |
| 0.14.0 | 35 | 03/26/2026 |
| 0.13.0 | 23 | 03/26/2026 |
| 0.12.0 | 33 | 03/26/2026 |
| 0.11.1 | 32 | 03/26/2026 |
| 0.11.0 | 38 | 03/26/2026 |
| 0.10.0 | 39 | 03/26/2026 |
| 0.10.0-preview1 | 29 | 03/26/2026 |
| 0.9.0 | 34 | 03/26/2026 |
| 0.1.10-beta3 | 32 | 03/26/2026 |
| 0.1.10-beta2 | 34 | 03/26/2026 |
| 0.1.10-beta1 | 37 | 03/26/2026 |
| 0.1.10-alpha2 | 36 | 03/26/2026 |
| 0.1.10-alpha1 | 34 | 03/26/2026 |
| 0.1.9 | 36 | 03/26/2026 |
| 0.1.8 | 34 | 03/26/2026 |
| 0.1.7 | 34 | 03/26/2026 |
| 0.1.6 | 35 | 03/26/2026 |
| 0.1.5 | 35 | 03/26/2026 |
| 0.1.4 | 33 | 03/26/2026 |
| 0.1.3 | 34 | 03/26/2026 |
| 0.1.2 | 35 | 03/26/2026 |
| 0.1.1 | 34 | 03/26/2026 |
| 0.1.0 | 28 | 03/26/2026 |



