@budarin/cache-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.18 • Public • Published

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');

Readme

Keywords

Package Sidebar

Install

npm i @budarin/cache-store

Weekly Downloads

2

Version

1.0.18

License

MIT

Unpacked Size

4.87 kB

Total Files

5

Last publish

Collaborators

  • budarin