Skip to main content

Class: RedisStore

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

Implements a SimpleStore storage system that combines a local in-memory store optionally backed by Redis. When no Redis client is given, the store behaves as a plain in-memory store (equivalent to MemoryStore).

Implements​

Constructors​

Constructor​

new RedisStore(baseKey?, client?): RedisStore

Defined in: core/src/RedisStore.ts:43

Parameters​

baseKey?​

string = "store."

The base key that is pre-pended to all IDs.

client?​

RedisClientType

The Redis client to back this store with. When omitted, the store operates purely in-memory.

Returns​

RedisStore

Properties​

baseKey​

readonly baseKey: string

Defined in: core/src/RedisStore.ts:23

The base key that is pre-pended to all IDs.


client?​

optional client?: RedisClientType

Defined in: core/src/RedisStore.ts:25


defaultTTL​

defaultTTL: number = 60

Defined in: core/src/RedisStore.ts:28

The default record TTL (in seconds).

Implementation of​

SimpleStore.defaultTTL


entries​

protected entries: Map<string, MemoryStoreEntry>

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


maxSize​

maxSize: number = 10000

Defined in: core/src/RedisStore.ts:33

The maximum number of records to store.

Implementation of​

SimpleStore.maxSize


sets​

protected sets: Map<string, MemoryStoreSetEntry>

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

Methods​

clear()​

clear(): Promise<void>

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

Deletes all entries in the storage system.

Returns​

Promise<void>

Implementation of​

SimpleStore.clear


delete()​

delete(id): Promise<void>

Defined in: core/src/RedisStore.ts:67

Deletes a single record with the given id.

Parameters​

id​

string

The id of the record to delete.

Returns​

Promise<void>

Implementation of​

SimpleStore.delete


deleteMany()​

deleteMany(ids): Promise<void>

Defined in: core/src/RedisStore.ts:75

Deletes the records associated with the list of given ids.

Parameters​

ids​

string[]

The list of ids to delete.

Returns​

Promise<void>

Implementation of​

SimpleStore.deleteMany


deleteSet()​

deleteSet(id): Promise<void>

Defined in: core/src/RedisStore.ts:92

Deletes the set of records associated with the given id.

Parameters​

id​

string

Returns​

Promise<void>

Implementation of​

SimpleStore.deleteSet


destroy()​

destroy(): void

Defined in: core/src/RedisStore.ts:104

Returns​

void


load()​

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

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

Retrieves a single record with the given id.

Parameters​

id​

string

The id of the record to retrieve.

skipRedis?​

boolean = false

Returns​

Promise<Record<string, any> | undefined>

Implementation of​

SimpleStore.load


loadMany()​

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

Defined in: core/src/RedisStore.ts:167

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

Parameters​

ids​

string[]

The list of ids of records to retrieve.

Returns​

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

Implementation of​

SimpleStore.loadMany


loadSet()​

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

Defined in: core/src/RedisStore.ts:236

Retrieves the set of records with the given id.

Parameters​

id​

string

Returns​

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

Implementation of​

SimpleStore.loadSet


save()​

save(id, data, ttl?, skipRedis?): Promise<void>

Defined in: core/src/RedisStore.ts:279

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.

skipRedis?​

boolean = false

Returns​

Promise<void>

Implementation of​

SimpleStore.save


saveMany()​

saveMany(ids, data, ttl?): Promise<void>

Defined in: core/src/RedisStore.ts:311

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​

Promise<void>

Implementation of​

SimpleStore.saveMany


saveSet()​

saveSet(id, data, idProp?, ttl?): Promise<void>

Defined in: core/src/RedisStore.ts:358

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​

Promise<void>

Implementation of​

SimpleStore.saveSet