A multi storage adapter to manage local and remote store as one for Keyv.
npm install --save @keyvhq/multi
First, you need to provide your local
and remote
stores to be used, being possible to use any Keyv storage adapter:
const KeyvMulti = require('@keyvhq/multi')
const KeyvRedis = require('@keyvhq/redis')
const Keyv = require('@keyvhq/core')
const keyv = new Keyv({
store: new KeyvMulti({
local: new Map(),
remote: new KeyvRedis()
})
})
After that, just interact with the store as a single keyv instance.
The actions will be performed in parallel when is possible, and the stores will fallback between them to keep them in synchronized.
Type: Object
Default: new Keyv()
A keyv instance to be used as local strategy.
Type: Object
Default: new Keyv()
A keyv instance to be used as remote strategy.
Type: Function
Default: () => true
The validator function is used as a precondition to determining is remote storage should be checked.
@keyvhq/multi © Jytesh, released under the MIT License.
Maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq