HostLoom.Caching.Testing 0.18.0

dotnet add package HostLoom.Caching.Testing --version 0.18.0
                    
NuGet\Install-Package HostLoom.Caching.Testing -Version 0.18.0
                    
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="HostLoom.Caching.Testing" Version="0.18.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HostLoom.Caching.Testing" Version="0.18.0" />
                    
Directory.Packages.props
<PackageReference Include="HostLoom.Caching.Testing" />
                    
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 HostLoom.Caching.Testing --version 0.18.0
                    
#r "nuget: HostLoom.Caching.Testing, 0.18.0"
                    
#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 HostLoom.Caching.Testing@0.18.0
                    
#: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=HostLoom.Caching.Testing&version=0.18.0
                    
Install as a Cake Addin
#tool nuget:?package=HostLoom.Caching.Testing&version=0.18.0
                    
Install as a Cake Tool

HostLoom.Caching.Testing

Composes a HostLoom.Caching cache for a test without a container, and decorates a store so a test can inject failures or assert what the cache asked for.

var clock = new FakeTimeProvider();
var store = new InMemoryDistributedCacheStore(clock);
var serializer = new SystemTextJsonCacheValueSerializer(jsonOptions);

await using var cache = TestCache.Tiered(store, serializer, timeProvider: clock);

TestCache.InMemory() composes the in-process tier alone; TestCache.Tiered(store, serializer) composes both tiers. Two tiered caches over one InMemoryDistributedCacheStore behave like two service instances sharing a backend: they share payloads and invalidate each other. The kernel's constructors are public, so this adds nothing a test could not write itself; it removes the boilerplate and keeps every test on one composition, with jitter and the stampede pause off.

FaultingCacheStore passes invalidations through to the channel it was given, or to the inner store's own; over a store with neither, such as RedisCacheStore whose channel is a separate class, it fans out nothing and the probe reports "no channel: TTL-only", so a simulated outage does not also need a live channel that would evict the copies the outage is meant to serve. FaultingCacheStore wraps any store and fails the next n calls, or every call, with a chosen CacheFailureKind, which is how a test proves a consumer behaves when the distributed tier is down: the cache serves from the in-process tier and the factory, and nothing throws. RecordingCacheStore wraps any store and records every call, so a test asserts that a stampede took one lease, a bulk lookup made one batched read, or a null factory result wrote nothing. It forwards the inner store's channel, or the one it is given, and over a store with neither it fans out nothing, as FaultingCacheStore does.

Substituting ICache is the other option and a worse one. A substitute returns what the test told it to, so the test passes whether or not the consumer would have been served by a real cache. This package keeps the real composition and moves the fault to where it belongs, the store.

Time is a TimeProvider everywhere, so a test drives expiry and leases with a fake clock instead of waiting. This package ships no clock; Microsoft.Extensions.TimeProvider.Testing provides FakeTimeProvider, and any TimeProvider works.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.18.0 0 10/27/2026
0.17.0 88 10/25/2026
0.16.1 86 10/22/2026
0.16.0 84 10/14/2026
0.15.1 84 10/12/2026
0.15.0 100 10/4/2026
0.14.0 95 10/4/2026
0.13.0 95 9/28/2026
0.12.0 98 9/27/2026
0.11.0 99 9/25/2026
0.10.0 99 9/22/2026
0.9.0 98 9/22/2026
0.8.0 99 9/19/2026
0.7.0 115 9/17/2026
0.6.0 122 9/6/2026
0.5.0 115 9/5/2026
0.4.0 115 9/3/2026