Skip to main content



TTL key

Time complexity: O(1)

ACL categories: @keyspace, @read, @fast

Returns the remaining time to live of a key that has a timeout. This introspection capability allows a Dragonfly client to check how many seconds a given key will continue to be part of the dataset.


Integer reply: TTL in seconds, or a negative value in order to signal an error.

  • The command returns -2 if the key does not exist.
  • The command returns -1 if the key exists but has no associated expire.


dragonfly> SET mykey "Hello"
dragonfly> EXPIRE mykey 10
(integer) 1
dragonfly> TTL mykey
(integer) 10