Skip to main content

Class: LRUCache<T>

LRU cache (least recently used) Source: https://stackoverflow.com/a/46432113

Type parameters

Name
T

Constructors

constructor

new LRUCache<T>(max?)

Type parameters

Name
T

Parameters

NameTypeDefault value
maxnumber10

Defined in

packages/core/src/cache.ts:9

Methods

clear

clear(): void

Deletes all values from the cache.

Returns

void

Defined in

packages/core/src/cache.ts:17


get

get(key): undefined | T

Returns the value for the given key.

Parameters

NameTypeDescription
keystringThe key to retrieve.

Returns

undefined | T

The value if found; undefined otherwise.

Defined in

packages/core/src/cache.ts:26


set

set(key, val): void

Sets the value for the given key.

Parameters

NameTypeDescription
keystringThe key to set.
valTThe value to set.

Returns

void

Defined in

packages/core/src/cache.ts:40


delete

delete(key): void

Deletes the value for the given key.

Parameters

NameTypeDescription
keystringThe key to delete.

Returns

void

Defined in

packages/core/src/cache.ts:53


keys

keys(): IterableIterator<string>

Returns the list of all keys in the cache.

Returns

IterableIterator<string>

The array of keys in the cache.

Defined in

packages/core/src/cache.ts:61