【问题标题】:Store Node JS express sessions using Azure Redis Cache使用 Azure Redis 缓存存储节点 JS 快速会话
【发布时间】:2017-04-02 11:18:38
【问题描述】:

我尝试使用 Azure 构建 Express 4 Web 应用程序。我在几篇文章中发现可以将会话存储在 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 不是函数

我该如何解决这个问题?谢谢!

【问题讨论】:

    标签: node.js azure express redis


    【解决方案1】:

    你可能在RedisStore构造函数中犯了一个错误。

    将下面这行代码store: new RedisStore(client);改成如下:

    store: new RedisStore({client: client});
    

    【讨论】:

      猜你喜欢
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 2016-07-06
      • 2019-05-13
      • 2014-05-03
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      相关资源
      最近更新 更多