browser-caching
v1.0.3
Published
Set & get data to localStorage with expire. If you work with local storage for caching data to client side, you feel to set expire date for data. This small library will help you to solve the problem.
Downloads
69
Maintainers
Readme
BrowserCaching with Localstorage
If you work with local storage for caching data to client side, you feel to set expire date for data. This small library will help you to solve your problem.
Install
npm i browser-caching
Example:
import { setLocalStorage, getLocalStorage } from "browser-caching";
setLocalStorage('flowgiri', 'flowgiri.com', 5)
setBrowserCache():
This function has three parameters:
key
for storing data with the keyvalue
Any type of data you need to store.
Note: No need to make stringify of array or object.
expireInMinute
(optional). You can pass minutes for caching data till the minutes. If you do not pass expire, data will store like defaultlocalStorage
.
getBrowserCache():
This function will get your data as like as you store if expire is not over. If expire over then return null.