FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
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, distributed, hybrid, 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 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.
FusionCache received the Google Open Source 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.
What about each global or entry option? Sure thing, there's an ️ Options page for that.
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.
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, they are 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.
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.
FusionCache has a lot of features, let's see them grouped together:
IDistributedCache can be used as an optional 2nd level, all transparentlyDuration), since they depends on the value being cached itselfILogger interfaceThat was a lot, but not all!
Something more ?Also, FusionCache has some nice additional features:
null values differently than "no value". This creates a less ambiguous usage, and typically leads to better performance because it avoids the classic problem of not being able to differentiate between "the value was not in the cache, go check the database" and "the value was in the cache, and it was null"JitterMaxDuration will add a small randomized extra duration to a cache entry's normal duration. This is useful to prevent variations of the Cache Stampede problem in a multi-node scenarioCancellationToken, so it is easy to cancel an entire pipeline of operation gracefullyWe'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!
Main packages:
| Package Name | Version | Downloads |
|---|---|---|
| ZiggyCreatures.FusionCache The core package |
||
| ZiggyCreatures.FusionCache.OpenTelemetry Adds native support for OpenTelemetry setup |
||
| ZiggyCreatures.FusionCache.Chaos A package to add some controlled chaos, for testing |
Serializers:
| Package Name | Version | Downloads |
|---|---|---|
| ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson A serializer, based on Newtonsoft Json.NET |
||
| ZiggyCreatures.FusionCache.Serialization.SystemTextJson A serializer, based on the new System.Text.Json |
||
| ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack A MessagePack serializer, based on the most used MessagePack serializer on .NET |
||
| ZiggyCreatures.FusionCache.Serialization.ProtoBufNet A Protobuf serializer, based on one of the most used protobuf-net serializer on .NET |
||
| ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack A serializer based on the uber fast new serializer by Neuecc, MemoryPack |
[](https://www.nuget.org/packages/ZiggyCreatures.FusionCache.Serialization.Cys |
No open issues yet, or sync has not completed.