package
Lightweight, asynchronous, key-value JSON storage for Node.js applications. Supports TTL, atomic updates, self-repairing and more.
npm install storage-asyncGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Lightweight, asynchronous, key-value JSON storage for Node.js applications. Supports TTL, atomic updates, self-repairing and more.
This module aims to provide relatively lightweight and reliable way of locally storing JSON data, such as cache, preferences or temporary settings.
$ npm install storage-asyncimport {createStore} from 'storage-async';
(async () => {
const store = await createStore();
await store.set('name', 'John');
await store.set('age', 20);
await store.has('name'); //=> true
await store.delete('age');
await store.get('name'); //=> 'John'
await store.clear();
})();createStore(options)Creates a new store, which features the following API:
interface Handlers {
set: (key: string, value: unknown) => Promise<void>;
get: (key: string) => Promise<unknown>;
has: (key: string) => Promise<boolean>;
delete: (key: string) => Promise<void>;
clear: () => Promise<void>;
}optionsType: Options
Storage options:
interface Options {
path?: string; // defaults to './store.json
ttl?: number; // defaults to 900000ms (15 minutes)
resetOnFailure?: boolean; // whether to reset the store if it couldn't be repaired
}./store.json by default) does not exist, it will be created automatically.MIT © Antoni Kepinski
Estimated unpacked size across 9 packages.
716.1 kB
Includes dependencies.
3 direct · 3 outdated