Backend-agnostic caching contracts for SquidStd. It defines the typed cache-aside facade
(ICacheService), the low-level byte provider/metrics contracts, and the shared CacheService
facade that applies key-prefixing, default TTL and cache-aside once over any provider. Pick a
backend implementation (in-memory or Redis) from a companion package.
dotnet add package SquidStd.Caching.Abstractionsusing SquidStd.Caching.Abstractions.Interfaces;
// Resolve ICacheService from a backend package (in-memory or Redis).
public Task<int> GetOrComputeAsync(ICacheService cache)
=> cache.GetOrSetAsync("answer", _ => Task.FromResult(42), TimeSpan.FromMinutes(5));| Type | Purpose |
|---|---|
ICacheService |
Typed cache-aside facade. |
ICacheProvider |
Byte-level backend contract (per provider). |
CacheService |
Shared facade: serialization, key prefix, default TTL, cache-aside. |
ICacheMetrics |
Hit/miss/set/remove metrics sink. |
CacheOptions |
Default TTL and key prefix. |
CacheConnectionString |
scheme://host[?params] parsing into CacheOptions. |
- Tutorial: Caching
MIT - part of SquidStd.