- Usage:
-
PTTL key
- Complexity:
- O(1)
- Since:
- 2.6.0
- ACL Categories:
- @keyspace, @read, @fast
- The command returns
-2if the key does not exist. - The command returns
-1if the key exists but has no associated expire. -
Integer reply: TTL in milliseconds.
-
Integer reply:
-1if the key exists but has no associated expiration. -
Integer reply:
-2if the key does not exist.
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
RESP2/RESP3 Reply
One of the following:
History
| Version | Change |
|---|---|
| 2.8.0 | Added the -2 reply. |