tags:

views:

28

answers:

2

Hello,

As far as Redis do not allow to reSet expire date to key (because of nans with replication) I'd like to know is there any method to check if key set to be expired or not?

Thank you

A: 

I don't think checking for expiration date make much sense in Redis, though. I'd like to first suggest that you model it so you don't need to check for expiration date.

If you really need it, though, you can just use another key to store the expiration date for later retrieval via normal GET/SET.

Note that you can also check for EXPIRES manually in your client code, which might be a better solution.

chakrit
I'm using Redis to write statistics about views (per day, per month, per year etc.). I don't need statistics for pre-previous day, pre-previous month etc., so I want to use Redis EXPIRES to be sure that pre-previous date objects are removed automatically and I don't have to clean DB manually.
Kirzilla
@Kirzilla Can you elaborate on why'd you need to re-check/re-set expires date?
chakrit
@chakrit, do you have Google Talk or ICQ? It would be great to contact you if you have some spare time... Thank you.
Kirzilla
@Kirzilla Spare time I have, of course :) but not ICQ accounts :( I think you might get better answers by posting this to the Redis Google Groups (http://groups.google.com/group/redis-db). The folks there are wayyy smarter than me :) I have GMail address but I don't have any IM software right now besides twitter.
chakrit
A: 

Use the TTL command. If an expiration is set, it returns the number of seconds until the key expires; otherwise it returns -1.

rpetrich