https://github.com/mohamedfasil/browserstorage-ttl
Localstorage with time to live / expiry, if expiry is zero uses SessionStorage
https://github.com/mohamedfasil/browserstorage-ttl
browser es6 javascript nodejs npm npm-package webpack
Last synced: 3 months ago
JSON representation
Localstorage with time to live / expiry, if expiry is zero uses SessionStorage
- Host: GitHub
- URL: https://github.com/mohamedfasil/browserstorage-ttl
- Owner: mohamedfasil
- Created: 2018-08-07T05:17:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-29T00:51:14.000Z (about 3 years ago)
- Last Synced: 2025-02-18T20:44:46.784Z (over 1 year ago)
- Topics: browser, es6, javascript, nodejs, npm, npm-package, webpack
- Language: JavaScript
- Size: 813 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# browserstorage-ttl
[](//npmjs.com/package/browserstorage-ttl)
Localstorage with time to live / expiry, if expiry is zero uses SessionStorage
# Usage
`npm install browserstorage-ttl`
In your file
```javascript
import Storage from 'browserstorage-ttl';
Storage.set('key', 'value', 30); // 30 minutes as ttl
const k = Storage.get('key');
console.log(k); // value
Storage.set('anotherkey', 'anothervalue', 0); // 0 minutes as ttl, will use sessionStorage
const t = Storage.get('anotherkey');
console.log(t); // anothervalue
```