@keyvhq/multi
v2.1.5
Published
Layered cache with any backend
Downloads
3,978
Readme
@keyvhq/multi
A multi storage adapter to manage local and remote store as one for Keyv.
Install
npm install --save @keyvhq/multi
Usage
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.
API
multi([options])
options
local
Type: Object
Default: new Keyv()
A keyv instance to be used as local strategy.
remote
Type: Object
Default: new Keyv()
A keyv instance to be used as remote strategy.
validator
Type: Function
Default: () => true
The validator function is used as a precondition to determining is remote storage should be checked.
License
@keyvhq/multi © Jytesh, released under the MIT License. Maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq