fie-cache
fie 数据缓存模块, 可以用来存储用户常用数据,支持有效期设置
Installation
npm install fie-cache --save
API
get(key)
获取缓存内容,如果不存在或已过期则返回 null
- key
{string}
缓存的键值 - return:
{mix}
缓存内容
set(key, value, options)
设置缓存
- key
{string}
缓存键值 - value
{mix}
缓存内容,可以为字符串,数字或json对象 - options
{object}
- options.expires
{number}
缓存时间,毫秒为单位,如: 1小时 => 3600000
clear
清除所有缓存
例子
const cache = ; // 将abc这个key的对象写入fie缓存文件。(该缓存文件一般在 ~/.fie/fie.cache.json 中)cache; // 从fie缓存中获取 abc 这个key的内容。cache;// => return { data : 1 } //清空fie的缓存内容cacheclear;
Support
使用过程中遇到的相关问题,及BUG反馈,可联系: hugohua baofen14787@gmail.com ,也可直接提issues