@jhowrf/local-storage-cache
v1.0.2
Published
lib for cache data on local storage
Downloads
7
Maintainers
Readme
Localstorage Cache
This is a package to use localstorage cache.
How to use
Install the package
npm i @jhowrf/local-storage-cache
// import the package
import { localStorageCache } from '@jhowrf/local-storage-cache/src/localStorageCache'
// to get a item from localstorage, only the key is required
const item = localStorageCache.getStorageItem("cache-key")
// to set a item in localstorage, the key and the item are required.
// The third parameter is the time in milliseconds that the item will be stored in localstorage, the default value is 31536000000 (1 year)
localStorageCache.setStorageItem("cache-key", item, 31536000000)
// to remove a item from localstorage
localStorageCache.removeStorageItems("cache-key", "cache-key-2")