# @raniel/local-storage-cache

> Module for use the local storage as a cache

Latest version **1.0.3** (published 2021-11-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @raniel/local-storage-cache
pnpm add @raniel/local-storage-cache
yarn add @raniel/local-storage-cache
bun add @raniel/local-storage-cache
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-11-05 |
| First published | 2020-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniele Sabre |
| Maintainers | raniel |
| Keywords | localstorage, cache, javascript |

## Links

- npm: https://www.npmjs.com/package/@raniel/local-storage-cache
- Repository: https://github.com/dsabre/local-storage-cache
- Homepage: https://github.com/dsabre/local-storage-cache#readme
- Issues: https://github.com/dsabre/local-storage-cache/issues
- npm.io page: https://npm.io/package/@raniel/local-storage-cache

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ^2.29.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-11-05
- 1.0.1 — 2021-11-05
- 1.0.0 — 2020-12-28

## README

# Local Storage Cache

Npm module for use the local storage as a cache


## Dependencies
[Moment.js](https://momentjs.com/)


## Installation

```bash
  npm i @raniel/local-storage-cache
```
    
    
## Methods
The class exposes these methods:

#### `setBucket(bucketName: string)`
Set the bucket name for the cache, if not used the default bucket name cache is used

---

#### `set(cid: string, value: any, expirationInMinutes: number)`
Set a cache item in bucket.
- **cid**: is the cache id for this item,
- **value**: contain what you want to be saved,
- **expirationInMinutes**: pass here the amount of minutes while you cache item is valid.

---

#### `get(cid: string)`
Get a cache item from bucket.
- **cid**: is the cache id for this item.

---

#### `remove(cid: string)`
Remove a cache item from bucket.
- **cid**: is the cache id for this item.

---

#### `flush()`
Flush the entire bucket from local storage.

---

#### `flushExpired()`
Flush expired items from bucket.


## Thanks

This class is inspired by:

[lscache](https://www.npmjs.com/package/lscache)


## License

[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/@raniel/local-storage-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
