redis commands

32 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 32 shown

  • redis-cli -h redis -p 6379 -a <password>

    Open interactive Redis CLI session

  • redis-cli -h redis INFO all

    Full server information: memory, CPU, clients, persistence

    monitoring

  • redis-cli -h redis MONITOR

    Stream all commands executed on the Redis server

    debug

  • redis-cli -h redis SLOWLOG GET 20

    Show last 20 slow queries with execution time

    debug · monitoring

  • redis-cli -h redis MEMORY USAGE <key>

    Show bytes consumed by a specific key

    debug

  • redis-cli -h redis FLUSHDB ASYNC

    Delete all keys in current DB asynchronously

  • redis-cli -h redis BGSAVE

    Trigger background RDB snapshot save

  • redis-cli -h redis INFO replication

    Show master/replica role, replication offset, connected replicas

    monitoring

  • redis-cli -h redis --scan --pattern 'session:*' | head -20

    Non-blocking key scan by pattern (prefer over KEYS in production)

    debug

  • redis-cli -h redis TTL <key>

    Remaining TTL in seconds; -1 = no expiry, -2 = not found

    debug

  • redis-cli MONITOR | grep -v PING

    Stream every command sent to Redis (exclude health pings)

    debug · monitoring

  • redis-cli SLOWLOG GET 20

    Last 20 slow commands with execution time in microseconds

    debug · monitoring

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

    Total memory consumed by keys matching a pattern

    monitoring

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

    Safely scan-delete matching keys without KEYS command

  • redis-cli SET mykey 'value' EX 3600

    Set key with 1-hour expiry (EX = seconds)

  • redis-cli INCRBY counter:hits 1

    Atomically increment an integer counter

  • redis-cli PUBLISH events '{"type":"login","user":"alice"}'

    Publish a message to a Redis pub/sub channel

  • redis-cli SUBSCRIBE events

    Subscribe and listen to messages on a channel

  • redis-cli INFO replication

    Role, connected replicas, replication lag

    monitoring

  • redis-cli BGSAVE && redis-cli LASTSAVE

    Trigger background RDB save and check its timestamp

  • redis-cli -n 1 FLUSHDB ASYNC

    Asynchronously flush database index 1 only

  • redis-cli ZREVRANGEBYSCORE leaderboard +inf -inf WITHSCORES LIMIT 0 10

    Top 10 entries from a sorted set with scores

  • redis-cli XADD mystream '*' event login user alice

    Append a message to a Redis Stream with auto-ID

  • redis-cli -c CLUSTER INFO && redis-cli -c CLUSTER NODES

    Cluster health and node list with slot ranges

    monitoring

  • redis-benchmark -q -n 100000 -c 50 -P 10

    100k requests, 50 clients, 10 pipeline depth (quiet output)

    performance

  • redis-cli --bigkeys

    Sample keyspace to find largest keys per type; note: estimates, runs SCAN not blocking

    performance · troubleshooting · debug

  • redis-cli --memkeys

    Sample keys ranked by actual memory usage, not element count; finds RAM hogs

    performance · monitoring · debug

  • redis-cli MEMORY USAGE <name> SAMPLES 0

    Bytes used by a single key incl overhead; SAMPLES 0 = exact for collections

    performance · debug · monitoring

  • redis-cli SLOWLOG GET 10; redis-cli SLOWLOG RESET

    List 10 slowest commands with args and duration, then clear the log

    performance · troubleshooting · observability

  • redis-cli LATENCY DOCTOR

    Human-readable latency analysis with likely causes; pair with LATENCY HISTORY <event>

    performance · troubleshooting · observability

  • redis-cli CLIENT LIST | tr ' ' '\n' | grep -E 'addr=|age=|idle=' | paste - - - | sort -t= -k3 -rn | head

    Find long-lived/idle connections leaking sockets; sort by age then idle

    network · troubleshooting · debug

  • redis-cli --cluster check <host>:<port>

    Verify slot coverage, node consistency and open slots across the cluster

    troubleshooting · network · monitoring