egg-catbox
Catbox plugin for egg framework.
Install
$ npm i egg-catbox --save
Usage
exports.catbox = {
enable: true,
package: 'egg-catbox',
};
Configuration
exports.catbox = {
};
see config/config.default.js for more detail.
Example
const Service = require('egg').Service;
const segment = 'segment';
class UserService extends Service {
async save(user, ttl) {
const id = 'id';
const key = { id, segment };
await app.catbox.set(key, user, ttl);
}
async load(id) {
const key = { id, segment };
const result = await app.catbox.get(key);
return result ? result.item : null;
}
async drop(id) {
const key = { id, segment };
await app.catbox.drop(key);
}
}
module.exports = UserService;
Questions & Suggestions
Please open an issue here.
License
MIT