egg-lru
v1.0.1
Published
egg lru-cache plugin
Downloads
1,408
Readme
egg-lru
egg lru-cache plugin
Install
$ npm i egg-lru --save
Configuration
// {app_root}/config/plugin.js
exports.lru = {
client: {
enable: true,
package: 'egg-lru',
},
};
see config/config.default.js for more detail.
Simple lru instance
// {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');
Multiple lru instance
// {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');
see config/config.default.js for more detail.
Questions & Suggestions
Please open an issue here.