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