# boomerang-cache

> boomerangCache is a client side caching library based on localStorage

Latest version **1.2.0** (published 2017-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install boomerang-cache
pnpm add boomerang-cache
yarn add boomerang-cache
bun add boomerang-cache
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2017-12-18 |
| First published | 2016-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | giraysam, feyyazakkus |
| Maintainers | feyyazakkus, giraysam |
| Keywords | localStorage |

## Links

- npm: https://www.npmjs.com/package/boomerang-cache
- Repository: https://github.com/giraysam/boomerang-cache
- Issues: https://github.com/giraysam/boomerang-cache/issues
- npm.io page: https://npm.io/package/boomerang-cache

## Dependencies (1)

- [docdash](https://npm.io/package/docdash.md) ^0.4.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2017-12-18
- 1.1.0 — 2016-11-10
- 1.0.5 — 2016-10-11
- 1.0.4 — 2016-09-26
- 1.0.3 — 2016-09-22
- 1.0.2 — 2016-09-21
- 1.0.0 — 2016-09-21

## README

# Boomerang Cache
boomerangCache is a client side caching library based on localStorage.

[![NPM](https://nodei.co/npm/boomerang-cache.png?compact=true)](https://www.npmjs.com/package/boomerang-cache)

[![npm version][npm-badge-v]][npm] 
[![npm downloads][npm-badge-dm]][npm] 
[![build status][travis-badge]][travis] 
[![js-standard-style][code-standart-badge]](https://github.com/giraysam/boomerang-cache)

#### How to install?
Npm:
```sh
npm install boomerang-cache
```

Bower:
```sh
bower install boomerang-cache
```

### Docs
[https://giraysam.github.io/boomerang-cache](https://giraysam.github.io/boomerang-cache)

API Reference
-------------
* create
* check
* set
* get
* getAll
* length
* remove
* clear

* * *

### BoomerangCache.create

> Creates a new bucket.

#### Arguments

1. `bucket` (**String**)
2. `options` (**Object**)
    * `storage`: (**local** | **session**)
    * `encrypt`: (**true** | **false**)

 
```js
var boomerang = BoomerangCache.create('bucket1', {storage: 'local', encrypt: true});
```

### BoomerangCache.set

> Set a key to a particular value or a hash object (Object or Array) under a hash key.

#### Arguments

1. `key` (**String**)
2. `value` (**String**, **Number**, **Object**, **Array**)
3. `seconds` (**Number**) - optional


> These values will never expire and will only be removed when you (or the browser) removes them.

```js
boomerang.set('stringData', 'Hello World');
boomerang.set('numberData', 12345);
boomerang.set('objectData', {value: 'Hello World'});
boomerang.set('arrayData', [{value: 'Hello World'}, {value: 'Hello Boomerang'}]);
```

#### Set values with expire

> After 3 seconds this will return null.
```js
var seconds = 3;
boomerang.set('key', 'Hello World', seconds);
```

### BoomerangCache.get

> Returns the saved value for given key. If value is null or undefined it returns a default value.

#### Arguments

1. `key` (**String**)
2. `defaultValue` (**String**, **Number**, **Object**, **Array**)


```js
boomerang.get('key', 'Hello World'); // If value is null returns Hello World.
```

### BoomerangCache.getAll

> Returns all saved values.

```js
boomerang.getAll();
// {key1: 'value1'}, {key2: 'value2'}
```


### BoomerangCache.length

> Returns all values count.

```js
boomerang.length();
// returns 2
```

### BoomerangCache.remove

> Remove a key from storage

#### Arguments

1. `key` (**String**)


```js
boomerang.remove('key');
```


### BoomerangCache.clear

> Empties storage


```js
boomerang.clear();
```

[npm]: https://www.npmjs.org/package/boomerang-cache
[npm-badge-v]: https://img.shields.io/npm/v/boomerang-cache.svg?style=flat-square
[npm-badge-dm]: https://img.shields.io/npm/dm/boomerang-cache.svg?style=flat-square
[travis]: https://travis-ci.org/giraysam/boomerang-cache
[travis-badge]: https://travis-ci.org/giraysam/boomerang-cache.svg?branch=master
[code-standart-badge]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square

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