1

I am using Jedis 2.9.0 version and i followed

Redis Key expire notification with Jedis

but onPMessage method in Listener is not called when redis key expires.

in Subscriber I used

 jedis.psubscribe(new KeyExpiredListener(), "*"); 

When I am running server

 jedis.set("notify", "test"); jedis.expire("notify", 10); 

but After 10 seconds Redis key expired but onPMessage did not trigger.

1
  • have you tried to replace * with the specific keyspace channel? Like "__key*__:* Commented Dec 19, 2016 at 19:45

1 Answer 1

4

Expire keyspace notification isn't fired just when a key has expired but (taken from the docs):

  • When the key is accessed by a command and is found to be expired.
  • Via a background system that looks for expired keys in background, incrementally, in order to be able to also collect keys that are never accessed.

In addition, maybe you've not enabled keyspace notifications:

By default keyspace events notifications are disabled because while not very sensible the feature uses some CPU power. Notifications are enabled using the notify-keyspace-events of redis.conf or via the CONFIG SET.

Some docs page will explain you how to enable them.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Matías Fidemraizer. I just added $AKE for notify-keyspace-events and it worked like a charm.
@GouravSoni You're welcome! I'm glad you could solve your problem! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.