1.0.1 • Published 2 years ago
egg-psyduck-cache v1.0.1
egg-psyduck-cache
Egg plugin for cache
安装
$ npm i egg-psyduck-cache --save支持的 egg 版本
| egg 3.x | egg 2.x | egg 1.x |
|---|---|---|
| 😁 | 😁 | ❌ |
开启插件
// {app_root}/config/plugin.js
exports.cache = {
enable: true,
package: "egg-psyduck-cache",
};配置
// {app_root}/config/config.default.js
config.cache = {
ttl: 600, // 缓存时长(秒)
fs: {
path: path.join(appInfo.baseDir, "cache"),
subdirs: false,
zip: false,
},
redis: null,
};示例
const result = await this.app.cache.fs.wrap("key", async () => {
return await this.app.mysql.select("sql");
});