我曾尝试使用 Azure 构建 Express 4 Web 应用程序。我在多篇文章中发现我可以将 session 存储在 Azure Redis 缓存中。但是,我应该如何将我的 Web 应用程序连接到 Redis 缓存?
var session = require('express-session');
var redis = require('redis');
var RedisStore = require('connect-redis')(session);
var client = redis.createClient(6380, 'MyHost', { auth_pass: 'MyPass', tls: { servername: 'MyHostName' } });
app.use(session({
secret: 'keyboard cat',
key: 'sid',
resave: false,
saveUninitialized: false,
store: new RedisStore(client);
}));
但是当我运行该应用程序时它会返回一个错误。说 TypeError: this.client.unref 不是函数
我该如何解决这个问题?谢谢!
最佳答案
您可能在 RedisStore
构造函数中犯了错误。
更改以下代码行 store: new RedisStore(client);
如下:
store: new RedisStore({client: client});
关于node.js - 使用 Azure Redis 缓存存储 Node JS 快速 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43157810/