Method: Redis::Commands::Keys#ttl
- Defined in:
- lib/redis/commands/keys.rb
#ttl(key) ⇒ Integer
Get the time to live (in seconds) for a key.
In Redis 2.6 or older the command returns -1 if the key does not exist or if the key exist but has no associated expire.
Starting with Redis 2.8 the return value in case of error changed:
- The command returns -2 if the key does not exist.
- The command returns -1 if the key exists but has no associated expire.
120 121 122 |
# File 'lib/redis/commands/keys.rb', line 120 def ttl(key) send_command([:ttl, key]) end |