Last date modified: 2025-Jul-02

Interface: IExpirationCache<T>

Experimental

This API is in preview and not ready for production use. Expect breaking changes in the future. Class for implementing item caches with a time-based expiration.

Type Parameters

T

Cache item type

Methods

addOrUpdate()

addOrUpdate(key, value, insertedAt?): void

Experimental

Parameters

key: string

Key to add

value: T

Value to add

insertedAt?: number

Optional insertedAt override

Returns

void

Remarks

This will refresh the expiration timer.


get()

get(key, markAsUsed?): T

Experimental

Parameters

key: string

Key to retrieve

markAsUsed?: boolean

Whether the retrieval should mark the cache entry as used (Defaults to true)

Returns

T

Cache item


has()

has(key): boolean

Experimental

Parameters

key: string

Key to check

Returns

boolean

Boolean indicating if a cache item with that ID exists


howOld()

howOld(key): number

Experimental

Parameters

key: string

Key to check

Returns

number

undefined if it doesn't exist, otherwise how old the cache entry is in milliseconds


tryRemove()

tryRemove(key, fireEvictionEvent?): boolean

Experimental

Parameters

key: string

Key to remove

fireEvictionEvent?: boolean

Returns

boolean

Whether an item was removed


updateMaxSize()

updateMaxSize(newMaxSize): void

Experimental

Parameters

newMaxSize: number

new max cache size

Returns

void

Return to top of the page
Feedback