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

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

Rig.TUnit.Caching.Memory

IMemoryCache-backed CacheFixtureBase — 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 CacheRigContract in its fastest mode.
  • Not for: distributed coherency testing (nothing to coordinate); use Rig.TUnit.Caching.Fusion with 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.MemoryCacheFixture
  • Rig.TUnit.Caching.Memory.Options.MemoryCacheFixtureOptions
  • Rig.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/ACacheAssert.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 seenSizeLimit must be combined with per-entry Size; entries without a Size are never size-evicted.

See docs/troubleshooting.md#memory-cache.

Provider quirks + edge cases

  • IMemoryCache.Remove(object) takes object, not string — typed wrappers are your friend.
  • AbsoluteExpirationRelativeToNow on Set measures 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.

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