ZiggyCreatures.FusionCache 2.2.0-preview-1

FusionCache

FusionCache logo

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.

FusionCache diagram

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.

๐Ÿ“บ Media

More into videos?

I've been lucky enough to be invited on some shows and podcasts here and there: you can find them in the Media section.

A good example is when the fine folks at On .NET invited me on the show to allow me to mumbling random caching stuff.

On .NET Talk

โœ” Features

FusionCache has a lot of features, let's see them grouped together:

Resiliency

Performance & Scalability

Flexibility

Observability

โญ 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.

FusionCache Simulator

๐Ÿงฐ 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 14 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.

Showing the top 20 packages that depend on ZiggyCreatures.FusionCache.

Packages Downloads
ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis
FusionCache backplane for Redis based on the StackExchange.Redis library
4
ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis
FusionCache backplane for Redis based on the StackExchange.Redis library
5
ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis
FusionCache backplane for Redis based on the StackExchange.Redis library
41
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
FusionCache serializer based on Newtonsoft Json.NET
4
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
FusionCache serializer based on Newtonsoft Json.NET
5
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
FusionCache serializer based on Newtonsoft Json.NET
6
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
FusionCache serializer based on Newtonsoft Json.NET
44

- Change: updated multi-targeting to be more slim and to include only the currently supported versions - Add: make the AOT support official - Add: expose the current distributed cache, if any - Add: expose the current backplane, if any - Add NullFusionCache support via DI - Add: new memory locker based on the 3rd party AsyncKeyedLock library - Perf: better perf for Clear(true) when Raw Clear is possible (eg: L1 only) - Change: more async usage with the backplane (less thread blocking) - Change: better, more differentiated log levels - Change: no more distributed cache errors in the logs when used internally, only warnings - Fix: fixed a bug with Eager Refresh in high concurrency scenarios - Fix: fixed a small bug happening when using jittering and fail-safe - Update: package dependencies

Version Downloads Last updated
2.3.0 4 06/10/2025
2.2.0 4 05/23/2025
2.2.0-preview-1 4 04/14/2025
2.1.0 35 03/16/2025
2.0.2 3 06/08/2025
2.0.1 4 04/01/2025
2.0.0 4 04/01/2025
2.0.0-preview-4 4 04/01/2025
2.0.0-preview-3 4 04/01/2025
2.0.0-preview-2 3 04/01/2025
2.0.0-preview-1 3 04/01/2025
1.4.1 4 04/01/2025
1.4.0 4 04/01/2025
1.3.0 4 04/01/2025
1.2.0 4 04/01/2025
1.2.0-preview1 4 04/01/2025
1.1.0 4 04/01/2025
1.0.0 5 04/01/2025
1.0.0-preview2 4 04/01/2025
1.0.0-preview1 4 04/01/2025
0.26.0 4 04/01/2025
0.25.0 4 04/01/2025
0.25.0-preview1 4 04/01/2025
0.24.0 6 04/01/2025
0.24.0-preview1 4 04/01/2025
0.23.0 4 04/01/2025
0.22.0 3 04/01/2025
0.21.0 4 04/01/2025
0.21.0-preview2 4 04/01/2025
0.21.0-preview1 4 04/01/2025
0.20.0 5 04/01/2025
0.20.0-preview2 3 04/01/2025
0.20.0-preview1 4 04/01/2025
0.19.0 5 04/01/2025
0.18.0 4 04/01/2025
0.17.0 4 04/01/2025
0.16.0 4 04/01/2025
0.15.0 3 04/01/2025
0.14.0 4 04/01/2025
0.13.0 4 04/01/2025
0.12.0 4 04/01/2025
0.11.1 4 04/01/2025
0.11.0 4 04/01/2025
0.10.0 4 04/01/2025
0.10.0-preview1 6 04/01/2025
0.9.0 3 04/01/2025
0.1.10-beta3 4 04/01/2025
0.1.10-beta2 4 04/01/2025
0.1.10-beta1 4 04/01/2025
0.1.10-alpha2 6 04/01/2025
0.1.10-alpha1 4 04/01/2025
0.1.9 4 04/01/2025
0.1.8 4 04/01/2025
0.1.7 4 04/01/2025
0.1.6 4 04/01/2025
0.1.5 3 04/01/2025
0.1.4 4 04/01/2025
0.1.3 4 04/01/2025
0.1.2 4 04/01/2025
0.1.1 4 04/01/2025
0.1.0 4 04/01/2025