How to get a callback when a key expires in REDIS

I am developing an application using Bottle. In my registration form, I confirm email by email with a unique key. I save this key in REDIS after 4 days. If the user does not confirm the email within 4 days, the key has expired. for this, I want to permanently delete the user record from my database (mongoDB).

Of course, I do not require continuous polling of my redis server to check for a key or not.

Is there a way to get a callback from Redis?

OR is there any other effective way?

+8
python bottle redis
source share
2 answers

This feature, implemented in Redis 2.8, is read here http://redis.io/topics/notifications

+11
source share

There are no such callbacks in redis (not what I know).

I would do it like this:

  • when the user subscribes, put your identifier in a sorted set , where the grade is the timestamp (now + 4 days) and the member is the user id.
  • have a periodic job that gets all the records from this sorted set, where the timestamp is in the past.
  • go through these user IDs and take action (if he did not confirm, delete all user data).
+9
source share

All Articles