How to retrieve the remaining time in keys expiry in milliseconds in Redis? What is PTTL Command in Reids?
PTTL is a Redis command that returns the remaining time to live of a key in milliseconds. The
PTTL command is similar to the
TTL command, but returns the time-to-live of the key in milliseconds instead of seconds.
The syntax of the
PTTL command is as follows:
key is the name of the key for which to retrieve the remaining time-to-live.
For example, to get the remaining time to live of the key
mykey in milliseconds, you can run the following command:
This command returns the remaining time-to-live of the key
mykey in milliseconds. If the key does not exist or has no associated expiration time, the
PTTL command returns -1.
Note that the
PTTL command is available since Redis version 2.6.0, so make sure your Redis version supports it before using this command.
Post a Comment