Skip to content

nswbmw/koa-redis-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-redis-pool

koa-redis-pool is a redis middleware for koa, support connection pool.

Install

npm i koa-redis-pool --save

Usage

app.use(redisPool({
  host: 'localhost',
  port: 6379,
  max: 100,
  min: 1,
  timeout: 30000,
  log: false,
  db: 0,
  ... // https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
}));

or

app.use(redisPool({
  url: 'localhost:6379', //  if exist, ignore `host`, `port`, `password` and `db`.
  ...
}));

or

app.use(redisPool('localhost:6379'));

Example

'use strict';

var koa = require('koa');
var redisPool = require('./');

var app = koa();

app.use(redisPool());

app.use(function* (next) {
  yield this.redis.set('name', 'nswbmw');
  yield* next;
  this.body = yield this.redis.get('name');
});

app.listen(3000);

License

MIT

About

Redis middleware for koa, support connection pool.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published