Boomerang Cache
boomerangCache is a client side caching library based on localStorage.
How to install?
Npm:
npm install boomerang-cache
Bower:
bower install boomerang-cache
Docs
https://giraysam.github.io/boomerang-cache
API Reference
- create
- check
- set
- get
- getAll
- length
- remove
- clear
BoomerangCache.create
Creates a new bucket.
Arguments
bucket
(String)options
(Object)storage
: (local | session)encrypt
: (true | false)
var boomerang = BoomerangCache;
BoomerangCache.set
Set a key to a particular value or a hash object (Object or Array) under a hash key.
Arguments
key
(String)value
(String, Number, Object, Array)seconds
(Number) - optional
These values will never expire and will only be removed when you (or the browser) removes them.
boomerang;boomerang;boomerang;boomerang;
Set values with expire
After 3 seconds this will return null.
var seconds = 3;boomerang;
BoomerangCache.get
Returns the saved value for given key. If value is null or undefined it returns a default value.
Arguments
key
(String)defaultValue
(String, Number, Object, Array)
boomerang; // If value is null returns Hello World.
BoomerangCache.getAll
Returns all saved values.
boomerang;// {key1: 'value1'}, {key2: 'value2'}
BoomerangCache.length
Returns all values count.
boomeranglength;// returns 2
BoomerangCache.remove
Remove a key from storage
Arguments
key
(String)
boomerang;
BoomerangCache.clear
Empties storage
boomerangclear;