PTTL

Reports a key's remaining lifetime in milliseconds.

Keys & expiration · Example verified

Syntax covered here

PTTL key

A persistent key gives -1 and a missing key gives -2; other cases verify positive lifetimes after expiry-setting commands.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> SET sample value
"OK"
# connection: default
> PTTL sample
-1
# connection: default
> PTTL missing
-2