koa-redis
koa-redis is a mongodb middleware for koa@2, using redis and bluebird, support connection pool, inspired by koa-mongo middleware https://github.com/nswbmw/koa-mongo. It's written in Typescript and support koa2 async / await syntax.
Usage
import koaRedis from 'dt-koa-redis';
app.use(koaRedis({
host: '127.0.0.1',
port: 6379,
maxConnections: 100,
minConnections: 1,
}));
Example
'use strict';
import koa from 'koa';
import koaRedis from 'dt-koa-redis';
const app = new koa();
app.use(koaRedis());
app.use(async (ctx, next) => {
try {
const data = await ctx.redis.getAsync('test');
const write = 'testing';
await ctx.redis.setAsync('test_key',write);
} catch(err) {
debug(err);
}
});
app.listen(3000, () => {
console.log('listening on port 3000');
});
License
MIT