FromCacheOptions
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:44
Options for configuring read-through caching and rehydration via FromCache.
Type Parameters
Section titled “Type Parameters”TQuery
Section titled “TQuery”TQuery = unknown
TResult
Section titled “TResult”TResult = unknown
Properties
Section titled “Properties”alwaysHydrate?
Section titled “alwaysHydrate?”
optionalalwaysHydrate?:boolean
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:71
Requires hydrateFn at decoration time. Every hit is rehydrated whenever a
hydrator applies, so this flag does not change the result.
hydrateFn?
Section titled “hydrateFn?”
optionalhydrateFn?: ((cached) =>TResult) |null
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:56
Function to rehydrate a raw cached snapshot back into a domain entity.
When omitted, the repository’s QueryRepositoryHydration applies;
null opts this method out of it.
isNewer?
Section titled “isNewer?”
optionalisNewer?: (cached,incoming) =>boolean
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:82
Optional version comparator for stale-read prevention during concurrent cache population. Defaults to isCacheNewer.
Parameters
Section titled “Parameters”cached
Section titled “cached”unknown
incoming
Section titled “incoming”unknown
Returns
Section titled “Returns”boolean
keyFn?
Section titled “keyFn?”
optionalkeyFn?: ((query) =>string|null) |null
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:49
Function deriving the cache key from query options.
When it returns null, caching is skipped for that call.
logger?
Section titled “logger?”
optionallogger?:ICacheLogger
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:89
Receives read-through warnings (unversioned adapter, uncacheable result, missing
cache property). Defaults to console.warn with a [FromCacheDecorator]
prefix. See ICacheLogger.
serializeFn?
Section titled “serializeFn?”
optionalserializeFn?: ((result) =>unknown) |null
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:65
Optional serializer function to convert a domain entity or complex result into
a pure, detached snapshot for storage in cache.
If omitted, the repository’s QueryRepositoryHydration serializer
applies, and otherwise toCacheSnapshot extracts a snapshot via
result.toJSON() or deep JSON cloning. null skips the repository default.
optionalttl?:number
Defined in: packages/ddd-core/persistence/decorators/from-cache.decorator.ts:76
Optional time-to-live in milliseconds for cached entries.