@keyv/tiered
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@keyv/tiered keyv

Tiered storage adapter for Keyv to manage local and remote store as one for Keyv

build codecov npm npm

Tiered storage adapter for Keyv.

Install

npm install --save keyv @keyv/tiered

Usage

First, you need to provide your local and remote stores to be used, being possible to use any Keyv storage adapter:

const Keyv = require('keyv');
const KeyvSqlite = require('@keyv/sqlite');
const KeyvTiered = require('@keyv/tiered');
const remoteStore = () => new Keyv({
	store: new KeyvSqlite({
		uri: 'sqlite://test/testdb.sqlite',
		busyTimeout: 30_000,
	}),
});
const localStore = () => new Keyv();
const remote = remoteStore();
const local = localStore();
const store = new KeyvTiered({remote, local});
const keyv = new Keyv({store});
keyv.on('error', handleConnectionError);

API

KeyvTiered([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

MIT © Jared Wray

Package Sidebar

Install

npm i @keyv/tiered

Weekly Downloads

196

Version

1.0.6

License

MIT

Unpacked Size

10.9 kB

Total Files

10

Last publish

Collaborators

  • jaredwray
  • lukechilds