首页 > 其他 > 详细

koa redis 链接

时间:2014-07-18 14:37:16      阅读:549      评论:0      收藏:0      [点我收藏+]

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

koa redis 链接,布布扣,bubuko.com

koa redis 链接

原文:http://www.cnblogs.com/aibo/p/3852516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!