【问题标题】:Jedis keyspace notification event for "set" not working“set”的 Jedis 键空间通知事件不起作用
【发布时间】:2021-04-28 18:22:55
【问题描述】:

所以我尝试在 redis 上设置一些值时实现基本侦听器,但是当我设置一些值时,什么都没有发生,只有过期事件被调用。

订阅者

public class Subscriber {

    private static JedisPool pool;

    public static void main(String[] args) {
        JedisPool pool = new JedisPool("localhost");

        Jedis jedis = pool.getResource();
        jedis.psubscribe(new SubListener(), "*");
    }

}

子监听器

public class SubListener extends JedisPubSub {

    @Override
    public void onPSubscribe(String pattern, int subscribedChannels) {
        System.out.println("onPSubscribe "
                + pattern + " " + subscribedChannels);
    }

    @Override
    public void onPMessage(String pattern, String channel, String message) {

        System.out
                .println("onPMessage pattern "
                        + pattern + " " + channel + " " + message);
    }


}

编辑:我发现我将配置中的 notify-keyspace-events 设置为 Ex。现在我将其设置为 KEA 以调用每个事件,但我应该使用什么来仅在集合上调用事件

【问题讨论】:

    标签: java redis jedis


    【解决方案1】:

    要仅在现场调用事件,请将配置设置为 Ks

    【讨论】:

      猜你喜欢
      • 2019-03-13
      • 1970-01-01
      • 2017-05-04
      • 2014-08-18
      • 2013-06-06
      • 1970-01-01
      • 2020-01-18
      • 2020-07-26
      • 1970-01-01
      相关资源
      最近更新 更多