ZiggyCreatures.FusionCache 2.5.0

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.

๐Ÿง‘โ€๐Ÿซ Courses (more)

If you are interested in all things caching, I published a course on Dometrain:

Caching Course on Dometrain

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.

๐Ÿ“บ 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.

On .NET Talk

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

Performance & Scalability

Flexibility

Observability

โ“‚๏ธ 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.

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 46 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: support for distributed Cache Stampede protection, thanks to a new IFusionCacheDistributedLocker component - Add: new MemoryCacheDuration option to override the normal Duration for the L1 (memory level), useful when using an L2 without a backplane (to reduce the incoherency window) - Add: Best Practices Advisor for automatic analysis and suggestions - Add: new IgnoreTimeoutsWhenDebugging option, to ignore timeouts when a debugger is attached - Change: the timestamp for a new entry produced by a factory is now set when the factory ends and not when it starts, to better reflect the mos precise moment in time when the value has been produced - Perf: various internal performance improvements, mostly for edge cases - Update: package dependencies

Version Downloads Last updated
2.6.0 1 03/26/2026
2.5.0 1 03/26/2026
2.4.0 1 03/26/2026
2.3.0 1 03/26/2026
2.2.0 24 03/23/2026
2.2.0-preview-1 1 03/26/2026
2.1.0 1 03/26/2026
2.0.2 1 03/26/2026
2.0.1 1 03/26/2026
2.0.0 1 03/26/2026
2.0.0-preview-4 1 03/26/2026
2.0.0-preview-3 1 03/26/2026
2.0.0-preview-2 1 03/26/2026
2.0.0-preview-1 1 03/26/2026
1.4.1 1 03/26/2026
1.4.0 1 03/26/2026
1.3.0 1 03/26/2026
1.2.0 1 03/26/2026
1.2.0-preview1 1 03/26/2026
1.1.0 1 03/26/2026
1.0.0 1 03/26/2026
1.0.0-preview2 1 03/26/2026
1.0.0-preview1 1 03/26/2026
0.26.0 1 03/26/2026
0.25.0 1 03/26/2026
0.25.0-preview1 1 03/26/2026
0.24.0 1 03/26/2026
0.24.0-preview1 1 03/26/2026
0.23.0 1 03/26/2026
0.22.0 1 03/26/2026
0.21.0 1 03/26/2026
0.21.0-preview2 1 03/26/2026
0.21.0-preview1 1 03/26/2026
0.20.0 1 03/26/2026
0.20.0-preview2 1 03/26/2026
0.20.0-preview1 1 03/26/2026
0.19.0 1 03/26/2026
0.18.0 1 03/26/2026
0.17.0 1 03/26/2026
0.16.0 1 03/26/2026
0.15.0 1 03/26/2026
0.14.0 1 03/26/2026
0.13.0 1 03/26/2026
0.12.0 1 03/26/2026
0.11.1 1 03/26/2026
0.11.0 1 03/26/2026
0.10.0 1 03/26/2026
0.10.0-preview1 1 03/26/2026
0.9.0 1 03/26/2026
0.1.10-beta3 1 03/26/2026
0.1.10-beta2 1 03/26/2026
0.1.10-beta1 1 03/26/2026
0.1.10-alpha2 1 03/26/2026
0.1.10-alpha1 1 03/26/2026
0.1.9 1 03/26/2026
0.1.8 1 03/26/2026
0.1.7 1 03/26/2026
0.1.6 1 03/26/2026
0.1.5 1 03/26/2026
0.1.4 1 03/26/2026
0.1.3 1 03/26/2026
0.1.2 1 03/26/2026
0.1.1 1 03/26/2026
0.1.0 1 03/26/2026