@budarin/cache-store
v1.0.18
Published
Service for storing json data in the browser cache
Downloads
7
Readme
cache-store
Service for storing json data in the browser cache.
The service is a simple alternative to IndexedDB, but without an overhead for the description of the structure and the ceremonies for updating and changing structure.
This storage is convenient both for direct storage of unstructured data in the form of JSON and as a common data storage shared by the client and the service worker.
Instalation
yarn add @budarin/cache-store
Usage
import { CacheStore } from '@budarin/cache-store';
const store = new CacheStore('kv-storage'); //ew CacheStore('kv-storage', console);
const usersStore = [
{
name: 'Ivan',
age: 20,
},
{
name: 'Petr',
age: 21,
},
];
await store.setItem('users', usersStore);
const users = await store.getItem('users');
users.forEach((user) => console.log(user));
await store.removeItem('users');
await store.clear('kv-storage');