fie-cache

3.1.4 • Public • Published

fie-cache

NPM version David deps Known Vulnerabilities npm download

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 = require('fie-cache');
 
// 将abc这个key的对象写入fie缓存文件。(该缓存文件一般在 ~/.fie/fie.cache.json 中)
cache.set('abc',{ data : 1 });
 
// 从fie缓存中获取 abc 这个key的内容。
cache.get('abc');
// => return { data : 1 }
 
//清空fie的缓存内容
cache.clear();
 

Support

使用过程中遇到的相关问题,及BUG反馈,可联系: hugohua baofen14787@gmail.com ,也可直接提issues

License

GNU GPLv3

Readme

Keywords

Package Sidebar

Install

npm i fie-cache

Weekly Downloads

20

Version

3.1.4

License

none

Unpacked Size

39.7 kB

Total Files

4

Last publish

Collaborators

  • hugohua
  • xiaocong.hxc
  • zernmal
  • zhouxiong03
  • akirakai
  • mark-ck
  • channing_hyl