Rig.TUnit.Databases.NoSql.Redis
0.1.0-beta.2
dotnet add package Rig.TUnit.Databases.NoSql.Redis --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Databases.NoSql.Redis -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Databases.NoSql.Redis" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Databases.NoSql.Redis" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Databases.NoSql.Redis" />
paket add Rig.TUnit.Databases.NoSql.Redis --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Databases.NoSql.Redis, 0.1.0-beta.2"
#:package Rig.TUnit.Databases.NoSql.Redis@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Databases.NoSql.Redis&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Databases.NoSql.Redis&version=0.1.0-beta.2&prerelease
Rig.TUnit.Databases.NoSql.Redis
Redis-as-KV-store fixture, sibling to
Rig.TUnit.Caching.Redis. Same container, different semantic contract.
What this package is
Redis wears two hats in real systems: a best-effort cache (with eviction,
TTLs, dogpile prevention) and a durable key-value store (primary of
record for session tokens, counters, distributed locks). The Rig.TUnit
split keeps those roles in separate packages so consumers declare
intent — UseRedisCache(…) vs UseRedisKv(…). Shares the underlying
RedisFixture with Rig.TUnit.Caching.Redis to avoid a duplicate
container per test process.
Ships KeyScanHelper — a SCAN-based enumeration wrapper with sensible
batch size + match-pattern support, because KEYS * is forbidden in
anything touching production-shape data.
When to use it
- Integration tests where Redis is the primary store (session state, idempotency keys, leaderboards).
- Tests that need to enumerate keys safely during assertions.
- Not for: caching scenarios — use
Rig.TUnit.Caching.Redis.
Prerequisites
- .NET 10 SDK
- Docker Desktop / Colima (Redis image ~120 MB)
StackExchange.Redis(transitive)
Quick start
using Rig.TUnit.Caching.Redis.Fixtures;
using Rig.TUnit.Databases.NoSql.Redis.Helpers;
using StackExchange.Redis;
await using var fx = new RedisFixture();
await fx.InitializeAsync();
var db = ConnectionMultiplexer.Connect(fx.ConnectionString).GetDatabase();
await db.StringSetAsync("session:abc", "user-42");
Options
| Property | Type | Default | Description |
|---|---|---|---|
Image |
string |
"redis:7-alpine" |
Image |
StartupTimeoutSeconds |
int |
30 |
Redis boots in ~1 s |
Password |
string? |
null |
Off in dev mode |
AppendOnly |
bool |
false |
AOF persistence; disabled for test speed |
Fixture + helper APIs
Rig.TUnit.Databases.NoSql.Redis.Builder.RedisKvRigBuilderRig.TUnit.Databases.NoSql.Redis.Helpers.KeyScanHelper- Shared:
Rig.TUnit.Caching.Redis.Fixtures.RedisFixture
Per-test isolation
Per-test key prefix: session:{IsolationKey:short}:*. KeyScanHelper
teardown issues SCAN + DEL against the prefix. Cheaper than running a
container per test.
Parallelism + performance
- First-run pull: ~5 s.
- Warm startup: ~1 s.
- Per-test prefix scrub: ~5–10 ms per 100 keys.
- Parallelism: 8+ concurrent tests; key-prefix isolation is effectively free.
Troubleshooting
- Cross-test data bleed — a test forgot the
{IsolationKey}prefix. TheKeyScanHelperonly scrubs inside the prefix; keys outside linger. ERR SCAN iteration terminated by timeout— increasecountbatch size (default 100) or reduce the number of keys per test.
See docs/troubleshooting.md#redis.
Provider quirks + edge cases
- Redis is single-threaded per shard;
MULTI/EXECis atomic but a slow script blocks everyone else. Avoid Lua scripts in tests unless testing them. - Keyspace notifications (
CONFIG SET notify-keyspace-events "KEA") are off by default; enable explicitly if testing pub/sub on key expiry.
Benchmarks
See RedisKvBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
- ADR-007 — Redis cache/KV split
- Architecture diagram
- Glossary
- Family base:
Rig.TUnit.Databases.NoSql - Sibling:
Rig.TUnit.Caching.Redis
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.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.Redis (>= 0.1.0-beta.2)
- Rig.TUnit.Databases.NoSql (>= 0.1.0-beta.2)
- StackExchange.Redis (>= 2.8.22)
- Testcontainers (>= 4.11.0)
- Testcontainers.Redis (>= 4.11.0)
- TUnit.Core (>= 1.34.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Databases.NoSql.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). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 43 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 44 | 4/26/2026 |