码迷,mamicode.com
首页 > 其他好文 > 详细

koa redis 链接

时间:2014-07-18 10:20:48      阅读:488      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   

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 链接

标签:style   blog   http   color   os   io   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!