Falko
Falko

Reputation: 1038

Redis Keyspace Notifications and Key Expiration

The documentation about Redis Keyspace Notifications http://redis.io/topics/notifications says near its end, that a key with timeout is removed from the database

Question: Is it enough to retrieve the very key, e.g. via KEYS *, or do I have to access the content the key refers to?

Background: The second process I omitted (the .. above) is a probabilistic process, and the real deletion of an expired key may be delayed, and thus the delivery of the EXPIRED event. I want to ensure the notification is given to a subscriber, so just accessing the keys would be easiest.

Upvotes: 1

Views: 1883

Answers (1)

Nik
Nik

Reputation: 1334

Redis implements a logic of periodic checking of keys for expiry and picks a number (100) of keys and checks them for their expiry.

What I understand is that your concerned with the fact that with above logic there would exist events which belong to expired keys which have not been deleted.

To avoid such a case checking the keys just for existence would delete them. Cost of REDIS calls should be kept in mind and hence a LUA script or bulk command should be designed which is invoked periodically and iterates a list of keys and run EXISTS command on them and cause automatic delete if they are expired.

To test this you would need a large dataset.

Upvotes: 1

Related Questions