- Usage:
-
PTTL key
- Complexity:
- O(1)
- Since:
- 2.6.0
- The command returns
-2
if the key does not exist. - The command returns
-1
if the key exists but has no associated expire.
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.
The command returns the following values in case of errors:
Examples
127.0.0.1:6379> SET mykey "Hello"
OK
127.0.0.1:6379> EXPIRE mykey 1
(integer) 1
127.0.0.1:6379> PTTL mykey
(integer) 989
History
Version | Change |
---|---|
2.8.0 | Added the -2 reply. |