Generic
TTL
Return the expiration in seconds of a key.
Arguments
keybodystrrequired
The key
Response
intrequired
The number of seconds until this expires, negative if the key does not exist or does not have an expiration set.
Example
# Get the TTL of a keyredis.set("my-key", "value")assert redis.ttl("my-key") == -1redis.expire("my-key", 10)assert redis.ttl("my-key") > 0# Non existent keyassert redis.ttl("non-existent-key") == -2