Rig.TUnit.Caching.Memory
0.1.0-beta.2
dotnet add package Rig.TUnit.Caching.Memory --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Caching.Memory -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Caching.Memory" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Caching.Memory" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Caching.Memory" />
paket add Rig.TUnit.Caching.Memory --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Caching.Memory, 0.1.0-beta.2"
#:package Rig.TUnit.Caching.Memory@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Caching.Memory&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Caching.Memory&version=0.1.0-beta.2&prerelease
Rig.TUnit.Caching.Memory
IMemoryCache-backedCacheFixtureBase— single-node in-memory cache. Zero-container speed-of-light tier.
What this package is
The simplest cache provider: a standard Microsoft.Extensions.Caching. Memory.IMemoryCache wrapped in a Rig.TUnit fixture. No container, no
distributed coordination, no backplane — just a dictionary with TTL +
size-limit eviction and the CacheRigContract subset that applies to
single-node caches.
When to use it
- Tests that need a trivially-fast cache for sanity-check assertions.
- In-process caching scenarios where L2 distribution is deliberately absent.
- Running the
CacheRigContractin its fastest mode. - Not for: distributed coherency testing (nothing to coordinate); use
Rig.TUnit.Caching.Fusionwith an L2 Redis backplane.
Prerequisites
- .NET 10 SDK
Microsoft.Extensions.Caching.Memory(transitive)
Quick start
using Rig.TUnit.Caching.Memory.Fixtures;
await using var fx = new MemoryCacheFixture();
await fx.InitializeAsync();
fx.Cache.Set("k", "v", TimeSpan.FromSeconds(30));
Options
| Property | Type | Default | Description |
|---|---|---|---|
SizeLimit |
long? |
null |
IMemoryCache.SizeLimit |
CompactionPercentage |
double |
0.25 |
% evicted on size-pressure |
DefaultTtl |
TimeSpan |
5m |
Applied when entry has no explicit TTL |
Fixture + helper APIs
Rig.TUnit.Caching.Memory.Fixtures.MemoryCacheFixtureRig.TUnit.Caching.Memory.Options.MemoryCacheFixtureOptionsRig.TUnit.Caching.Memory.Builder.MemoryCacheRigBuilder
Per-test isolation
Per-fixture IMemoryCache instance. Each test owns its own cache;
nothing is shared. Safe under full parallelism without any extra work.
Parallelism + performance
- Zero container startup.
Set/Get: ~200 ns.- Safe under full parallelism.
Troubleshooting
- Coherency assertions N/A —
CacheAssert.Coherent(…)is a no-op against a single-node cache. The contract suite's skipped entries are documented; do not treat the skip as a regression. - Size-limit evictions not seen —
SizeLimitmust be combined with per-entrySize; entries without a Size are never size-evicted.
See docs/troubleshooting.md#memory-cache.
Provider quirks + edge cases
IMemoryCache.Remove(object)takesobject, notstring— typed wrappers are your friend.AbsoluteExpirationRelativeToNowonSetmeasures from enqueue time, not eviction-check time. A 5 s expiry set at T=0 evicts at T=5.
Benchmarks
See MemoryCacheBenchmarks.cs;
baseline in benchmarks/baseline-005.json. Speed-of-light reference.
Related docs
- Architecture diagram
- Glossary
- Family base:
Rig.TUnit.Caching
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)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Caching.Memory:
| 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 | 47 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 44 | 4/26/2026 |