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

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

Rig.TUnit.Caching.Redis

Redis-as-cache fixture (primary home for RedisFixture) with RedisBackplaneCapture for pub/sub cache-invalidation tests.

What this package is

The Rig.TUnit Redis-as-cache provider. Primary home for RedisFixture — the same container is re-used by Rig.TUnit.Databases.NoSql.Redis in its KV role. Exposes UseRedisCache(…) (no bare UseRedis — ADR-007 forces the caller to declare intent cache vs KV). Ships RedisBackplaneCapture which subscribes to a pub/sub channel and records cache-invalidation events, so tests can assert "publishing orders:cache-invalidate evicts the L1 on every node".

When to use it

  • Testing distributed-cache coherency with pub/sub-based invalidation.
  • L2 backing for FusionCache / HybridCache distributed-tier tests.
  • Asserting cache hit-rate targets against real Redis.
  • Not for: KV-store scenarios — use Rig.TUnit.Databases.NoSql.Redis.

Prerequisites

  • .NET 10 SDK
  • Docker Desktop / Colima (Redis image ~120 MB)
  • StackExchange.Redis (transitive)

Quick start

using Rig.TUnit.Caching.Redis.Fixtures;
using StackExchange.Redis;

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

var db = ConnectionMultiplexer.Connect(fx.ConnectionString).GetDatabase();
await db.StringSetAsync("cache:orders:42", "{}", TimeSpan.FromMinutes(5));

Options

Property Type Default Description
Image string "redis:7-alpine" Image
StartupTimeoutSeconds int 30 Redis boots fast
Password string? null Off in dev mode
BackplaneChannel string "cache-invalidate" Pub/sub channel

Fixture + helper APIs

  • Rig.TUnit.Caching.Redis.Fixtures.RedisFixture
  • Rig.TUnit.Caching.Redis.Options.RedisCacheFixtureOptions
  • Rig.TUnit.Caching.Redis.Builder.RedisCacheRigBuilder
  • Rig.TUnit.Caching.Redis.Helpers.RedisBackplaneCapture

Per-test isolation

Per-test key prefix cache:{IsolationKey:short}:*. Teardown via SCAN + DEL on the prefix. Pub/sub channels are per-fixture to avoid cross-test subscriber leakage.

Parallelism + performance

  • First-run pull: ~5 s.
  • Warm startup: ~1 s.
  • Per-op Get/Set: ~150 µs (in-process latency dominated).
  • Parallelism: 8+ concurrent tests — key-prefix isolation makes this trivially safe.

Troubleshooting

  • TimeoutException on first opConnectionMultiplexer.Connect is synchronous and blocks until the initial topology discovery completes; under heavy parallel startup this can exceed the default 5-second timeout. Raise SyncTimeout in your config.
  • Backplane capture missed eventsISubscriber.Subscribe is eventually-consistent; poll for the subscription to be active before publishing (fixture does this but a custom wire-up must too).

See docs/troubleshooting.md#redis-cache.

Provider quirks + edge cases

  • Redis pub/sub is fire-and-forget — a subscriber started after a publish misses the message. Always subscribe before triggering the event the test expects.
  • KEYS * is the classic production foot-gun; the fixture-internal teardown uses SCAN (O(1) per batch) instead.
  • Cache-vs-KV split rationale: ADR-007. Bare UseRedis does not exist; this is deliberate.

Benchmarks

See RedisCacheBenchmarks.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 (2)

Showing the top 2 NuGet packages that depend on Rig.TUnit.Caching.Redis:

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.Databases.NoSql.Redis

TUnit fixture for Redis-as-database backed by Testcontainers. Use for Redis-as-database scenarios; for caching see Rig.TUnit.Caching.Redis.

GitHub repositories

This package is not used by any popular GitHub repositories.

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