CacheStore
Storage and nearest-neighbour search behind a SemanticCache.
kmemo splits responsibilities on purpose: the store owns where entries live and when they are dropped (capacity, eviction, TTL), while SemanticCache owns whether a candidate is good enough to serve (threshold, guards, verification). That split is what lets a Redis or pgvector adapter delegate expiry to the database without reimplementing any match logic.
Implementations must honour three rules:
search never returns an expired entry. Expiry is the store's business; the cache trusts it.
search returns at most
limitresults, sorted by descending similarity.Every method is safe to call concurrently from multiple coroutines.
Inheritors
Functions
Writes entry, replacing any existing entry with the same CacheEntry.id.