TTL of a key redis
Remaining TTL in seconds; -1 = no expiry, -2 = not found
redis-cli -h redis TTL <key>
more redis
all 32 commands →
Monitor real-time commands
redis-cli MONITOR | grep -v PING
Show slow query log
redis-cli SLOWLOG GET 20
Memory usage per key pattern
redis-cli --scan --pattern 'session:*' | xargs -n1 redis-cli MEMORY USAGE | awk '{sum+=$1} END{print sum/1024/1024" MB"}'
Delete keys by pattern
redis-cli --scan --pattern 'cache:*' | xargs -r redis-cli DEL
Set key with TTL
redis-cli SET mykey 'value' EX 3600