VOOZH about

URL: https://www.nuget.org/packages/ZiggyCreatures.FusionCache/1.2.0-preview1

⇱ NuGet Gallery | ZiggyCreatures.FusionCache 1.2.0-preview1




👁 Image
ZiggyCreatures.FusionCache 1.2.0-preview1

Prefix Reserved
This is a prerelease version of ZiggyCreatures.FusionCache.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ZiggyCreatures.FusionCache --version 1.2.0-preview1
 
 
NuGet\Install-Package ZiggyCreatures.FusionCache -Version 1.2.0-preview1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.2.0-preview1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZiggyCreatures.FusionCache" Version="1.2.0-preview1" />
 
Directory.Packages.props
<PackageReference Include="ZiggyCreatures.FusionCache" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZiggyCreatures.FusionCache --version 1.2.0-preview1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZiggyCreatures.FusionCache, 1.2.0-preview1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZiggyCreatures.FusionCache@1.2.0-preview1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZiggyCreatures.FusionCache&version=1.2.0-preview1&prerelease
 
Install as a Cake Addin
#tool nuget:?package=ZiggyCreatures.FusionCache&version=1.2.0-preview1&prerelease
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

FusionCache

👁 FusionCache logo

FusionCache is an easy to use, fast and robust cache with advanced resiliency features and an optional distributed 2nd level.

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've tried to put together these experiences and came up with FusionCache.

👁 FusionCache diagram

It uses a memory cache (any impl of the standard IMemoryCache interface) as the primary backing store and optionally a distributed, 2nd level cache (any impl of the standard IDistributedCache interface) as a secondary backing store for better resilience and higher performance, for example in a multi-node scenario or to avoid the typical effects of a cold start (initial empty cache, maybe after a restart).

Optionally, it can also use a backplane: in a multi-node scenario this will send notifications to the other nodes to keep each node's memory cache perfectly synchronized, without any additional work.

FusionCache also includes some advanced resiliency features like a fail-safe mechanism, cache stampede prevention, fine grained soft/hard timeouts with background factory completion, customizable extensive logging and more (see below).

🏆 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.

More into videos? The fine folks at On .NET have been kind enough to invite me on the show and listen to me mumbling random caching stuff.

👁 On .NET Talk

✔ Features

These are the key features of FusionCache:

  • 🛡️ Cache Stampede: automatic protection from the Cache Stampede problem
  • 🔀 2nd level: an optional 2nd level handled transparently, with any implementation of IDistributedCache
  • 💣 Fail-Safe: a mechanism to avoids transient failures, by reusing an expired entry as a temporary fallback
  • ⏱ Soft/Hard Timeouts: a slow factory (or distributed cache) will not slow down your application, and no data will be wasted
  • 📢 Backplane: in a multi-node scenario, it can notify the other nodes about changes in the cache, so all will be in-sync
  • ↩️ Auto-Recovery: automatic handling of transient issues with retries and sync logic
  • 🧙‍♂️ Adaptive Caching: for when you don't know upfront the cache duration, as it depends on the value being cached itself
  • 🔂 Conditional Refresh: like HTTP Conditional Requests, but for caching
  • 🦅 Eager Refresh: start a non-blocking background refresh before the expiration occurs
  • 🔃 Dependency Injection + Builder: native support for Dependency Injection, with a nice fluent interface including a Builder support
  • 📛 Named Caches: easily work with multiple named caches, even if differently configured
  • 🔭 OpenTelemetry: native observability support via OpenTelemetry
  • 📜 Logging: comprehensive, structured and customizable, via the standard ILogger interface
  • 💫 Fully sync/async: native support for both the synchronous and asynchronous programming model
  • 📞 Events: a comprehensive set of events, both at a high level and at lower levels (memory/distributed)
  • 🧩 Plugins: extend FusionCache with additional behavior like adding support for metrics, statistics, etc...

⭐ Quick Start

FusionCache can be installed via the nuget UI (search for the ZiggyCreatures.FusionCache package) or via the nuget package manager console:

PM> Install-Package ZiggyCreatures.FusionCache

As an example, imagine having a method that retrieves a product from your database:

Product GetProductFromDb(int id) {
	// YOUR DATABASE CALL HERE
}

💡 This is using the sync programming model, but it would be equally valid with the newer async one for even better performance.

To start using FusionCache the first thing is create a cache instance:

var cache = new FusionCache(new FusionCacheOptions());

If instead you are using DI (Dependency Injection) use this:

services.AddFusionCache();

We can also specify some global options, like a default FusionCacheEntryOptions object to serve as a default for each call we'll make, with a duration of 2 minutes and a Low priority:

var cache = new FusionCache(new FusionCacheOptions() {
	DefaultEntryOptions = new FusionCacheEntryOptions {
		Duration = TimeSpan.FromMinutes(2),
		Priority = CacheItemPriority.Low
	}
});

Or, using DI, like this:

services.AddFusionCache()
	.WithDefaultEntryOptions(new FusionCacheEntryOptions {
		Duration = TimeSpan.FromMinutes(2),
		Priority = CacheItemPriority.Low
	})
;

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 simply do this:

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.

💼 Is it Production Ready ™️ ?

Yes!

FusionCache is being used in production on real world projects for years, happily handling millions of requests.

Considering that the FusionCache packages have been downloaded more than 4 million times (thanks everybody!) it may very well be used even more.

And again, if you are using it please ✉ drop me a line, I'd like to know!

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (125)

Showing the top 5 NuGet packages that depend on ZiggyCreatures.FusionCache:

Package Downloads
ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson

FusionCache serializer based on Newtonsoft Json.NET

ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis

FusionCache backplane for Redis based on the StackExchange.Redis library

ZiggyCreatures.FusionCache.Serialization.SystemTextJson

FusionCache serializer based on System.Text.Json

ZiggyCreatures.FusionCache.Chaos

Chaos-related utilities and implementations of various componenets (like a distributed cache or a backplane), useful for things like testing dependent components' behavior in a controlled failing environment.

ZiggyCreatures.FusionCache.OpenTelemetry

Add native OpenTelemetry support to FusionCache.

GitHub repositories (17)

Showing the top 17 popular GitHub repositories that depend on ZiggyCreatures.FusionCache:

Repository Stars
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
oqtane/oqtane.framework
Oqtane is an open-source developer productivity platform for building modern .NET applications and websites that run on Web, Desktop and Mobile.
Azure/data-api-builder
Data API builder provides modern REST, GraphQL endpoints and MCP tools to your Azure Databases and on-prem stores.
VahidN/EFCoreSecondLevelCacheInterceptor
EF Core Second Level Cache Interceptor
TurnerSoftware/CacheTower
An efficient multi-layered caching system for .NET
YSGStudyHards/DotNetExercises
⚔【DotNetGuide专栏C#/.NET/.NET Core编程技巧练习集】C#/.NET/.NET Core编程常用语法、算法、技巧、中间件、类库、工作业务实操练习集,配套详细的文章教程和代码示例,助力快速掌握C#/.NET/.NET Core中各种编程常用语法、算法、技巧、中间件、类库、工作业务实操等等。
LANCommander/LANCommander
Corsinvest/cv4pve-admin
Web management platform for Proxmox VE clusters — like vCenter but for Proxmox
JasonBock/Rocks
A mocking library based on the Compiler APIs (Roslyn + Mocks)
dotnet/dotnet-operator-sdk
KubeOps is a Kubernetes operator sdk in dotnet. Strongly inspired by kubebuilder.
ikyriak/IdempotentAPI
A .NET library that handles the HTTP write operations (POST and PATCH) that can affect only once for the given request data and idempotency-key by using an ASP.NET Core attribute (filter).
neozhu/cleanaspire
CleanAspire is a cloud-native template built on Aspire, using .NET 10 Minimal APIs and Blazor WebAssembly to deliver lightweight, scalable PWAs with offline support.
DuendeSoftware/foss
Duende's Free and Open Source software.
DamianMorozov/OpenTgResearcher
OpenTgResearcher - tool for analyzing Telegram chats and downloading their content
ncosentino/DevLeader
Projects referred to by my blog, Dev Leader
neon-sunset/fast-cache
The fastest cache library written in C# for items with set expiration time. Easy to use, thread-safe and light on memory.
dr-marek-jaskula/DomainDrivenDesignUniversity
This project was made for tutorial purpose - to clearly present the domain driven design concept.
Version Downloads Last Updated
2.6.0 1,779,703 3/14/2026
2.5.0 2,864,368 12/22/2025
2.4.0 3,945,068 8/17/2025
2.3.0 2,449,018 6/9/2025
2.2.0 1,599,372 4/18/2025
2.2.0-preview-1 11,587 4/6/2025
2.1.0 1,808,937 2/2/2025
2.0.2 790,936 4/18/2025
2.0.1 335,272 2/23/2025
2.0.0 1,001,454 1/19/2025
2.0.0-preview-4 6,184 1/1/2025
2.0.0-preview-3 52,520 12/9/2024
2.0.0-preview-2 3,603 11/14/2024
2.0.0-preview-1 1,950 11/10/2024
1.4.1 2,107,038 10/27/2024
1.4.0 1,729,249 9/15/2024
1.3.0 3,280,972 8/4/2024
1.2.0 834,638 6/2/2024
1.2.0-preview1 1,269 5/19/2024
1.1.0 639,841 4/24/2024
Loading failed

- Add: full support for DI keyed services
- Add: new PreferSyncSerialization option