In Redis, the TTL
command returns the remaining time to live of a given key, in seconds.
If the key doesn’t have a timeout, an integer reply of -1
is returned. If the key doesn’t exist, -2
is returned.
Redis also has a PTTL
command, which works the same, but returns its result in milliseconds.