1.0.2 • Published 1 year ago
egg-cache-manage v1.0.2
egg-cache
Egg.js 缓存插件,支持内存、文件、Redis 缓存
安装
npm i egg-cache-manage --save
依赖说明
依赖的 egg 版本
egg 3.x | egg 2.x | egg 1.x |
---|---|---|
😁 | 😁 | ❌ |
依赖的插件
开启插件
// {app_root}/config/plugin.js
exports.cache = {
enable: true,
package: 'egg-cache-manage',
};
配置
// {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')
})