Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get callback when key expires in REDIS

Tags:

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?

like image 602
Kartik Rokde Avatar asked Nov 01 '12 09:11

Kartik Rokde


People also ask

How can I update a Redis value without affecting the remaining TTL?

According to Redis documentation, the SET command removes the TTL because the key is overwritten. However you can use the EVAL command to evaluate a Lua script to do it automatically for you.

What happens when Redis key expires?

After the timeout has expired, the key will automatically be deleted. A key with an associated timeout is often said to be volatile in Redis terminology. The timeout will only be cleared by commands that delete or overwrite the contents of the key, including DEL , SET , GETSET and all the *STORE commands.

What is Keyspace in Redis?

Redis keyspace notifications allow you to subscribe to PubSub channels. Through the channel, clients receive published events when a Redis command or data alteration occurs. These notifications are useful when an application must respond to changes that occur to the value stored in a particular key or keys.


1 Answers

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

like image 107
Nikita Koksharov Avatar answered Oct 27 '22 04:10

Nikita Koksharov