Skip to content

basalt / cache/src / CacheOptions

Interface: CacheOptions ​

Defined in: cache/src/index.ts:25

Extended by ​

Properties ​

now? ​

> optional now?: () => number

Defined in: cache/src/index.ts:44

Injectable clock (ms) for stale-while-revalidate windows. Default: Date.now.

Returns ​

number


onMissingScope? ​

> optional onMissingScope?: "error" | "global"

Defined in: cache/src/index.ts:42

What to do when the scope function resolves nothing (no tenant in context): 'global' (default) shares one namespace — convenient but a per-tenant value cached without a tenant leaks to others; 'error' fails closed (throws MissingCacheScopeError) on read/write. In a multi-tenant app (or with an explicit 'error'), flush() fails closed too, so a mis-scoped call can't wipe every tenant's cache.


prefix? ​

> optional prefix?: string

Defined in: cache/src/index.ts:27

Root prefix for all keys. Default: 'basalt'


scope? ​

> optional scope?: (() => string | undefined) | null

Defined in: cache/src/index.ts:33

Dynamic segment of the prefix, resolved on every operation. The default reads ctx().tenant.id — automatic per-tenant isolation. Pass null to disable (a deliberate global cache).

Released under the MIT License.