Skip to main content
Version: Next (2.x)

CacheOptions<Item>

CacheOptions<Item> = object

Configuration options for cache stores

Type Parameters

Type Parameter

Item

Properties

PropertyTypeDefault valueDescription

name

string

undefined

Unique name for the cache store. Used as a prefix for cache keys to avoid collisions.

parse

(value) => Item

undefined

Function to parse stored strings back into source objects. If it throws an error, the cache will be treated as a miss and the value will be deleted.

serialize

(value) => string

undefined

Function to serialize source objects into strings for cache storage.

namespace?

string

CacheClient options or "baeta"

Optional namespace to prefix all cache keys

onDelete?

(ref) => void | Promise<void>

undefined

Hook that gets called with the refs of deleted items after a delete operation.

onInsert?

(item) => void | Promise<void>

undefined

Hook that gets called with the inserted items after an insert operation.

onUpdate?

(item) => void | Promise<void>

undefined

Hook that gets called with the updated items after an update operation.

revision?

number

CacheClient options or "default"

Revision number for cache invalidation. Incrementing this number will invalidate all existing cache entries for this store.

ttlMs?

number

CacheClient options or 3_600_000 (1 hour)

Time-to-live in milliseconds