How to get all keys close to expire

173 views
Skip to first unread message

Dan

unread,
Nov 9, 2017, 2:13:24 AM11/9/17
to Redis DB
Hi All

I want to make the key live longer if some condition met.

What I think is if I can query all the keys close to expire (like 10 minutes to expire), then I can do the query-check-activate intervally.
I seached but not found any clue, if you know how to achieve it, please tell me.
Any help will be highly appreciated!

Itamar Haber

unread,
Nov 9, 2017, 6:28:08 AM11/9/17
to Redis DB
Hello Dan,

Querying for keys based on their expiration time is not supported by Redis at the moment.

You can work around this by not using Redis' built-in expiration and managing it yourself, e.g. by using a Sorted Set to track expiration times and implementing passive and active expiration in your application.

Cheers,

--
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+unsubscribe@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.



--

Itamar Haber | Chief OSS Education Officer
Redis Labs ~/redis

Mobile: +972 (54) 567 9692
Twitter: @itamarhaber
Skype: itamar.haber

Salvatore Sanfilippo

unread,
Nov 9, 2017, 6:32:06 AM11/9/17
to redi...@googlegroups.com
Technically speaking you *could* SCAN and ask fro TTL. Does not block
and works but is O(N).
TLDR: You can do it if you really want. The fact you need that is
probably an hint that there is some design issue in your project.

On Thu, Nov 9, 2017 at 12:27 PM, Itamar Haber <ita...@redislabs.com> wrote:
> Hello Dan,
>
> Querying for keys based on their expiration time is not supported by Redis
> at the moment.
>
> You can work around this by not using Redis' built-in expiration and
> managing it yourself, e.g. by using a Sorted Set to track expiration times
> and implementing passive and active expiration in your application.
>
> Cheers,
>
> On Thu, Nov 9, 2017 at 4:26 AM, Dan <bir...@gmail.com> wrote:
>>
>> Hi All
>>
>> I want to make the key live longer if some condition met.
>>
>> What I think is if I can query all the keys close to expire (like 10
>> minutes to expire), then I can do the query-check-activate intervally.
>> I seached but not found any clue, if you know how to achieve it, please
>> tell me.
>> Any help will be highly appreciated!
>>
>> --
>> 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.
>
>
>
>
> --
>
> Itamar Haber | Chief OSS Education Officer
> Redis Labs ~/redis
>
> Mobile: +972 (54) 567 9692
> Twitter: @itamarhaber
> Skype: itamar.haber
>
> --
> 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.

Itamar Haber

unread,
Nov 9, 2017, 6:35:54 AM11/9/17
to Redis DB
Sure - scanning for TTL is possible, should have said that too #facepalm


>> 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.
>
>
>
>
> --
>
> Itamar Haber | Chief OSS Education Officer
> Redis Labs ~/redis
>
> Mobile: +972 (54) 567 9692
> Twitter: @itamarhaber
> Skype: itamar.haber
>
> --
> 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

> 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.
--
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+unsubscribe@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.
Reply all
Reply to author
Forward
0 new messages