simple-storage-mp

1.0.2 • Public • Published

simple-storage-mp

一个微信小程序缓存管理工具

import storage from "simple-storage-mp";
 
/**
 * 设置缓存,支持过期时间
 * @param {*} key 
 * @param {*} data 
 * @param {*} expire 
 *  过期时间点 "2019-1-14 21:38:00" | 过期时长,1天2小时3分钟4s后过期 "1d2h3m4s" | 过期时长'1.2.3.4' | 多少个自然日过期,1n为当天23:59:59过期 '1n'
 */
storage.set(key, data, expire);
 
// 获取缓存
storage.get(key);
 
// 一处指定缓存,key 未穿值为清楚所有缓存
storage.remove(key);
 
// 清楚过期缓存
storage.clear();
 
// 监听缓存改变
storage.onChange(key, fn)
 
// 移除缓存监听器
storage.removeListener(key, fn)

Readme

Keywords

Package Sidebar

Install

npm i simple-storage-mp

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.91 kB

Total Files

3

Last publish

Collaborators

  • fanx