Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.7 KB

File metadata and controls

41 lines (29 loc) · 1.7 KB

SquidStd.Caching.Abstractions

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.

Install

dotnet add package SquidStd.Caching.Abstractions

Usage

using 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));

Key types

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.

Related

License

MIT - part of SquidStd.