How to get callback when key expires in REDIS

前端 未结 2 2078
伪装坚强ぢ
伪装坚强ぢ 2020-12-25 13:39

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

2条回答
  •  时光取名叫无心
    2020-12-25 14:07

    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).

提交回复
热议问题