Skip to content

CollectionOptions

Defined in: packages/collection/src/index.ts:2

Retention policy for a Collection.

K = unknown

V = unknown

optional jitter?: number

Defined in: packages/collection/src/index.ts:6

Fraction (0-1) of each entry’s TTL randomly shaved off when it is set, so entries stored together do not expire together. Default 0.


optional maxSize?: number

Defined in: packages/collection/src/index.ts:8

Maximum entries stored with set(); least-recently-used are evicted past it. setWithoutTTL() entries are never counted or evicted.


optional onEvict?: (key, value, reason) => void

Defined in: packages/collection/src/index.ts:12

Called after an entry is removed automatically, with why. Exceptions are swallowed.

K

V

EvictionReason

void


optional slide?: boolean

Defined in: packages/collection/src/index.ts:10

Whether a read restarts a TTL entry’s window. Default true; with false an entry lapses a fixed time after it was set, and reads only mark it recently used.


optional ttl?: number

Defined in: packages/collection/src/index.ts:4

Default sliding TTL in ms for set(). Omit for no expiry.