CollectionOptions
Defined in: packages/collection/src/index.ts:2
Retention policy for a Collection.
Type Parameters
Section titled “Type Parameters”K = unknown
V = unknown
Properties
Section titled “Properties”jitter?
Section titled “jitter?”
optionaljitter?: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.
maxSize?
Section titled “maxSize?”
optionalmaxSize?: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.
onEvict?
Section titled “onEvict?”
optionalonEvict?: (key,value,reason) =>void
Defined in: packages/collection/src/index.ts:12
Called after an entry is removed automatically, with why. Exceptions are swallowed.
Parameters
Section titled “Parameters”K
V
reason
Section titled “reason”Returns
Section titled “Returns”void
slide?
Section titled “slide?”
optionalslide?: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.
optionalttl?:number
Defined in: packages/collection/src/index.ts:4
Default sliding TTL in ms for set(). Omit for no expiry.