https://github.com/budarin/cache-store
Service for storing json data in the browser cache
https://github.com/budarin/cache-store
Last synced: 15 days ago
JSON representation
Service for storing json data in the browser cache
- Host: GitHub
- URL: https://github.com/budarin/cache-store
- Owner: budarin
- License: mit
- Created: 2023-11-28T11:18:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-09T14:30:21.000Z (20 days ago)
- Last Synced: 2025-05-09T14:34:39.063Z (20 days ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@budarin/cache-store
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```bash
yarn add @budarin/cache-store
```## Usage
```ts
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');
```