Skip to main content

Class: MemoryStore

Defined in: core/src/MemoryStore.ts:17

Implements a SimpleStore storage system that uses a local in-memory storage map.

Implements​

Constructors​

Constructor​

new MemoryStore(): MemoryStore

Defined in: core/src/MemoryStore.ts:30

Returns​

MemoryStore

Properties​

defaultTTL​

defaultTTL: number = 60

Defined in: core/src/MemoryStore.ts:19

The default record TTL (in seconds).

Implementation of​

SimpleStore.defaultTTL


entries​

protected entries: Map<string, MemoryStoreEntry>

Defined in: core/src/MemoryStore.ts:21


maxSize​

maxSize: number = 10000

Defined in: core/src/MemoryStore.ts:24

The maximum number of records to store.

Implementation of​

SimpleStore.maxSize


sets​

protected sets: Map<string, MemoryStoreSetEntry>

Defined in: core/src/MemoryStore.ts:26

Methods​

clear()​

clear(): void

Defined in: core/src/MemoryStore.ts:35

Deletes all entries in the storage system.

Returns​

void

Implementation of​

SimpleStore.clear


delete()​

delete(id): void

Defined in: core/src/MemoryStore.ts:40

Deletes a single record with the given id.

Parameters​

id​

string

The id of the record to delete.

Returns​

void

Implementation of​

SimpleStore.delete


deleteMany()​

deleteMany(ids): void

Defined in: core/src/MemoryStore.ts:44

Deletes the records associated with the list of given ids.

Parameters​

ids​

string[]

The list of ids to delete.

Returns​

void

Implementation of​

SimpleStore.deleteMany


deleteSet()​

deleteSet(id): void

Defined in: core/src/MemoryStore.ts:50

Deletes the set of records associated with the given id.

Parameters​

id​

string

Returns​

void

Implementation of​

SimpleStore.deleteSet


destroy()​

destroy(): void

Defined in: core/src/MemoryStore.ts:59

Stops the background sweep timer. Call when the owning SessionManager is destroyed.

Returns​

void


load()​

load(id): Record<string, any> | undefined

Defined in: core/src/MemoryStore.ts:63

Retrieves a single record with the given id.

Parameters​

id​

string

The id of the record to retrieve.

Returns​

Record<string, any> | undefined

Implementation of​

SimpleStore.load


loadMany()​

loadMany(ids): (Record<string, any> | undefined)[]

Defined in: core/src/MemoryStore.ts:78

Retrieves the list of records for the given list of ids.

Parameters​

ids​

string[]

The list of ids of records to retrieve.

Returns​

(Record<string, any> | undefined)[]

Implementation of​

SimpleStore.loadMany


loadSet()​

loadSet(id): (Record<string, any> | undefined)[] | undefined

Defined in: core/src/MemoryStore.ts:88

Retrieves the set of records with the given id.

Parameters​

id​

string

Returns​

(Record<string, any> | undefined)[] | undefined

Implementation of​

SimpleStore.loadSet


save()​

save(id, data, ttl?): void

Defined in: core/src/MemoryStore.ts:103

Stores a single record with the given id for the specified TTL.

Parameters​

id​

string

The id of the record to retrieve.

data​

Record<string, any>

The record to store.

ttl?​

number = ...

The number of seconds that the record will be stored.

Returns​

void

Implementation of​

SimpleStore.save


saveMany()​

saveMany(ids, data, ttl?): void

Defined in: core/src/MemoryStore.ts:119

Stores a list of records with the given list of ids for the specified TTL.

Parameters​

ids​

string[]

data​

Record<string, any>[]

The list of records to store.

ttl?​

number = ...

The number of seconds that each record will be stored.

Returns​

void

Implementation of​

SimpleStore.saveMany


saveSet()​

saveSet(id, data, idProp?, ttl?): void

Defined in: core/src/MemoryStore.ts:129

Stores a set of records with the given id for the specified TTL.

Parameters​

id​

string

The id of the record set to store.

data​

Record<string, any>[]

The record to store.

idProp?​

string = "uid"

The name of the property in data to use as an id for storage.

ttl?​

number = ...

The number of seconds that the set will be stored.

Returns​

void

Implementation of​

SimpleStore.saveSet