koa-2-ioredis
v1.1.1
Published
ioredis midleware for koa 2 application
Downloads
8
Maintainers
Readme
Koa.js 2 ioredis middleware
ioredis midleware for koa 2 application
How to install
npm i -S koa-2-ioredis
How to use
Config
config/default.json
{
"redis": {
"host": "127.0.0.1",
"port": 6379
}
}
Middleware
app.js:
const Koa = require('koa');
const app = new Koa();
const ioredis = require('koa-2-ioredis');
app.use(ioredis());
app.use(async (ctx, next) => {
await ctx.redis.set(key, value);
const data = await ctx.redis.get(key);
});
In module
const redis = require('koa-2-ioredis/redis');
redis.set('test', 'test');
Debug
DEBUG=koa2:ioredis npm start