Redis商店没有get方法?
http://senchalabs.github.com/connect/middleware-session.html提及….“每个会话商店必须实施以下方法:”
- 获得(SID,callback)
- .set(sid,session,callback)
- .destroy(sid,callback)
我正在使用下面的代码来尝试获取SID:
节点JavaScript,使用Socket.io连接
io.sockets.on('connection', function(socket) { var sid = socket.id; if (sid) { sessionStore.get(sid, function (error, session) { console.log("Connect Sid: " + sid); }); } });
而且我收到以下错误:
TypeError: Object function RedisStore(options) { options = options || {}; Store.call(this, options); this.client = new redis.createClient(options.port || options.socket, options.host, options); if (options.pass) { this.client.auth(options.pass, function(err){ if (err) throw err; }); } if (options.db) { var self = this; self.client.select(options.db); self.client.on("connect", function() { self.client.send_anyways = true; self.client.select(options.db); self.client.send_anyways = false; }); } } has no method 'get'
包含redis
//Redis store for storage var sessionStore = require('connect-redis')(express); ... ... app.use(express.session({secret: "keyboard cat",store: new sessionStore}));
看起来你忘了在实例化商店时inputnew
的名字?
取自: https : //github.com/visionmedia/connect-redis
This means express users may do the following, since express.session.Store points to the connect.session.Store function:
这似乎工作:
express.session.Store(sid, function(){ console.log("Connect Sid: " + sid); });
我这样做:
var RedisStore = require('connect-redis')(express); var sessionStore = new RedisStore; ... app.use(express.session({secret: "keyboard cat",store: sessionStore}));
这样,如果需要,可以使用来自socket.io代码的sessionStore对象来引用会话数据。
- 网站使用前端的骨干和后端的nodejs
- 在nodejs中,如何停止FOR循环直到mongodb调用返回
- Memory.orem.MemoryStore不返回会话?
- Node – Express + Ember + Socket MVC开发项目文件结构
- Nodejs – 从MongoDB中检查空对象并parsing它
- 如何使用express / mongoose和客户端JS将HTML类发布到mongoDB集合中?
- Nodejs / Express – 启动我的应用程序:express.createServer()已弃用
- 护照通过Google reCaptcha进行身份validation
- heroku的节点:! Heroku推送被拒绝,没有检测到雪松支持的应用程序