InMemoryStore

constructor(maxEntries: Int = DEFAULT_MAX_ENTRIES, ttl: Duration? = null, clock: Clock = Clock.systemUTC(), maxBytes: Long? = null, listener: CacheListener? = null)

Parameters

maxEntries

hard cap across all scopes; the least recently used entry goes first.

ttl

how long an entry stays valid, or null to keep entries until they are evicted. Expired entries are never returned by search and are dropped as they are encountered.

clock

time source; substitute a fixed clock in tests instead of sleeping.

maxBytes

optional cap on estimated resident bytes (embeddings dominate: dimensions * 4 each), evicted least-recently-used just like maxEntries, so a cache in a memory-constrained service cannot grow without bound. null (the default) bounds by count only.

listener

optional sink notified with a CacheEvent.Eviction whenever an entry is evicted (for capacity or memory) or dropped for being expired — the store owns eviction, so the store is what reports it. Called inline while the store's lock is held, so it must be fast and non-blocking (see CacheListener); pass the same listener you give dev.kmemo.SemanticCache to see the whole event stream in one place. null (the default) emits nothing.