TTL key

    Time complexity: O(1)

    Returns the remaining time to live of a key that has a timeout. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset.

    Starting with Redis 2.8 the return value in case of error changed:

    See also the command that returns the same information with milliseconds resolution (Only available in Redis 2.6 or greater).

    *Examples

    redis> SET mykey "Hello"

    redis> EXPIRE mykey 10

    redis>