WrapOpts

tagtree · /core·interface

Per-call options for CacheInstance.wrap, extending basic storage controls with a staleness guard that prevents a late-arriving write from overwriting an invalidation that fired while the fetcher was in flight.

Properties

stalenessGuard?
boolean
When ``true``, records the fetch start time and passes it as ``WriteOpts.writeIfNewerThan`` so any tag invalidation that arrived while the fetcher ran causes the write to be discarded.
swr?
boolean
When ``true``, the adapter may serve a stale entry while revalidating.
ttl?
number
Entry lifetime in seconds; omit for indefinite storage.

Example

const data = await cache.wrap(key, fetcher, { ttl: 60, stalenessGuard: true });

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourcecache.ts:17Edit the JSDoc directly

On this page