keyv-jetpack
v0.1.0
Published
FS-Jetpack based backend for Keyv. Wait, what
Downloads
2
Readme
KeyvJetpack
Simple filesystem based storage for the Keyv key-value store; FS-Jetpackfs-jetpack is used due to unadulterated laziness.
The existing keyv-file module had some quirky decisions — in particular, every namespace was stored in a single JSON file, making large piles of data a little punishing.
Usage
Create a new KeyV instance and use a KeyFsStore instance as its store
option. That's it.
import { KeyvFsStore } from 'keyv-jetpack';
import { Keyv } from 'keyv';
const kv = new Keyv({ store: new KeyFsStore() });
await kv.set('key', { data: 'stuff goes here…' });
console.log(await kv.get('key')); // { data: 'stuff goes here…' };
await kv.clear(); // Directory deleted
Thanks to KeyV, things like expiring values and such are handled transparently. A custom storage directory can be used, or multiple namespaces to avoid collisions.
import { KeyvFsStore } from 'keyv-fs';
import { Keyv } from 'keyv';
const kv = new Keyv({ store: new KeyFsStore({
rootDir: './custom/storage'
}) });
By default, a keyv
directory in the systemp temp dir will be used.