Skip to content

PURISTA API


PURISTA API / @purista/redis-config-store / RedisConfigStore

Class: RedisConfigStore<M, F, S>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:41

A config store for using redis as storage. Config values are stored as stringified JSON.

Per default, setting/changing and removal of values are enabled.

Example

typescript
const config = {
 enableGet: true, // optional, default is true
 enableRemove: true, // optional, default is true
 enableSet: true, // optional, default is true
 url: 'redis://alice:foobared@awesome.redis.server:6379'
}

const store = new RedisConfigStore({ config })

await store.setConfig('configKey',{ myConfig: 'value' })

let value = await store.getConfig('configKey')
console.log(value) // outputs: { configKey: { myConfig: 'value' } }

await store.removeConfig('configKey')

value = await store.getConfig('configKey')
console.log(value) // outputs: undefined

See documentation of underlaying redis lib package for detailed configuration options.

See

NODE-REDIS

Extends

Type Parameters

M

M extends RedisModules = RedisModules

F

F extends RedisFunctions = RedisFunctions

S

S extends RedisScripts = RedisScripts

Constructors

Constructor

new RedisConfigStore<M, F, S>(config?): RedisConfigStore<M, F, S>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:48

Parameters

config?
cacheTtl?

number

Cache time to live in ms

config?

RedisClientOptions<M, F, S>

enableCache?

boolean

Enable cache

enableGet?

boolean

Enable generally get method

enableRemove?

boolean

Enable generally remove method

enableSet?

boolean

Enable generally set method

logger?

Logger

A logger instance

logLevel?

LogLevelName

A log level for new logger if logger is not set

Returns

RedisConfigStore<M, F, S>

Overrides

ConfigStoreBaseClass.constructor

Properties

cache

cache: ConfigStoreCacheMap

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:22

Inherited from

ConfigStoreBaseClass.cache


client

client: RedisClientType<M, F, S>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:46


config

config: object

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:20

cacheTtl?

optional cacheTtl: number

Cache time to live in ms

config?

optional config: RedisClientOptions<M, F, S>

enableCache?

optional enableCache: boolean

Enable cache

enableGet?

optional enableGet: boolean

Enable generally get method

enableRemove?

optional enableRemove: boolean

Enable generally remove method

enableSet?

optional enableSet: boolean

Enable generally set method

logger?

optional logger: Logger

A logger instance

logLevel?

optional logLevel: LogLevelName

A log level for new logger if logger is not set

Inherited from

ConfigStoreBaseClass.config


logger

logger: Logger

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:19

Inherited from

ConfigStoreBaseClass.logger


name

name: string

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:21

Inherited from

ConfigStoreBaseClass.name

Methods

destroy()

destroy(): Promise<void>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:103

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.destroy


getClient()

protected getClient(): Promise<RedisClientType<M, F, S>>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:54

Returns

Promise<RedisClientType<M, F, S>>


getConfig()

getConfig<ConfigNames>(...configNames): Promise<ObjectWithKeysFromStringArray<ConfigNames>>

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:39

Returns the values for given config properties. This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected getConfigImpl

Type Parameters

ConfigNames

ConfigNames extends string[]

Parameters

configNames

...ConfigNames

Returns

Promise<ObjectWithKeysFromStringArray<ConfigNames>>

an object of

Inherited from

ConfigStoreBaseClass.getConfig


getConfigImpl()

protected getConfigImpl<ConfigNames>(...configNames): Promise<ObjectWithKeysFromStringArray<ConfigNames>>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:61

This method must be overwritten by actual store implementation.

Type Parameters

ConfigNames

ConfigNames extends string[]

Parameters

configNames

...ConfigNames

list of config items

Returns

Promise<ObjectWithKeysFromStringArray<ConfigNames>>

an object of

Overrides

ConfigStoreBaseClass.getConfigImpl


removeConfig()

removeConfig(configName): Promise<void>

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:54

Removes the config item given by config name. This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected removeConfigImpl

Parameters

configName

string

Returns

Promise<void>

Inherited from

ConfigStoreBaseClass.removeConfig


removeConfigImpl()

protected removeConfigImpl(configName): Promise<void>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:80

This method must be overwritten by actual store implementation.

Parameters

configName

string

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.removeConfigImpl


setConfig()

setConfig(configName, configValue): Promise<void>

Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:71

Sets a config value This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected setConfigImpl

Parameters

configName

string

configValue

unknown

Returns

Promise<void>

Inherited from

ConfigStoreBaseClass.setConfig


setConfigImpl()

protected setConfigImpl(configName, configValue): Promise<void>

Defined in: redis-config-store/src/RedisConfigStore.impl.ts:92

This method must be overwritten by actual store implementation.

Parameters

configName

string

configValue

unknown

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.setConfigImpl