1.2.4 • Published 1 year ago
gm-cache v1.2.4
内存缓存器
支持自动过期(并回调)
安装
npm install gm-cache --save
使用
import GmCache from "gm-cache"
const cache = new GmCache()
/**
* 无过期时间
*/
cache.set("name","ming")
/**
* 带过期时间
*/
cache.set("name","ming",3000,function(event,value){
console.log('该数据过期了')
})
/**
* 取回数据,无数据或已过期,返回 undefined
*/
cache.get("name")
/**
* 移除缓存,
*/
cache.remove('name')
/**
* 修改缓存时间
*/
cache.updateExp('name',5000)
/**
* 修改缓存为永久
*/
cache.updateExp('name',0)