redis

32 commands

32 shown

Connect to Redis CLI Open interactive Redis CLI session redis-cli -h redis -p 6379 -a <password> #redis Redis info all Full server information: memory, CPU, clients, persistence redis-cli -h redis INFO all #redis#monitoring Monitor commands in real-time Stream all commands executed on the Redis server redis-cli -h redis MONITOR #redis#debug Slow log Show last 20 slow queries with execution time redis-cli -h redis SLOWLOG GET 20 #redis#debug#monitoring Memory usage of key Show bytes consumed by a specific key redis-cli -h redis MEMORY USAGE <key> #redis#debug Flush database Delete all keys in current DB asynchronously redis-cli -h redis FLUSHDB ASYNC #redis Save snapshot (BGSAVE) Trigger background RDB snapshot save redis-cli -h redis BGSAVE #redis Check replication info Show master/replica role, replication offset, connected replicas redis-cli -h redis INFO replication #redis#monitoring Scan keys by pattern Non-blocking key scan by pattern (prefer over KEYS in production) redis-cli -h redis --scan --pattern 'session:*' | head -20 #redis#debug TTL of a key Remaining TTL in seconds; -1 = no expiry, -2 = not found redis-cli -h redis TTL <key> #redis#debug Monitor real-time commands Stream every command sent to Redis (exclude health pings) redis-cli MONITOR | grep -v PING #redis#debug#monitoring Show slow query log Last 20 slow commands with execution time in microseconds redis-cli SLOWLOG GET 20 #redis#debug#monitoring Memory usage per key pattern Total memory consumed by keys matching a pattern redis-cli --scan --pattern 'session:*' | xargs -n1 redis-cli MEMORY USAGE | awk '{sum+=$1} END{print sum/1024/1024" MB"}' #redis#monitoring Delete keys by pattern Safely scan-delete matching keys without KEYS command redis-cli --scan --pattern 'cache:*' | xargs -r redis-cli DEL #redis Set key with TTL Set key with 1-hour expiry (EX = seconds) redis-cli SET mykey 'value' EX 3600 #redis Increment counter Atomically increment an integer counter redis-cli INCRBY counter:hits 1 #redis Pub/Sub publish Publish a message to a Redis pub/sub channel redis-cli PUBLISH events '{"type":"login","user":"alice"}' #redis Subscribe to channel Subscribe and listen to messages on a channel redis-cli SUBSCRIBE events #redis Show replication info Role, connected replicas, replication lag redis-cli INFO replication #redis#monitoring Force save to disk (BGSAVE) Trigger background RDB save and check its timestamp redis-cli BGSAVE && redis-cli LASTSAVE #redis Flush single database Asynchronously flush database index 1 only redis-cli -n 1 FLUSHDB ASYNC #redis Sorted set top-N Top 10 entries from a sorted set with scores redis-cli ZREVRANGEBYSCORE leaderboard +inf -inf WITHSCORES LIMIT 0 10 #redis Stream add message Append a message to a Redis Stream with auto-ID redis-cli XADD mystream '*' event login user alice #redis Cluster info Cluster health and node list with slot ranges redis-cli -c CLUSTER INFO && redis-cli -c CLUSTER NODES #redis#monitoring Benchmark throughput 100k requests, 50 clients, 10 pipeline depth (quiet output) redis-benchmark -q -n 100000 -c 50 -P 10 #redis#performance Find biggest keys Sample keyspace to find largest keys per type; note: estimates, runs SCAN not blocking redis-cli --bigkeys #redis#performance#troubleshooting#debug Top memory keys Sample keys ranked by actual memory usage, not element count; finds RAM hogs redis-cli --memkeys #redis#performance#monitoring#debug Exact key memory Bytes used by a single key incl overhead; SAMPLES 0 = exact for collections redis-cli MEMORY USAGE <name> SAMPLES 0 #redis#performance#debug#monitoring Slowlog inspection List 10 slowest commands with args and duration, then clear the log redis-cli SLOWLOG GET 10; redis-cli SLOWLOG RESET #redis#performance#troubleshooting#observability Latency root-cause advice Human-readable latency analysis with likely causes; pair with LATENCY HISTORY <event> redis-cli LATENCY DOCTOR #redis#performance#troubleshooting#observability Oldest idle clients Find long-lived/idle connections leaking sockets; sort by age then idle redis-cli CLIENT LIST | tr ' ' '\n' | grep -E 'addr=|age=|idle=' | paste - - - | sort -t= -k3 -rn | head #redis#network#troubleshooting#debug Cluster health check Verify slot coverage, node consistency and open slots across the cluster redis-cli --cluster check <host>:<port> #redis#troubleshooting#network#monitoring
no commands match