我们已经实现了 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
它不起作用。
谢谢!
最佳答案
使用 conf 目录启动 redis -
./redis-server <path of redis.conf> &
现在 (notify-keyspace-events Ex) 将起作用,这在 redis.conf 中提到。
关于redis - Jedis pubsub >> "redis-cli config set notify-keyspace-events Ex "在 conf 文件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47868050/