Skip to main content

Class: RedisConfigStore<M, F, S>


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

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-REDISopen in new window

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&lt;RedisStoreConfig&lt;M, F, S&gt;&gt;.constructor

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:45open in new window

Properties

client

client: RedisClientType<M, F, S>

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:43open in new window


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/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:10


logger

logger: Logger

Inherited from

ConfigStoreBaseClass.logger

Defined in

core/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:9


name

name: string

Inherited from

ConfigStoreBaseClass.name

Defined in

core/lib/types/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:11

Methods

destroy

destroy(): Promise<void>

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.destroy

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:109open in new window


getConfig

getConfig(...configNames): Promise<Record<string, unknown>>

Parameters

NameType
...configNamesstring[]

Returns

Promise<Record<string, unknown>>

Overrides

ConfigStoreBaseClass.getConfig

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:51open in new window


removeConfig

removeConfig(configName): Promise<void>

Parameters

NameType
configNamestring

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.removeConfig

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:74open in new window


setConfig

setConfig(configName, configValue): Promise<void>

Parameters

NameType
configNamestring
configValueunknown

Returns

Promise<void>

Overrides

ConfigStoreBaseClass.setConfig

Defined in

redis-config-store/src/RedisConfigStore.impl.ts:92open in new window

Last update:
Contributors: Sebastian Wessel