Skip to main content
@brushy/storage uses node-cache-compatible TTL semantics. All internal expiry is tracked in milliseconds; public APIs accept seconds or human-readable strings.

Default TTL (stdTTL)

Set at construction time. Applied when set(key, value) omits a per-key TTL.
For stdTTL, bare numeric strings like "60000" are treated as milliseconds (60 seconds). For set() and ttl(), bare "60" means 60 seconds.

Per-key TTL on set

Duration units

Special values

ttl(key, ttl?)

Updates expiry of an existing key without changing the value. Returns false if the key is missing.
When persist is enabled, the updated TTL is written through to storage.

getTtl(key)

Returns the absolute expiry timestamp (Date.now() + remaining ms), 0 for non-expiring keys, or undefined if missing.

Background expiry (checkperiod)

A timer scans in-memory entries every checkperiod seconds (default 600). On Node.js the timer is unref()’d so it does not keep the process alive. Set checkperiod: 0 to disable scans. Keys still expire lazily on get / has.

Utility exports

Low-level helpers for custom adapters: