CacheOptions
Defined in: src/cache.ts:93
Type Parameters
Section titled “Type Parameters”T
Properties
Section titled “Properties”coalesce?
Section titled “coalesce?”
optionalcoalesce?:boolean
Defined in: src/cache.ts:108
Concurrent misses for the same key share one call (single-flight). Default true.
optionalkey?: (context) =>string|undefined
Defined in: src/cache.ts:96
Cache key for the execution; undefined bypasses the cache. Default: context.operationKey.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”string | undefined
optionalname?:string
Defined in: src/cache.ts:94
onCacheHit?
Section titled “onCacheHit?”
optionalonCacheHit?: (args) =>MaybePromise<void>
Defined in: src/cache.ts:109
Parameters
Section titled “Parameters”Returns
Section titled “Returns”MaybePromise<void>
onCacheMiss?
Section titled “onCacheMiss?”
optionalonCacheMiss?: (args) =>MaybePromise<void>
Defined in: src/cache.ts:110
Parameters
Section titled “Parameters”Returns
Section titled “Returns”MaybePromise<void>
onStaleServed?
Section titled “onStaleServed?”
optionalonStaleServed?: (args) =>MaybePromise<void>
Defined in: src/cache.ts:111
Parameters
Section titled “Parameters”Returns
Section titled “Returns”MaybePromise<void>
shouldCache?
Section titled “shouldCache?”
optionalshouldCache?: (args) =>MaybePromise<boolean>
Defined in: src/cache.ts:102
Default: successful results only. Failures are never cached.
Parameters
Section titled “Parameters”OutcomeArgs<T>
Returns
Section titled “Returns”MaybePromise<boolean>
shouldServeStale?
Section titled “shouldServeStale?”
optionalshouldServeStale?:ShouldHandle<OutcomeArgs<T>>
Defined in: src/cache.ts:106
Failures a stale value may hide. Default: every failure except aborts and client errors (4xx except 408/429).
staleTtl?
Section titled “staleTtl?”
optionalstaleTtl?:Duration
Defined in: src/cache.ts:104
Stale-if-error window after ttl: when the call fails, a value younger than ttl + staleTtl is returned instead. Default 0.
store?
Section titled “store?”
optionalstore?:CacheStore
Defined in: src/cache.ts:100
Default: a new MemoryCacheStore per strategy. Share one to share the cache between pipelines.
ttl:
Duration
Defined in: src/cache.ts:98
How long a value is served without calling. 0 with coalesce gives request deduplication without caching.