Rig.TUnit.Caching.Fusion 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Caching.Fusion.
dotnet add package Rig.TUnit.Caching.Fusion --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Caching.Fusion -Version 0.1.0-beta.2
                    
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="Rig.TUnit.Caching.Fusion" Version="0.1.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rig.TUnit.Caching.Fusion" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Caching.Fusion" />
                    
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 Rig.TUnit.Caching.Fusion --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Caching.Fusion, 0.1.0-beta.2"
                    
#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 Rig.TUnit.Caching.Fusion@0.1.0-beta.2
                    
#: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=Rig.TUnit.Caching.Fusion&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Caching.Fusion&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Caching.Fusion

FusionCache provider — L1 in-memory + optional L2 distributed + backplane, with fail-safe, eager refresh, and tag invalidation.

What this package is

The Rig.TUnit adapter for FusionCache. FusionCacheFixture configures an IFusionCache with production-shape defaults (fail-safe enabled, eager-refresh at 80 % TTL, 60 s default duration) and exposes FailSafeHelper + EagerRefreshHelper — pure decision-logic predicates that tests use to assert the cache should apply fail-safe or trigger an eager refresh, without racing the scheduler.

No container required — FusionCache is in-process. For the L2 distributed tier, pair with Rig.TUnit.Caching.Redis.

When to use it

  • Testing services that use FusionCache in production.
  • Verifying fail-safe fallback triggers when the underlying loader throws.
  • Asserting eager-refresh enters the right window near TTL expiry.
  • Not for: plain IMemoryCache — use Rig.TUnit.Caching.Memory.

Prerequisites

  • .NET 10 SDK
  • ZiggyCreatures.FusionCache 2.x (transitive)

Quick start

using Rig.TUnit.Caching.Fusion.Fixtures;

await using var fx = new FusionCacheFixture();
await fx.InitializeAsync();

var key = $"k-{Guid.NewGuid():N}";
var value = await fx.Cache.GetOrSetAsync<string>(key, async (_, _) =>
{
    await Task.Yield();
    return "computed";
});

Options

Property Type Default Description
DefaultDurationSeconds int 60 TTL for GetOrSet entries
IsFailSafeEnabled bool true Serve stale on loader failure
FailSafeMaxDurationSeconds int 3600 Fail-safe window upper bound
EagerRefreshThreshold double 0.8 Background refresh at 80 % of TTL

Section name: RigTUnit:FusionCache.

Fixture + helper APIs

  • Rig.TUnit.Caching.Fusion.Fixtures.FusionCacheFixture
  • Rig.TUnit.Caching.Fusion.Options.FusionCacheFixtureOptions
  • Rig.TUnit.Caching.Fusion.Builder.FusionCacheRigBuilder
  • Rig.TUnit.Caching.Fusion.Helpers.FailSafeHelper
  • Rig.TUnit.Caching.Fusion.Helpers.EagerRefreshHelper

Per-test isolation

Per-fixture IFusionCache instance — each test owns its own cache graph. No state is shared across tests by default; pairing with the Redis L2 backplane adds the Redis key-prefix isolation pattern.

Parallelism + performance

  • Zero container startup.
  • GetOrSetAsync warm hit: ~500 ns.
  • Stampede coalescing: ~50 µs for first-loader dogpile test.
  • Safe under full parallelism.

Troubleshooting

  • Fail-safe does not fire — check IsFailSafeEnabled = true AND FailSafeMaxDuration > 0 AND the loader threw (a null return is not a failure).
  • Eager refresh fires too often — test's synthetic clock is running real wall time; wrap with ClockControl from Rig.TUnit.Caching to freeze.

See docs/troubleshooting.md#fusion.

Provider quirks + edge cases

  • FusionCache's adaptive caching can return a stale value even when the loader succeeded — by design (for fail-safe). Tests asserting "always fresh" must disable it.
  • Eager refresh is fire-and-forget; the current caller still gets the cached value while a background refresh runs. Tests racing this boundary must poll, not assume.

Benchmarks

See FusionCacheBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Rig.TUnit.Caching.Fusion:

Package Downloads
Rig.TUnit.All

Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 48 4/27/2026
0.0.0-alpha.0.14 47 4/26/2026