koa redis 链接

koa 是新一代框架

npm install koa-redis

 

代码如下

var koa = require('koa');

var http = require('http');

var session = require('koa-sess');

var redisStore = require('koa-redis');



var app = koa();



app.name = 'koa-session-test';

app.keys = ['keys', 'keykeys'];



app.use(session({

  store: redisStore()

}));



app.use(function *() {

  this.session.name = 'koa-redis';

  this.body = this.session.name;

});



var app = module.exports = http.createServer(app.callback());

app.listen(8080);

Options

 * {Object} client    redis client
* {String} host      redis connect host (without options.client)
* {Number} port      redis connect port (without options.client)
* {String} socket    redis connect socket (without options.client)
* {String} db        redis db
* {String} pass      redis password

你可能感兴趣的:(redis)