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
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
Extends
ConfigStoreBaseClass
<RedisStoreConfig
<M
,F
,S
>>
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?
A logger instance
logLevel?
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
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
logger
logger:
Logger
Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:19
Inherited from
name
name:
string
Defined in: core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:21
Inherited from
Methods
destroy()
destroy():
Promise
<void
>
Defined in: redis-config-store/src/RedisConfigStore.impl.ts:103
Returns
Promise
<void
>
Overrides
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
>