Skip to content

JS module to save data to localstorage with time to live. Data will expire after set time.

License

Notifications You must be signed in to change notification settings

neolikotsi/localstorage-ttl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

localstorage-ttl

JS module to save data to localstorage with time to live. Data will expire after set time. On npm: https://www.npmjs.com/package/localstorage-ttl

Install:

npm install localstorage-ttl --save

Usage:

const ls = require('localstorage-ttl');

ls.set(variable, value, [ttl_ms]);
ls.get(variable);

to remove, just use plain js. It works in all usable browsers. http://caniuse.com/#search=localstorage

localStorage.removeItem(variable);
  • ttl_ms = time to live time in ms.

if ttl_ms is not set it will be without expire date and will be there till user deletes or your other js deletes it.

About

JS module to save data to localstorage with time to live. Data will expire after set time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%