Storage with expiration time based on localStorage
node6 or higher
$ yarn add storecache.js
# or
$ npm i -S storecache.js
const StoreCache = require('storecache.js');
const store = new StoreCache();
store.set('obj', { a: 1, b: { c: 'str' } });
console.log(store.get('obj')); // { a: 1, b: { c: 'str' } }
store.set('expired', { id: 123 }, 3); // expire after 3 seconds
console.log(store.get('expired')); // { id: 123 }
setTimeout(() => {
console.log(store.get('expired')); // null
}, 4000);
Type: Object
Type: string
Default: ''
Type: Storage
Default: localStorage
Type: string
Type: any
Type: number
Default: 0
Type: string
Type: string
Type: number
Default: 0
Type: string