Skip to content

Latest commit

 

History

History
115 lines (93 loc) · 2.62 KB

README.zh_CN.md

File metadata and controls

115 lines (93 loc) · 2.62 KB

egg-lru

NPM version appveyor build status build status Test coverage Known Vulnerabilities npm download

egg 框架的 lru cache 插件

依赖说明

依赖的 egg 版本

egg-lru 版本 egg 1.x
1.x 😁
0.x

开启插件

// config/plugin.js
exports.lru = {
  enable: true,
  package: 'egg-lru',
};

配置插件

单实例

// {app_root}/config/config.default.js
exports.lru = {
  client: {
    // all lru cache config available here
    max: 1000,
    maxAge: 1000 * 60 * 60, // 60 min cache
  },
  // load into app, default is open
  app: true,
  // load into agent, default is close
  agent: false,
};

Usage:

// you can access to simple lru instance by using app.lru
app.lru.set('test', 'aaa') ;
app.lru.get('test');

多实例

// {app_root}/config/config.default.js
exports.lru = {
  clients: {
    long: {
      max: 1000,
      maxAge: 1000 * 60 * 60, // 60 min cache
    },
    moment: {
      max: 1000,
      maxAge: 1000, // 1 second cache
    },
  },
  // load into app, default is open
  app: true,
  // load into agent, default is close
  agent: false,
};

Usage:

const long = app.lru.get('long');
long.set('test', 'aaa') ;
long.get('test');

const moment = app.lru.get('moment');
moment.set('test', 'aaa') ;
moment.get('test');

详细配置

请到 config/config.default.js 查看详细配置项说明。

单元测试

提问交流

请到 egg issues 异步交流。

License

MIT