Rig.TUnit.Caching.Fusion
0.1.0-beta.2
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
<PackageReference Include="Rig.TUnit.Caching.Fusion" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Caching.Fusion" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Caching.Fusion" />
paket add Rig.TUnit.Caching.Fusion --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Caching.Fusion, 0.1.0-beta.2"
#:package Rig.TUnit.Caching.Fusion@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Caching.Fusion&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Caching.Fusion&version=0.1.0-beta.2&prerelease
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— useRig.TUnit.Caching.Memory.
Prerequisites
- .NET 10 SDK
ZiggyCreatures.FusionCache2.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.FusionCacheFixtureRig.TUnit.Caching.Fusion.Options.FusionCacheFixtureOptionsRig.TUnit.Caching.Fusion.Builder.FusionCacheRigBuilderRig.TUnit.Caching.Fusion.Helpers.FailSafeHelperRig.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.
GetOrSetAsyncwarm hit: ~500 ns.- Stampede coalescing: ~50 µs for first-loader dogpile test.
- Safe under full parallelism.
Troubleshooting
- Fail-safe does not fire — check
IsFailSafeEnabled = trueANDFailSafeMaxDuration > 0AND the loader threw (anullreturn is not a failure). - Eager refresh fires too often — test's synthetic clock is running
real wall time; wrap with
ClockControlfromRig.TUnit.Cachingto 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.
Related docs
License
MIT. See LICENSE.
| Product | Versions 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. |
-
net10.0
- Bogus (>= 35.6.1)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Microsoft.Extensions.TimeProvider.Testing (>= 10.0.0)
- Rig.TUnit.Caching (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
- ZiggyCreatures.FusionCache (>= 2.0.0)
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 |