How to know about expired keys

50 views
Skip to first unread message

Francesco Montorsi

unread,
Jun 6, 2019, 7:08:19 AM6/6/19
to Redis DB
Hi all,
I'm using a Redis cluster to store around 100M keys; all of them have an EXPIRE set to like 12hours. This is just a safety mechanism in case of crash of my client app, since the client app should be able to DEL all keys it SETs.
However, due to a bug in my client app some keys are not cleaned up properly (with DEL command) and they end up expiring inside Redis (I monitor that looking at the "info" command output).

My question is: is there some mechanism I can use to know which keys are expired by Redis due to their TTL reaching zero?

Thanks,
Francesco


Ketan Parmar

unread,
Jun 6, 2019, 7:22:55 AM6/6/19
to Redis DB
I don't think Redis has a way to identify Key is expire by TTL or DEL command

But I suggest you should use UNLINK command because DEL is blocking command and UNLINK is non-blocking

Francesco

unread,
Jun 6, 2019, 8:27:42 AM6/6/19
to redi...@googlegroups.com
I didn't know about UNLINK, thanks for the suggestion!

Regarding the key expiral problem: there is no way to enable detailed log to know about that?

Thanks,
Francesco

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/Wm-5Q80NvFM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/9903fe97-8455-4ca1-934e-a2497d65856a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ketan Parmar

unread,
Jun 7, 2019, 1:20:39 AM6/7/19
to Redis DB
For key expired problem, You can monitor keyspace, Redis has a feature of Notifications, But in order to use notification, you need to implement Redis Pub/Sub. 

Check this link for more detail., https://redis.io/topics/notifications



On Thursday, 6 June 2019 17:57:42 UTC+5:30, Francesco wrote:
I didn't know about UNLINK, thanks for the suggestion!

Regarding the key expiral problem: there is no way to enable detailed log to know about that?

Thanks,
Francesco

Il giorno gio 6 giu 2019 alle ore 13:23 Ketan Parmar <ketanb...@gmail.com> ha scritto:
I don't think Redis has a way to identify Key is expire by TTL or DEL command

But I suggest you should use UNLINK command because DEL is blocking command and UNLINK is non-blocking

On Thursday, 6 June 2019 16:38:19 UTC+5:30, Francesco Montorsi wrote:
Hi all,
I'm using a Redis cluster to store around 100M keys; all of them have an EXPIRE set to like 12hours. This is just a safety mechanism in case of crash of my client app, since the client app should be able to DEL all keys it SETs.
However, due to a bug in my client app some keys are not cleaned up properly (with DEL command) and they end up expiring inside Redis (I monitor that looking at the "info" command output).

My question is: is there some mechanism I can use to know which keys are expired by Redis due to their TTL reaching zero?

Thanks,
Francesco


--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/Wm-5Q80NvFM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages