Skip to main content

QInMemoryCache

@quik/cache


@quik/cache / QInMemoryCache

Class: QInMemoryCache

Defined in: cache/src/QInMemoryCache.ts:13

In-memory implementation of the cache feature backed by a Map.

Entries are evicted lazily on access when their TTL has elapsed.

Implements

  • IQCache

Constructors

Constructor

new QInMemoryCache(): QInMemoryCache

Returns

QInMemoryCache

Methods

clear()

clear(): Promise<void>

Defined in: cache/src/QInMemoryCache.ts:82

Remove all entries from the cache.

Returns

Promise<void>

Implementation of

IQCache.clear


delete()

delete(key): Promise<void>

Defined in: cache/src/QInMemoryCache.ts:54

Remove a value by key.

Parameters

key

string

Cache key.

Returns

Promise<void>

Implementation of

IQCache.delete


get()

get<T>(key): Promise<T>

Defined in: cache/src/QInMemoryCache.ts:21

Retrieve a value by key, returning undefined if missing or expired.

Type Parameters

T

T = unknown

Parameters

key

string

Cache key.

Returns

Promise<T>

Implementation of

IQCache.get


has()

has(key): Promise<boolean>

Defined in: cache/src/QInMemoryCache.ts:64

Check whether a key exists and has not expired.

Parameters

key

string

Cache key.

Returns

Promise<boolean>

Implementation of

IQCache.has


set()

set<T>(key, value, ttlMs?): Promise<void>

Defined in: cache/src/QInMemoryCache.ts:43

Store a value by key with an optional TTL.

Type Parameters

T

T = unknown

Parameters

key

string

Cache key.

value

T

Value to store.

ttlMs?

number

Optional time-to-live in milliseconds.

Returns

Promise<void>

Implementation of

IQCache.set