2.0.2 • Published 9 months ago

@keyv/tiered v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@keyv/tiered

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

build codecov npm npm

Feature is Deprecated

This feature is deprecated and will be removed in 2025 as it is no longer needed.

offline and tiered mode for caching is built into the core Cacheable library which uses Keyv under the hood. Please use the Cacheable library for offline and tiered caching.

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:

import Keyv from 'keyv';
import KeyvTiered from '@keyv/tiered';
import KeyvSqlite from '@keyv/sqlite';

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

2.0.2

9 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago