Skip to content

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

Class: RedisConfigStore<M, F, S>

@purista/redis-config-store.RedisConfigStore

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

Type parameters

NameType
Mextends RedisModules = RedisModules
Fextends RedisFunctions = RedisFunctions
Sextends RedisScripts = RedisScripts

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

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

Type parameters

NameType
Mextends RedisModules = RedisModules
Fextends RedisFunctions = RedisFunctions
Sextends RedisScripts = RedisScripts

Parameters

NameTypeDescription
config?Object-
config.cacheTtl?numberCache time to live in ms
config.config?RedisClientOptions<M, F, S>-
config.enableCache?booleanEnable cache
config.enableGet?booleanEnable generally get method
config.enableRemove?booleanEnable generally remove method
config.enableSet?booleanEnable generally set method
config.logLevel?LogLevelNameA log level for new logger if logger is not set
config.logger?LoggerA logger instance

Returns

RedisConfigStore<M, F, S>

Overrides

ConfigStoreBaseClass.constructor

Defined in

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

Properties

cache

cache: ConfigStoreCacheMap

Inherited from

ConfigStoreBaseClass.cache

Defined in

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


client

client: RedisClientType<M, F, S>

Defined in

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


config

config: Object

Type declaration

NameTypeDescription
cacheTtl?numberCache time to live in ms
config?RedisClientOptions<M, F, S>-
enableCache?booleanEnable cache
enableGet?booleanEnable generally get method
enableRemove?booleanEnable generally remove method
enableSet?booleanEnable generally set method
logLevel?LogLevelNameA log level for new logger if logger is not set
logger?LoggerA logger instance

Inherited from

ConfigStoreBaseClass.config

Defined in

core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:18


logger

logger: Logger

Inherited from

ConfigStoreBaseClass.logger

Defined in

core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:17


name

name: string

Inherited from

ConfigStoreBaseClass.name

Defined in

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

Methods

destroy

destroy(): Promise<void>

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.destroy

Defined in

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


getClient

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

Returns

Promise<RedisClientType<M, F, S>>

Defined in

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


getConfig

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

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

Type parameters

NameType
ConfigNamesextends string[]

Parameters

NameType
...configNamesConfigNames

Returns

Promise<ObjectWithKeysFromStringArray<ConfigNames>>

an object of

Inherited from

ConfigStoreBaseClass.getConfig

Defined in

core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:37


getConfigImpl

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

This method must be overwritten by actual store implementation.

Type parameters

NameType
ConfigNamesextends string[]

Parameters

NameTypeDescription
...configNamesConfigNameslist of config items

Returns

Promise<ObjectWithKeysFromStringArray<ConfigNames>>

an object of

Overrides

ConfigStoreBaseClass.getConfigImpl

Defined in

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


removeConfig

removeConfig(configName): Promise<void>

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

Parameters

NameType
configNamestring

Returns

Promise<void>

Inherited from

ConfigStoreBaseClass.removeConfig

Defined in

core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:52


removeConfigImpl

removeConfigImpl(configName): Promise<void>

This method must be overwritten by actual store implementation.

Parameters

NameType
configNamestring

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.removeConfigImpl

Defined in

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


setConfig

setConfig(configName, configValue): Promise<void>

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

Parameters

NameType
configNamestring
configValueunknown

Returns

Promise<void>

Inherited from

ConfigStoreBaseClass.setConfig

Defined in

core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:69


setConfigImpl

setConfigImpl(configName, configValue): Promise<void>

This method must be overwritten by actual store implementation.

Parameters

NameType
configNamestring
configValueunknown

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.setConfigImpl

Defined in

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