Returns the expiration time in milliseconds of a key.
PTTL
key
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:
-2
if the key does not exist.-1
if the key exists but has no associated expire.One of the following:
Integer reply: TTL in milliseconds.
Integer reply: -1
if the key exists but has no associated expiration.
Integer reply: -2
if the key does not exist.
O(1)
@fast @keyspace @read
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
COPY, DEL, DUMP, EXISTS, EXPIRE, EXPIREAT, EXPIRETIME, KEYS, MIGRATE, MOVE, OBJECT, OBJECT ENCODING, OBJECT FREQ, OBJECT HELP, OBJECT IDLETIME, OBJECT REFCOUNT, PERSIST, PEXPIRE, PEXPIREAT, PEXPIRETIME, RANDOMKEY, RENAME, RENAMENX, RESTORE, SCAN, SORT, SORT_RO, TOUCH, TTL, TYPE, UNLINK, WAIT, WAITAOF.