Skip to main content

TTL

Syntax

TTL key

Time complexity: O(1)

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.

Return

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.

Examples

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