HostLoom.Caching.Testing
0.6.0
See the version list below for details.
dotnet add package HostLoom.Caching.Testing --version 0.6.0
NuGet\Install-Package HostLoom.Caching.Testing -Version 0.6.0
<PackageReference Include="HostLoom.Caching.Testing" Version="0.6.0" />
<PackageVersion Include="HostLoom.Caching.Testing" Version="0.6.0" />
<PackageReference Include="HostLoom.Caching.Testing" />
paket add HostLoom.Caching.Testing --version 0.6.0
#r "nuget: HostLoom.Caching.Testing, 0.6.0"
#:package HostLoom.Caching.Testing@0.6.0
#addin nuget:?package=HostLoom.Caching.Testing&version=0.6.0
#tool nuget:?package=HostLoom.Caching.Testing&version=0.6.0
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 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.
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 | 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
- HostLoom.Caching (>= 0.6.0)
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 | 32 | 10/27/2026 |
| 0.17.0 | 91 | 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 |