# @lindeneg/ls-cache

> Utility class interacting with localStorage.

Latest version **2.0.7** (published 2022-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lindeneg/ls-cache
pnpm add @lindeneg/ls-cache
yarn add @lindeneg/ls-cache
bun add @lindeneg/ls-cache
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2022-03-10 |
| First published | 2022-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lindeneg |
| Maintainers | christianlindeneg |
| Keywords | cache, typescript, localStorage |

## Links

- npm: https://www.npmjs.com/package/@lindeneg/ls-cache
- Repository: https://github.com/Lindeneg/lindeneg-npm-packages
- Homepage: https://github.com/lindeneg/lindeneg-npm-packages/tree/master/packages/ls-cache
- Issues: https://github.com/Lindeneg/lindeneg-npm-packages/issues
- npm.io page: https://npm.io/package/@lindeneg/ls-cache

## Dependencies (2)

- [@lindeneg/cache](https://npm.io/package/@lindeneg/cache.md) ^2.1.7
- [@lindeneg/types](https://npm.io/package/@lindeneg/types.md) ^1.1.6

## Recent versions

- 2.0.7 (latest) — 2022-03-10
- 2.0.6 — 2022-02-19
- 2.0.5 — 2022-02-19
- 2.0.4 — 2022-02-13
- 2.0.3 — 2022-02-13
- 2.0.2 — 2022-02-07
- 2.0.1 — 2022-02-05
- 2.0.0 — 2022-01-29
- 1.1.1 — 2022-01-23
- 1.1.0 — 2022-01-23

## README

### @lindeneg/ls-cache

![typescript](https://badgen.net/badge/icon/typescript?icon=typescript&label) ![bundle-size](https://badgen.net/bundlephobia/min/@lindeneg/ls-cache@2.0.4) ![license](https://badgen.net/npm/license/@lindeneg/ls-cache)

---

Utility class for interacting with [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)

### Installation

`yarn add @lindeneg/ls-cache`

### Usage

```ts
import LSCache from '@lindeneg/ls-cache';

// default usage
const cache = new LSCache();

// async usage
const cache = new LSCache({
  delayInit: true,
});

await cache.initialize();
```

#### Config

```ts
type Config = {
  /* prefix localStorage keys to avoid collisions
     default: '__cl_ls_cache__' */
  prefix?: string;

  /* delay localStorage initialization
     default: false */
  delayInit?: boolean;

  /* trimming interval in seconds 
     default: 600 */
  trim?: number;

  /* time-to-live in seconds 
     default: 3600 */
  ttl?: number;
};
```

#### Methods

The documentation [here](https://github.com/Lindeneg/lindeneg-npm-packages/tree/master/packages/cache#methods) can be used.

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