tank-cache基于 Node.js 的缓存插件
tank-cache是一套基于nodejs的文件缓存插件,易于集成,Api可满足大部分项目的使用需求,文件存储位置配置,可通过npm进行安装
- 安装
npm install --save tank-cache
- 使用
//import tank-cache
const FileCache = require("tank-cache/index")
//default savePath process.cwd()+".runtime/cache.json"
const cache = new FileCache()
//use savePath
const cache = new FileCache(".runtime/mycache.json")
//store
cache.Store("tank", "man", 1)
// or
cache.Set("tank", "man", 1)
- Api 列表
constructor(saveFilePath: any);
Has(key: any): any;
Get(key: any, defaultVal?: any): string | null;
Forever(key: any, val: any): void;
Forget(key: any): null | any;
Pull(key: any): string;
Store(key: any, val?: any, ttl?: number): any;
Set(key: any, val?: any, ttl?: number): any;
Add(key: any, val?: any, ttl?: number): boolean;
Flush(): void;
评论