= 2" />
English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis Pttl command returns the remaining expiration time of the key in milliseconds.
The basic syntax of the Redis Pttl command is as follows:
redis 127.0.0.1:6379> PTTL KEY_NAME
=> 2.6.0
When the key does not exist, return -2 . When the key exists but no remaining time to live is set, return -1 . Otherwise, return the remaining time to live of the key in milliseconds.
Note:In Redis 2.8 Previously, when the key does not exist, or the key does not have a remaining time to live set, the command returned -1 .
# Non-existent key redis> FLUSHDB OK redis> PTTL key (integer) -2 # Key exists but no remaining time to live is set redis> SET key value OK redis> PTTL key (integer) -1 # Key with remaining time to live redis> PEXPIRE key 10086 (integer) 1 redis> PTTL key (integer) 6179