【问题标题】:Jedis pubsub >> "redis-cli config set notify-keyspace-events Ex " doesn't work from conf fileJedis pubsub >> “redis-cli config set notify-keyspace-events Ex”在 conf 文件中不起作用
【发布时间】:2018-01-29 17:27:15
【问题描述】:

我们已经实现了 Jedis.expire 事件,并且倾向于使用 KeyExpiredListener 类的 onPMessage 方法来捕捉。

     KeyExpiredListener extends JedisPubSub {
......
public void onPMessage(String pattern, String channel, String message) {....}
....
}

完美运行 当我们在 Redis cli 中设置 .the notify 事件时。

redis-cli config set notify-keyspace-events Ex

但正如预期的那样,如果我们重新启动redis服务器,事件监听器会切换回默认值,不捕获任何事件,这与设置相同。

redis-cli config set notify-keyspace-events ""

所以我们尝试在 redis.conf 文件中设置它,但它不起作用,即没有捕获任何事件。

总结一下,如果我们在cli中设置

config set notify-keyspace-events Ex

它可以工作,如果我们在 conf 文件 (redis.conf) 中设置

notify-keyspace-events Ex

它不起作用。

谢谢!

【问题讨论】:

    标签: redis event-listener jedis


    【解决方案1】:

    使用 conf dir 启动 redis -

    ./redis-server <path of redis.conf> &
    

    现在(notify-keyspace-events Ex)将起作用,这在 redis.conf 中提到。

    【讨论】:

    • 这个redis.conf放在哪里?我在我的机器上搜索过,但找不到。请帮忙..
    猜你喜欢
    • 2015-09-15
    • 2016-07-10
    • 1970-01-01
    • 1970-01-01
    • 2020-07-27
    • 2014-04-18
    • 2021-04-28
    • 1970-01-01
    • 2022-09-23
    相关资源
    最近更新 更多