Last date modified: 2025-Jul-02

Interface: ICache<K, V>

Generic cache implementation for caching data

Type Parameters

KextendsSupportedCacheKeyTypeUnion = string

Key type

V = any

Value type

Methods

clear()

clear(): void

Removes all items from cache

Returns

void


delete()

delete(key): boolean

Removes the cached item for the provided key from the cache, if it exists

Parameters

key: K

Key to remove

Returns

boolean

Boolean indicating whether or not an item was removed


get()

get<T>(key): T

Retrieves the cached item for the provided key, if it exists

Type Parameters

T = V

Value type to retrieve (can be used to override cache value type)

Parameters

key: K

Key to retrieve

Returns

T

The cached item or undefined


has()

has(key): boolean

Checks whether the cache contains the provided key

Parameters

key: K

Key to check

Returns

boolean

Whether or not the key exists in the cache


set()

set<T>(key, value, override?): T

Inserts or overrides the value for the provided key

Type Parameters

T = V

Value type to set (can be used to override cache value type)

Parameters

key: K

Key to set

value: T

Value to insert

override?: boolean

Whether or not to allow overriding an existing value (defaults to true)

Returns

T

The resulting item value

Return to top of the page
Feedback