@keyvhq/multi
TypeScript icon, indicating that this package has built-in type declarations

2.1.5 • Public • Published

@keyvhq/multi keyv

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

Package Sidebar

Install

npm i @keyvhq/multi

Homepage

keyv.js.org

Weekly Downloads

642

Version

2.1.5

License

MIT

Unpacked Size

6.87 kB

Total Files

5

Last publish

Collaborators

  • kikobeats
  • jytesh