cache-manage-js
v0.0.7
Published
js cache manage
Downloads
5
Readme
Cache-Manage
a uniform and sample js cache manage
Install
yarn add cache-manage-js
Usage
default use localStorage
strategy to save cache.
import CacheManage from 'cache-manage-js'
let cacheItem = new CacheManage(CACHE_ITEM_KEY_NAME)
cacheItem.set({ name: 100 })
cacheItem.get() // { name: 100 }
cacheItem.remove()
cacheItem.clear()
More Strategy
uniform manage your cache, support four cache strategy:
- localStorage (web api) - default
- sessionStorage (web api)
- MemoryStorage
- CookieStorage (extend js-cookie)
import CacheManage, { MemoryStorage, CookieStorage } from 'cache-manage-js'
// union manage cache for different cache strategy in a single file
let cacheItem = new CacheManage(CACHE_ITEM_KEY_NAME, localStorage)
let cacheItem = new CacheManage(CACHE_ITEM_KEY_NAME, sessionStorage)
let cacheItem = new CacheManage(CACHE_ITEM_KEY_NAME, new MemoryStorage())
let cacheItem = new CacheManage(CACHE_ITEM_KEY_NAME, new CookieStorage({ expires: 7 }))