Skip to content

Interface: ProjectCacheOptions

Options for the default project-scoped memory and disk cache.

readonly optional cacheDir?: string

Override the cache directory, primarily for tests.


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

CacheOptions.cacheId


readonly optional disk?: boolean

Disable the default disk level. Defaults to true.


readonly optional diskWriteDelayMs?: number

Delay used by keyv-file to coalesce file rewrites. Defaults to 100 milliseconds.


readonly optional levels?: readonly CacheLevel[]

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

ProjectCacheOptions.levels


readonly optional maxEntries?: number

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

CacheOptions.maxEntries


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).

CacheOptions.maxTtl


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

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

CacheOptions.namespace


readonly optional projectName?: string

Override the project name resolved through projectUtils.name().


optional stats?: boolean

Whether to enable statistics for the cacheable instance

CacheOptions.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.

CacheOptions.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.

CacheOptions.ttl


readonly optional useClone?: boolean

Whether memory reads clone values. Defaults to true.

CacheOptions.useClone


readonly optional writeDelayMs?: number

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

CacheOptions.writeDelayMs