Last date modified: 2026-Mar-30

Interface: IAsyncExpirationCache<T>

Experimental

This API is in preview and not ready for production use. Expect breaking changes in the future. Async interface for implementing item caches with a time-based expiration. This interface provides async methods to support IndexedDB operations.

Type Parameters

TextendsNonNullable<unknown>

Cache item type (cannot be undefined or null)

Properties

isAsyncCache

readonlyisAsyncCache: true

Experimental

Methods

addOrUpdate()

addOrUpdate(key, value, insertedAt?): Promise<void>

Experimental

Parameters

key: string

Key to add

value: T

Value to add

insertedAt?: number

Optional insertedAt override

Returns

Promise<void>

Remarks

This will refresh the expiration timer.


get()

get(key, markAsUsed?): Promise<T>

Experimental

Parameters

key: string

Key to retrieve

markAsUsed?: boolean

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

Returns

Promise<T>

Cache item


has()

has(key): Promise<boolean>

Experimental

Parameters

key: string

Key to check

Returns

Promise<boolean>

Boolean indicating if a cache item with that ID exists


howOld()

howOld(key): Promise<number>

Experimental

Parameters

key: string

Key to check

Returns

Promise<number>

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


tryRemove()

tryRemove(key, fireEvictionEvent?): Promise<boolean>

Experimental

Parameters

key: string

Key to remove

fireEvictionEvent?: boolean

Returns

Promise<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