cache-manage-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

Cache-Manage

a uniform and sample js cache manage

NPM Version Dependencies NPM Download

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:

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 }))

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i cache-manage-js

Weekly Downloads

8

Version

0.0.7

License

MIT

Unpacked Size

180 kB

Total Files

13

Last publish

Collaborators

  • springleo