SkillAgentSearch skills...

FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.

Install / Use

/learn @ZiggyCreatures/FusionCache

README

<div align="center">

FusionCache logo

FusionCache

</div> <div align="center">

License: MIT NuGet

</div>

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.

<div style="text-align:center;">

FusionCache diagram

</div>

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.

🏆 Awards

<div align="center">

Google OSS Award

</div>

FusionCache received the Google Open Source Award: here is the official blogpost.

📕 Getting Started (more)

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.

🧑‍🏫 Courses (more)

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

<div align="center">

Caching Course on Dometrain

</div>

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.

<div align="center">

On .NET Talk

</div>

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 IDistributedCache can 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 ILogger interface
  • 📞 Events: a comprehensive set of events, both at a high level and at lower levels (memory/distributed)

That was a lot, but not all!

<details> <summary>Something more 😏 ?</summary> <br/>

Also, FusionCache has some nice additional features:

  • ✅ Portable: targets .NET Standard 2.0, so it can run almost everywhere
  • ✅ High Performance: FusionCache is optimized to minimize CPU usage and memory allocations to get better performance and lower the cost of your infrastructure all while obtaining a more stable, error resilient application
  • ✅ Null caching: explicitly supports caching of 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"
  • ✅ Circuit-breaker: it is possible to enable a simple circuit-breaker for when the distributed cache or the backplane become temporarily unavailable. This will prevent those components to be hit with an excessive load of requests (that would probably fail anyway) in a problematic moment, so it can gracefully get back on its feet. More advanced scenarios can be covered using a dedicated solution, like <a href="https://github.com/App-vNext/Polly">Polly</a>
  • ✅ Dynamic Jittering: setting JitterMaxDuration will add a small randomized extra duration to a cache entry's normal duration. This is useful to prevent variations of the <a href="https://en.wikipedia.org/wiki/Cache_stampede">Cache Stampede problem</a> in a multi-node scenario
  • ✅ Cancellation: every method supports cancellation via the standard CancellationToken, so it is easy to cancel an entire pipeline of operation gracefully
  • ✅ Code comments: every property and method is fully documented in code, with useful informations provided via IntelliSense or similar technologies
  • ✅ Fully annotated for nullability: every usage of nullable references has been annotated for a better flow analysis by the compiler
</details>

Ⓜ️ Microsoft HybridCache (more)

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!

📦 Packages

Main packages:

| Package Name | Version | Downloads | |--------------------------------|:---------

View on GitHub
GitHub Stars3.7k
CategoryDevelopment
Updated6h ago
Forks183

Languages

C#

Security Score

100/100

Audited on Mar 31, 2026

No findings