browser-caching

1.0.3 • Public • Published

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:

  1. key for storing data with the key

  2. value Any type of data you need to store.

Note: No need to make stringify of array or object.

  1. expireInMinute (optional). You can pass minutes for caching data till the minutes. If you do not pass expire, data will store like default localStorage.

getBrowserCache():

This function will get your data as like as you store if expire is not over. If expire over then return null.

Package Sidebar

Install

npm i browser-caching

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

2.79 kB

Total Files

3

Last publish

Collaborators

  • emrancu