The delegate store to cache
Cache configuration options
Optional Readonlysize?: numberMaximum number of records to cache.
When the cache exceeds this bound, the least-recently-used record is evicted after each miss.
Optional Readonlyttl?: numberMaximum record age in milliseconds.
Records older than this value are treated as misses on the next retrieval and evicted when a sibling miss triggers the TTL sweep. Expiration is checked on every hit, so a stale record is never returned even if the sweep hasn't run yet.
Optional Readonlymatch?: (entry: string, cache: string) => booleanPredicate deciding which cached records an invalidation event discards.
Invoked for writes made through the wrapper and for mutation events signalled by the delegate. It receives the
identifier of the mutated resource and the identifier of each cached record, and returns true if the record
is to be evicted.
An immutable store with caching behaviour
Creates a caching store backed by a delegate.
Serves repeated retrievals from an in-memory cache, sparing the delegate a round-trip whenever a prior result can be reused. This cuts latency and backend load for read-heavy workloads, while writes and eviction keep cached results coherent and bounded.
Results are cached by
entry,model, and thelocaleandlimitof the lookup retrieval scope. Templates differing only in member or element order share a cached result.shapeis not part of the cache key. A retrieval result MUST depend only onentry,model,localeandlimit, withshapesupplying structural metadata that does not affect the returned payload.The scope
localeis part of the cache key, because it selects which localised content a retrieval returns. Unlike the model, the locale priority list is order-significant:["en", "it"]and["it", "en"]are cached separately. An omitted and an empty locale list share a single cached result, distinct from any explicit list.The scope
limitis part of the cache key, because it caps the page size of each collection and so changes the returned payload. An omitted and a0limit share a single cached result. The scopeplainanddepthare not part of the key: they only accept or reject a model, and never alter a successful payload.The cache offers three observable guarantees:
The configurable
matchpredicate selects which cached entries a write invalidates.Transaction Isolation — Inherited from the wrapped Store.
Mutation Events — Inherited from the wrapped Store.