Rig.TUnit.Caching 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Caching.
dotnet add package Rig.TUnit.Caching --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Caching -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" 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" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Caching" />
                    
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 --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Caching, 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@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&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Caching&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

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.ICacheRig
  • Rig.TUnit.Caching.Fixtures.CacheFixtureBase
  • Rig.TUnit.Caching.Builder.CacheRigBuilder<TSelf>
  • Rig.TUnit.Caching.Assertions.CacheAssert
  • Rig.TUnit.Caching.Helpers.StampedeTester
  • Rig.TUnit.Caching.Helpers.BackplaneCapture
  • Rig.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

  • StampedeTester reports > 1 loader call — the provider's stampede prevention window is narrower than the test's concurrent-call window.

See docs/troubleshooting.md.

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

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 (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