Table of Contents

Interface ICacheStore

Namespace
CL.MySQL2.Services
Assembly
CL.MySQL2.dll

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

int

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

IReadOnlyDictionary<string, int>

EvictAsync(string, CancellationToken)

Evicts a single key.

Task EvictAsync(string key, CancellationToken ct = default)

Parameters

key string
ct CancellationToken

Returns

Task

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

tableName string
ct CancellationToken

Returns

Task<int>

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

key string
value object
ttl TimeSpan
tableName string
ct CancellationToken

Returns

Task

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

key string
ct CancellationToken

Returns

Task<(bool Found, object Value)>