PTTL

Syntax

  1. PTTL key

Time complexity: O(1)

Like TTL this command returns the remaining time to live of a key that has an expire set, with the sole difference that TTL returns the amount of remaining time in seconds while PTTL returns it in milliseconds.

Return

Integer reply: TTL in milliseconds, 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

  1. dragonfly> SET mykey "Hello"
  2. "OK"
  3. dragonfly> EXPIRE mykey 1
  4. (integer) 1
  5. dragonfly> PTTL mykey
  6. (integer) 1000