redis timer

522 views
Skip to first unread message

Santos Das

unread,
Mar 10, 2017, 6:31:32 AM3/10/17
to Redis DB
Hi All,

I am using redis cluster with hi-vip as redis client library.

I wanted to know if I can setup a timer on a particular key and get notified when the timer expires.I don't want to delete the key, but just get notified when the timer expires. Is this support available if so any limitation on this?

Regards, Santos

Salvatore Sanfilippo

unread,
Mar 10, 2017, 6:43:51 AM3/10/17
to redi...@googlegroups.com
Hello, search for keyspace notifications in the Redis web site. There
is a notification for keys expiring.
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, 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.
> For more options, visit https://groups.google.com/d/optout.



--
Salvatore 'antirez' Sanfilippo
open source developer - Redis Labs https://redislabs.com

"If a system is to have conceptual integrity, someone must control the
concepts."
— Fred Brooks, "The Mythical Man-Month", 1975.

Santos Das

unread,
Mar 10, 2017, 6:50:20 AM3/10/17
to Redis DB

I looked at this . But, there seems to be a problem


Because Redis Pub/Sub is fire and forget currently there is no way to use this feature if you application demands reliable notification of events, that is, if your Pub/Sub client disconnects, and reconnects later, all the events delivered during the time the client was disconnected are lost.


Is there a way of addressing this problem, because I am working on a long lived timer and the clients might get disconnect and reconnect inbetween.

Salvatore Sanfilippo

unread,
Mar 10, 2017, 6:54:02 AM3/10/17
to redi...@googlegroups.com
There is currently no fix for this (but there are several things in
the workings that address the same problem at different angles, like
the ability to write Redis 4.0 modules that subscribe to channels, and
the introduction of Streams planned for 4.2). If you can show the use
case why you need this (even a made up one, that maps to your original
use case), we can try suggesting other options.

Santos Das

unread,
Mar 10, 2017, 7:03:27 AM3/10/17
to Redis DB
Hi,

Think something like this:

I have a bunch of worker tasks(worker bees) communicating with redis cluster, each work bees has their own redis client.

The data structure which they work on is something like user sessions. There is no session pinning. When a request arrives, any worker can pick up, retrieve the user session, work and then write back.

But, I have a timer requirement. I want take some action on the user session if they are not active for some duration (for example days). I have a limitation of not maintaining the timer at the application level because the user request can be processed by any worker. 

So, I am thinking if this can be done at the database level. There could be a timer set for a particular entry and when the timer expires it should notify. In the mean time, if there is any request for that user session comes then the worker can reset and write back the timer with a different value.

Please advice.

Thanks, Santos



On Friday, March 10, 2017 at 5:01:32 PM UTC+5:30, Santos Das wrote:

Santos Das

unread,
Mar 13, 2017, 2:08:21 AM3/13/17
to Redis DB
Any recommendations on how to address this?


On Friday, March 10, 2017 at 5:01:32 PM UTC+5:30, Santos Das wrote:

hva...@gmail.com

unread,
Mar 13, 2017, 12:31:57 PM3/13/17
to Redis DB
It looks to me like you are hoping to use Redis as a timer in addition to a pub/sub queue,but this isn't working out.  The only suggestions that come to mind are:
  1. Investigate using Redis's event notice feature on the expiration of a regular key rather than pub/sub elements.
  2. Select something else for your timer needs.

Salvatore Sanfilippo

unread,
Mar 13, 2017, 12:46:49 PM3/13/17
to redi...@googlegroups.com
Your use case looks like one where you can use, instead, a sorted set
keyed by the time you will need to perform an action. Makes sense as a
solution?

mini duan

unread,
Feb 4, 2021, 5:28:07 AM2/4/21
to Redis DB
 I still in our project have wishes that Redis can notfiy us bees to work every 5 minutes.
1. the data in Redis is frequently updated, 1000 times per second maybe
2. but we just want to read it every 5 mins.

seems a same requirement as this discussion.

Reply all
Reply to author
Forward
0 new messages