Skip to content

TTL

Syntax

TTL key

TTL returns the remaining time to live (in seconds) of a key that has an expiration set.

  • Returns -1 if the key has no expiration.
  • Returns -2 if the key does not exist.

Examples

localhost:7379> SET k 43
OK OK
localhost:7379> TTL k
OK -1
localhost:7379> SET k 43 EX 10
OK OK
localhost:7379> TTL k
OK 9
localhost:7379> TTL kn
OK -2