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
Type parameters
Name | Type |
---|---|
M | extends RedisModules = RedisModules |
F | extends RedisFunctions = RedisFunctions |
S | extends RedisScripts = RedisScripts |
Hierarchy
ConfigStoreBaseClass
<RedisStoreConfig
<M
,F
,S
>>↳
RedisConfigStore
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new RedisConfigStore<M
, F
, S
>(config?
): RedisConfigStore
<M
, F
, S
>
Type parameters
Name | Type |
---|---|
M | extends RedisModules = RedisModules |
F | extends RedisFunctions = RedisFunctions |
S | extends RedisScripts = RedisScripts |
Parameters
Name | Type | Description |
---|---|---|
config? | Object | - |
config.cacheTtl? | number | Cache time to live in ms |
config.config? | RedisClientOptions <M , F , S > | - |
config.enableCache? | boolean | Enable cache |
config.enableGet? | boolean | Enable generally get method |
config.enableRemove? | boolean | Enable generally remove method |
config.enableSet? | boolean | Enable generally set method |
config.logLevel? | LogLevelName | A log level for new logger if logger is not set |
config.logger? | Logger | A 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
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
Name | Type | Description |
---|---|---|
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 |
logLevel? | LogLevelName | A log level for new logger if logger is not set |
logger? | Logger | A logger instance |
Inherited from
Defined in
core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:18
logger
• logger: Logger
Inherited from
Defined in
core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:17
name
• name: string
Inherited from
Defined in
core/dist/commonjs/core/ConfigStore/ConfigStoreBaseClass.impl.d.ts:19
Methods
destroy
▸ destroy(): Promise
<void
>
Returns
Promise
<void
>
Overrides
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
Name | Type |
---|---|
ConfigNames | extends string [] |
Parameters
Name | Type |
---|---|
...configNames | ConfigNames |
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
Name | Type |
---|---|
ConfigNames | extends string [] |
Parameters
Name | Type | Description |
---|---|---|
...configNames | ConfigNames | list 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
Name | Type |
---|---|
configName | string |
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
Name | Type |
---|---|
configName | string |
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
Name | Type |
---|---|
configName | string |
configValue | unknown |
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
Name | Type |
---|---|
configName | string |
configValue | unknown |
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.setConfigImpl