Since the Redis expires keys in passive and active way,
Is there any way to get a key even if its expire time has passed(but still exists in Redis)?
Since the Redis expires keys in passive and active way,
Is there any way to get a key even if its expire time has passed(but still exists in Redis)?
2
Answers
No, there isn’t. The key (and its value) will be expired automatically eventually, or upon trying to access it (i.e. passively or actively).
DEBUG OBJECT myKey
will return info about the key even when it is expired timewise – if it has not been garbage-collected (actively-expired) or passively-expired (accessed) yet.To test this, you can disable the background (active) expiring with
DEBUG SET-ACTIVE-EXPIRE 0
. Use carefully. Restore withDEBUG SET-ACTIVE-EXPIRE 1
Note the
DEBUG OBJECT myKey
returns the memory address, so if you really need to see the value, you’ll have to explore the RAM contents.DEBUG OBJECT myKey
returns(error) ERR no such key
if it has been expired already, actively or passively, or if it doesn’t exist of course.