Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/services/cache/storage/memory

lib/services/cache/storage/memory

In-memory cache storage implementation using LRU cache.

This storage backend keeps all cache entries in memory using an LRU (Least Recently Used) eviction policy. It’s fast and efficient for development and testing, but data is lost when the process restarts.

Classes

MemoryCacheStorage

Cache storage interface for different backends

Implements

Constructors

Constructor

new MemoryCacheStorage(options): MemoryCacheStorage

Parameters
options

MemoryCacheOptions = {}

Returns

MemoryCacheStorage

Methods

get()

get<T>(key): Promise<null | CacheEntry<T>>

Get a value from cache

Type Parameters
T

T

Parameters
key

string

Returns

Promise<null | CacheEntry<T>>

Implementation of

CacheStorage.get

set()

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

Set a value in cache

Type Parameters
T

T

Parameters
key

string

value

T

options?

CacheSetOptions

Returns

Promise<void>

Implementation of

CacheStorage.set

delete()

delete(key): Promise<boolean>

Delete a value from cache

Parameters
key

string

Returns

Promise<boolean>

Implementation of

CacheStorage.delete

has()

has(key): Promise<boolean>

Check if key exists

Parameters
key

string

Returns

Promise<boolean>

Implementation of

CacheStorage.has

clear()

clear(pattern?): Promise<number>

Clear cache entries matching pattern

Parameters
pattern?

string

Returns

Promise<number>

Number of entries cleared

Implementation of

CacheStorage.clear

keys()

keys(pattern?): Promise<string[]>

Get all keys matching pattern

Parameters
pattern?

string

Returns

Promise<string[]>

Implementation of

CacheStorage.keys

getMany()

getMany<T>(keys): Promise<Map<string, CacheEntry<T>>>

Get multiple values at once

Type Parameters
T

T

Parameters
keys

string[]

Returns

Promise<Map<string, CacheEntry<T>>>

Implementation of

CacheStorage.getMany

setMany()

setMany<T>(entries, options?): Promise<void>

Set multiple values at once

Type Parameters
T

T

Parameters
entries

Map<string, T>

options?

CacheSetOptions

Returns

Promise<void>

Implementation of

CacheStorage.setMany

getStats()

getStats(): Promise<CacheStats>

Get cache statistics

Returns

Promise<CacheStats>

Implementation of

CacheStorage.getStats

cleanup()

cleanup(): Promise<number>

Clean up expired entries

Returns

Promise<number>

Number of entries cleaned

Implementation of

CacheStorage.cleanup

destroy()

destroy(): void

Destroy the storage (cleanup resources)

Returns

void

Implementation of

CacheStorage.destroy

Last updated on