Skip to content

CacheOptions

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:53

Options for configuring write-through and eviction caching via Cache.

TEntity = unknown

optional barrierTtl?: number

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:93

Lifetime in milliseconds of the CacheMutationBarrier written on deletions and secondary invalidations.

A barrier only has to outlive the in-flight reads/writes it guards against, so configure this above the expected maximum repository operation latency. Ignored by IVersionedCache adapters, which fence concurrent fills by revision instead of by barrier.

DEFAULT_BARRIER_TTL_MS


optional deleteKeys?: ((entity) => string[]) | null

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:63

Function deriving keys to evict when save() returns null or undefined (e.g. deletion).


optional invalidateKeys?: ((entity) => string[]) | null

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:68

Optional secondary keys to evict on every successful save before writing the new entry.


optional isNewer?: ((cached, incoming) => boolean) | null

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:80

Optional version comparison function for CAS-safe write-through caching. If omitted, defaults to isCacheNewer which compares version, __gen, or updatedAt. Pass null to skip the isNewer comparison.


optional logger?: ICacheLogger

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:99

Receives cache-maintenance warnings. Defaults to console.warn with a [CacheDecorator] prefix. See ICacheLogger.


optional setKey?: ((entity) => string) | null

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:58

Function deriving the cache key to write on success. Pass null or omit to skip write-through caching.


optional ttl?: number

Defined in: packages/ddd-core/persistence/decorators/cache.decorator.ts:73

Optional time-to-live in milliseconds for the write-through cache entry.