Rig.TUnit.Caching
0.1.0-beta.2
dotnet add package Rig.TUnit.Caching --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Caching -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Caching" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Caching" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Caching" />
paket add Rig.TUnit.Caching --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Caching, 0.1.0-beta.2"
#:package Rig.TUnit.Caching@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Caching&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Caching&version=0.1.0-beta.2&prerelease
Rig.TUnit.Caching
Caching family-base:
CacheRigBuilder<TSelf>+CacheAssert(Stampede, TagInvalidation, Coherent, FailSafe, NegativeCached, HitRate, EagerRefresh) +StampedeTester+BackplaneCapture+ClockControl.
What this package is
The shared contract for the Caching family. Defines ICacheRig,
CacheFixtureBase, and the novel CacheAssert fluent API with
assertions for the seven cache-quality dimensions that matter in
production: stampede prevention, tag-based invalidation coherence,
distributed-cluster coherency, fail-safe read-through, negative-caching,
hit-rate targets, and eager-refresh semantics. ClockControl wraps
FakeTimeProvider so TTL tests run instantly.
Concrete providers: .Memory, .Redis, .Hybrid, .Fusion.
When to use it
- Authoring a new cache provider (MemoryCache with custom eviction, etc).
- Writing cache-semantic tests that run against every provider.
- Not for: concrete caching — install one of the four leaves.
Prerequisites
- .NET 10 SDK
Microsoft.Extensions.TimeProvider.Testing(transitive)
Quick start
using Rig.TUnit.Caching.Helpers;
using Rig.TUnit.Core.Builder;
using Rig.TUnit.Core.Helpers;
var rig = new RigBuilder()
.WithIsolation(IsolationKey.FromExecutionContext())
.Build();
var clock = new ClockControl();
await using var _ = rig;
Options
| Property | Type | Default | Description |
|---|---|---|---|
DefaultTtl |
TimeSpan |
5m |
Starting TTL for cache entries |
EnableStatistics |
bool |
true |
Track hit/miss counts |
NegativeCacheTtl |
TimeSpan |
30s |
TTL for null / not-found entries |
StampedePreventionWindow |
TimeSpan |
500ms |
Coalesce concurrent loaders |
Fixture + helper APIs
Rig.TUnit.Caching.ICacheRigRig.TUnit.Caching.Fixtures.CacheFixtureBaseRig.TUnit.Caching.Builder.CacheRigBuilder<TSelf>Rig.TUnit.Caching.Assertions.CacheAssertRig.TUnit.Caching.Helpers.StampedeTesterRig.TUnit.Caching.Helpers.BackplaneCaptureRig.TUnit.Caching.Helpers.ClockControl
Per-test isolation
Each provider isolates differently — memory caches per-fixture, Redis
via key prefix, hybrid via L1 reset + L2 prefix. The base contract's
CacheAssert assumes isolation is guaranteed by the provider.
Parallelism + performance
§9 — N/A: family-base; per-provider. Memory is fastest; Fusion is
slowest (backplane + L1 + L2 coordination).
Troubleshooting
StampedeTesterreports > 1 loader call — the provider's stampede prevention window is narrower than the test's concurrent-call window.
Provider quirks + edge cases
- Stampede prevention semantics differ — some providers coalesce per-key,
others per-process.
CacheAssert.Stampede(…)tests per-key coalescing.
Benchmarks
§12 — N/A: family-base; concrete leaves have individual
*CacheBenchmarks.cs entries under tests/Rig.TUnit.Benchmarks/.
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.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.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.Core (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Rig.TUnit.Caching:
| 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). |
|
|
Rig.TUnit.Caching.Memory
TUnit fixture for IMemoryCache - in-process, no container required. Suitable for unit-style cache tests. |
|
|
Rig.TUnit.Caching.Fusion
TUnit fixture for ZiggyCreatures FusionCache. Layered cache, fail-safe, and adaptive caching test helpers. |
|
|
Rig.TUnit.Caching.Redis
TUnit fixture for Redis-as-cache backed by Testcontainers. Lock acquisition, tag invalidation, and TTL assertions. |
|
|
Rig.TUnit.Caching.Hybrid
TUnit fixture for ASP.NET Core HybridCache (L1+L2). Layered cache assertions and stampede-prevention checks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 45 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 51 | 4/26/2026 |