$ command-helper

Redis

redis-cli, working with keys and TTL, monitoring and finding big keys.

Requires Google sign-in

Connecting

Connect
redis-cli -h <host> -p <port>
Connect with a password and select a database
redis-cli -h <host> -p <port> -a <password> -n 0
Check availability
redis-cli -h <host> ping

Keys

Set a value with a 1 hour TTL
SET <key> value EX 3600
Get a value
GET <key>
Remaining TTL in seconds
TTL <key>
Key type
TYPE <key>
Find keys by pattern (safe for production)
redis-cli -h <host> --scan --pattern 'user:*'

Don't use KEYS * in production — it blocks the server.

Delete keys by patternadvanced
redis-cli -h <host> --scan --pattern 'cache:*' | xargs -r -L 100 redis-cli -h <host> UNLINK

Troubleshooting

General info and memory
redis-cli -h <host> INFO memory
Number of keys
DBSIZE
Biggest keysadvanced
redis-cli -h <host> --bigkeys
Memory used by a keyadvanced
MEMORY USAGE <key>
Slow queries
SLOWLOG GET 10
Watch all commands in real timeadvanced
redis-cli -h <host> MONITOR

Heavily loads the server — use only for short debugging sessions.

Server latency
redis-cli -h <host> --latency