【问题标题】:Redis Config Set with Node jSRedis 配置集与 Node jS
【发布时间】:2020-01-29 15:49:16
【问题描述】:

团队,

我正在尝试使用 NODE js 应用程序在运行时设置 redis 的配置,如下所示。

让 setConfig = await this.cacheConnection.config("set", "notify-keyspace-events", "Ex"); let setConfig = await this.cacheConnection.config("SET", "notify-keyspace-events", "Ex");

上面的代码总是向我返回 false。

我在我的应用程序中使用 redis 节点模块。所有其他命令,如 getAsync、SetAsync 对我来说都很好。 让结果 = 等待 this.cacheConnection.getAsync("keyname");

这里的任何建议都会很棒。

【问题讨论】:

标签: node.js redis


【解决方案1】:

请在redis客户端准备好服务命令后设置配置

const redisClient = this.cacheConnection;
redisClient.on("ready", function(err) {
    if(!err) redisClient.config("SET", "notify-keyspace-events", "Ex");
});

【讨论】:

  • 感谢您的回复。我通过下面的代码让它工作。 this.cacheConnection.configAsync("SET", "notify-keyspace-events", "KExe$");
【解决方案2】:

this.cacheConnection.configAsync("SET", "notify-keyspace-events", "KExe$");

【讨论】:

    猜你喜欢
    • 2019-10-15
    • 2023-04-09
    • 1970-01-01
    • 2016-05-22
    • 2016-07-20
    • 2020-10-26
    • 2016-05-25
    • 2022-11-13
    • 1970-01-01
    相关资源
    最近更新 更多