Which command returns the remaining time to live of a key in seconds?
- A EXPIRE key
- B TTL key (correct answer)
- C PERSIST key
- 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.