Defined in: packages/cache/src/cache.ts:309
CacheOptions, plus the eviction policy a customCache follows.
Extends
Section titled “Extends”CacheOptions<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Properties
Section titled “Properties”capacity
Section titled “capacity”
readonlycapacity:number
Defined in: packages/cache/src/cache.ts:56
The bound the cache keeps itself within. Without weigh, it counts entries and must be a positive safe integer. With weigh, it bounds the exact sum of the supplied binary floating-point weights and may be any positive finite number. There is no rounding tolerance at the bound.
Inherited from
Section titled “Inherited from”weigh?
Section titled “weigh?”
readonlyoptionalweigh?: (key,value) =>number
Defined in: packages/cache/src/cache.ts:62
Give one entry’s share of capacity. Called once per set, before
the cache changes. The result must be a positive finite number no larger
than capacity. Omit it to weigh every entry as 1.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”timeToLive?
Section titled “timeToLive?”
readonlyoptionaltimeToLive?:number
Defined in: packages/cache/src/cache.ts:68
How long after its set an entry stays readable, in the milliseconds of
clock. An entry whose age has reached timeToLive is never
returned again. Requires clock.
Inherited from
Section titled “Inherited from”clock?
Section titled “clock?”
readonlyoptionalclock?:Clock
Defined in: packages/cache/src/cache.ts:73
The time source that timeToLive is measured against. A clock that moves backwards only delays expiry.
Inherited from
Section titled “Inherited from”trace?
Section titled “trace?”
readonlyoptionaltrace?:object
Defined in: packages/cache/src/cache.ts:80
Receive a CacheTraceEvent for each hit, miss, insert, update, eviction, delete, and expiry, in order, so a caller can replay or scrub the policy’s behavior. Any array fits. Omitted, the cache allocates no event objects. Events are immutable; the sink is not read by the cache.
readonlypush: (event) =>unknown
Parameters
Section titled “Parameters”Returns
Section titled “Returns”unknown
Inherited from
Section titled “Inherited from”policy
Section titled “policy”
readonlypolicy:CacheEvictionPolicyFactory<K>
Defined in: packages/cache/src/cache.ts:311
Build the cache’s eviction policy.