1.0.2 • Published 1 year ago

egg-cache-manage v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

egg-cache

Egg.js 缓存插件,支持内存、文件、Redis 缓存

安装

npm i egg-cache-manage --save

依赖说明

依赖的 egg 版本

egg 3.xegg 2.xegg 1.x
😁😁

依赖的插件

cache-manager

cache-manager-fs

cache-manager-ioredis

开启插件

// {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')
})

查看更多项目

License

MIT