Q41 Redis Domain 2 · 25–30% of exam Priority · Real Exam

Which command returns the remaining time to live of a key in seconds?

  1. A EXPIRE key
  2. B TTL key (correct answer)
  3. C PERSIST key
  4. D OBJECT IDLETIME key

Shortcut: TTL returns the remaining lifetime in seconds, -1 if the key has no expiry, and -2 if the key does not exist. PTTL gives the same in milliseconds.