1.0.5 • Published 6 years ago

web-cached-persistence v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

web-cached-persistence

Tools for cookie and local storage cache.

Why?

In some scenerio, we need to read local storage or cookie repeatedly. Sometimes, it is not necessary and a waste of system resource. This lib help to use Cookie and local storage with cache.

install and import

npm install web-cached-persistence
yarn add web-cached-persistence


import { CachedCookie, CachedStorage } from 'web-cached-persistence'

CachedStorage

const CachedTest = new CachedStorage('test') // create a cached local storage whose key is 'test'
CachedTest.set('123') // set local storage 'test' value to '123'.
CachedTest.get() // return '123'
CachedTest.remove() // remove the local storage record

CachedCookie

const CachedToken = new CachedCookie('token') // create a cached cookie
CachedToken.get() // return the cookie value and cache it
CachedToken.clear() // make the cookie calue to ''
CachedToken.renew() // refresh the cache and read value from cache, then return the new value.
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago