Video in progress
Which commands do you use in redis-cli to quickly check a running Redis?
PING shows it's alive, INFO shows memory, clients and stats, DBSIZE shows the number of keys, and TTL/TYPE show the state of a single key. MONITOR shows all commands in real time, but in prod it should only be turned on briefly.
📖 Answer
redis-cli -h 10.0.0.5 -a $PASS PING # PONG
redis-cli INFO memory | grep used_memory_human
redis-cli INFO clients | grep connected_clients
redis-cli DBSIZE
redis-cli TYPE shop:cart:user:7
redis-cli TTL shop:cart:user:7
redis-cli --bigkeys # the biggest keys
When someone says "the app isn't getting data from Redis", I check these first: does the key the app expects actually exist, is its type right (for example, a String where a Hash is expected), and has the TTL already run out.
MONITOR is very handy for debugging, but it noticeably hurts Redis performance. In prod, turn it on for a few seconds and get out. SLOWLOG GET 10 shows slow commands safely.
Watch out: with -a the password stays in your shell history; the REDISCLI_AUTH environment variable is better.
Sign up to mark studied questions and save your progress.