A library of cache based on localStorage that supports expired storage.
<script src="https://unpkg.com/expired-localstorage@1.0.3/index.js"></script>
npm install expired-localstorage --save-dev
const LS = require('expired-localstorage')
//get data
LS.get('test');
//set data with expires time
LS.set('test', 123, 60000);
//remove data
LS.remove('test');
//clear all data
LS.clear();
LS.get(key)
- {String} key -> key name.(required)
LS.set(key, value, time)
- {String} key -> key name.(required)
- {Any} value -> data value.(required)
- {Number} time -> expires time, unit is ms, such as passing 60000, that means 1 minute. No value, no expiration.(optional)
LS.remove(key)
- {String} key -> key name.(required)
LS.clear()
expired-localstorage is MIT licensed.