Jedis keyspace notification event for "set" not working

Viewed 286

So im trying to implement basic listener for when some value is set on redis, but when i set some value nothing happens and only expiry event gets called.

Subscriber

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(), "*");
    }

}

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);
    }


}

Edit: i found out that i had the notify-keyspace-events in config set to Ex. Now i set it to KEA to call on every event but what should i use to only call the event on set

1 Answers

To only call the event on set, set the config to Ks

Related