我正在 Node 中使用 Express-Session 设置 Redis。
我收到此错误:
if (options.unref) this.client.unref();
this.client.unref is not a function
这个错误指向我的node_modules中的redis-connect库。
这是我在 Node 中的基本代码:
var express = require('express');
var session = require('express-session');
var redis = require('redis');
var redisStore = require('connect-redis')(session);
那么,
var client = redis.createClient();
var sessionStore = new redisStore(client);
app.use(session({
store: sessionStore,
secret: 'a stringy string thing',
}))
如何解决该错误? 谢谢!
最佳答案
创建Redis存储实例的正确方法:
var sessionStore = new redisStore({ client : client });
换句话说,redisStore
需要一个选项对象作为参数传递,而不是直接传递 Redis 客户端实例。
关于node.js - connect-redis client.unref 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43875968/