Interface ICacheStore
Abstraction over the cache backend. The default implementation is in-process (CL.MySQL2.Services.InProcessCacheStore). Distributed adapters (Redis, memcached) can implement this without touching callers.
public interface ICacheStore
Properties
Count
Total entries currently in the cache (best-effort).
int Count { get; }
Property Value
Methods
Clear()
Wipes everything (tests, admin operations).
void Clear()
CountByTable()
Diagnostic snapshot — entry count grouped by tableName. Used by the admin UI to surface "what's actually in the cache" without dumping values. Default implementation returns an empty dict for adapters that can't enumerate.
IReadOnlyDictionary<string, int> CountByTable()
Returns
EvictAsync(string, CancellationToken)
Evicts a single key.
Task EvictAsync(string key, CancellationToken ct = default)
Parameters
keystringctCancellationToken
Returns
EvictByTableAsync(string, CancellationToken)
Evicts every entry whose tableName matches. Used by Invalidate(string) so orphan entries (e.g. older table-version snapshots) don't accumulate after a mutation. Default implementation is a no-op for adapters that can't enumerate; the in-process store overrides this with an O(n) scan that's still cheap relative to the savings.
Task<int> EvictByTableAsync(string tableName, CancellationToken ct = default)
Parameters
tableNamestringctCancellationToken
Returns
SetAsync(string, object, TimeSpan, string, CancellationToken)
Stores a value with a TTL.
Task SetAsync(string key, object value, TimeSpan ttl, string tableName, CancellationToken ct = default)
Parameters
keystringvalueobjectttlTimeSpantableNamestringctCancellationToken
Returns
TryGetAsync(string, CancellationToken)
Attempts to read a cached value. Returns false if missing or expired.
Task<(bool Found, object? Value)> TryGetAsync(string key, CancellationToken ct = default)
Parameters
keystringctCancellationToken