Check key TTL

Show the remaining TTL in seconds: -1 means no expiry, -2 means the key does not exist

redis-cli -h redis TTL <key>

tool
redis32 commands
tags
redisdebug

More redis commands

  • redis-cli MONITOR | grep -v PING

    Stream every command sent to Redis, without health-check pings

  • redis-cli SLOWLOG GET 20

    Show the last 20 slow commands with execution time in microseconds

  • redis-cli --scan --pattern 'session:*' | xargs -n1 redis-cli MEMORY USAGE | awk '{sum+=$1} END{print sum/1024/1024" MB"}'

    Show the total memory in MB used by keys that match a pattern

  • redis-cli --scan --pattern 'cache:*' | xargs -r redis-cli DEL

    Delete matching keys with SCAN instead of the blocking KEYS command

  • redis-cli SET mykey 'value' EX 3600

    Set a key that expires in 1 hour (EX is in seconds)

all 32 redis commands