31

I'm developing application using Bottle. In my registration form, I'm confirming email by mail with a unique key. I'm storing this key in REDIS with expiry of 4 days. If user does not confirm email within 4 days, key gets expired. for this, I want to permanently delete the user entry from my database(mongoDB).

Ofcourse I dont require continous polling to my redis server to check whether key exists or not.

Is there any way to get a callback from Redis??

OR is there any other efficient way?

Kartik Rokde
  • 3,633
  • 8
  • 27
  • 33
  • 1
    Please see [Notification of key expiration in redis python](http://stackoverflow.com/questions/23964548/notification-of-key-expiration-in-redis-python) for an up-to-date answer. – André Laszlo Nov 09 '14 at 21:03

2 Answers2

31

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

Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71
11

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

I would do it like this:

  • when user signs up, put his id into a sorted set where the score is a timestamp (now + 4 days) and member is user id.
  • have a periodic job that gets all records from that sorted set where timestamp is in the past.
  • loop through those user ids and take actions (if he didn't confirm - delete all user's data).
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367