@zero-version/key-value-storage.file
v9.9.14
Published
File key/value storage.
Downloads
30
Maintainers
Readme
File key/value storage.
Usage
The fileKeyValueStore
method accepts two arguments:
fileName
, which defaults to 'cache.json'dir
, which defaults toos.tmpdir()
The file is persisted each time a set
or remove
method is invoked, and read each time the get
method is invoked.
import { fileKeyValueStore } from '@zero-version/key-value-storage.file';
const store = fileKeyValueStore();
store.set('my-value', { some: 'value' });
console.log(store.get('my-value'));
// -> { some: 'value' }
store.set('my-value', { some: 'other-value' });
console.log(store.get('my-value'));
// -> { some: 'other-value' }
store.remove('my-value');
console.log(store.get('my-value'));
// -> undefined
Support ☕
Are you using a package I've developed and finding it useful? Or have you looked at one of my repositories and learnt something new? If so, please consider buying me a coffee. Thanks!