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
Use the TTL
command. If an expiration is set, it returns the number of seconds until the key expires; otherwise it returns -1.
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.
精彩评论