Keys Pttl
# Redis Pttl Command
[!(#) Redis key](#)
Redis Pttl command returns the remaining expiration time of the key in milliseconds.
### Syntax
Basic syntax of redis Pttl command is as follows:
redis 127.0.0.1:6379> PTTL KEY_NAME
### Available Version
>= 2.6.0
### Return Value
When the key does not exist, return -2. When the key exists but no remaining survival time is set, return -1. Otherwise, return the remaining survival time of the key in milliseconds.
**Note:** Before Redis 2.8, when the key did not exist, or when the key had no remaining survival time set, the command returned -1.
### Example
# Non-existent key
redis> FLUSHDB
OK
redis> PTTL key
(integer) -2
# Key exists, but no remaining survival time is set
redis> SET key value
OK
redis> PTTL key
(integer) -1
# Key with remaining survival time
redis> PEXPIRE key 10086
(integer) 1
redis> PTTL key
(integer) 6179
[!(#) Redis key](#)
YouTip