Cache data based on localstorage in browser, expire property is provided.
npm i cachest
import cachest from 'cachest';
or
const cachest = require('cachest');
Assign value
to key
with expire time,if expire
is not defined, keep the value until to be removed.
Params
key
{String}: The key of the property to save.value
{any}: The content to save.expire
{Number}: Expire time, ms as unit
Return the value of key
.
Params
key
{String}: The key of the property to get.- return {*}
Remove the value of key
.
Params
key
{String}: The key of the property to remove.
Clear all saved value.
Get the keys not expired.
- return {Array}
return {Number}
Length of keys.
Check if the key
is expired, return true if key is not existed.
Params
key
{String}: The key of the property to check.- return {Boolean}
Copyright © 2018, ZiQiangWang. Released under the MIT License.