Skip to content

Interface: CacheOptions

Options for an AppKit-independent memory-first cache.

  • Pick<CacheableOptions, "cacheId" | "maxTtl" | "namespace" | "stats" | "tags" | "ttl">

optional cacheId?: string

The cacheId for the cacheable instance. This is primarily used for the wrap function to not have conflicts. If it is not set then it will be a random string that is generated

Pick.cacheId


readonly optional levels?: readonly CacheLevel[]

Additional ordered persistence levels. No levels creates a memory-only cache.


readonly optional maxEntries?: number

Maximum entries retained in the memory primary. Defaults to 1,000.


optional maxTtl?: string | number

The maximum time-to-live for the cacheable instance. When set, any TTL that exceeds this value is capped to maxTtl. Entries with no TTL will also be capped to maxTtl. Can be a number in milliseconds or a human-readable format such as 1s, 1m, 1h, 1d. Default is undefined (no maximum).

Pick.maxTtl


optional namespace?: string | (() => string)

The namespace for the cacheable instance. It can be a string or a function that returns a string.

Pick.namespace


optional stats?: boolean

Whether to enable statistics for the cacheable instance

Pick.stats


optional tags?: boolean

Enables the tag service so tag-based invalidation can be used and freshness checks run on every get / getMany. Tags must be explicitly enabled — while disabled, all tag operations are no-ops and values set with tags are stored without tag tracking. Enable this on every instance that shares the store (writers and readers) so invalidations are honored consistently across distributed instances. Default is false.

Pick.tags


optional ttl?: string | number

The time-to-live for the cacheable instance and will be used as the default value. can be a number in milliseconds or a human-readable format such as 1s for 1 second or 1h for 1 hour or undefined if there is no time-to-live.

Pick.ttl


readonly optional useClone?: boolean

Whether memory reads clone values. Defaults to true.


readonly optional writeDelayMs?: number

Delay used to coalesce persistence mutations. Defaults to 25 milliseconds.