skip to Main Content

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


  1. 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).

    Login or Signup to reply.
  2. 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 with DEBUG 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
    Value at:0x7fff70629920 refcount:1 encoding:embstr serializedlength:4 ...
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search