Code Reference

CLI Basics

Redis · Reference cheat sheet

CLI Basics

Redis · Reference cheat sheet


📋 Overview

redis-cli is the standard admin and debugging client: run commands, monitor traffic, check latency, and inspect keys safely with SCAN.

🔧 Core concepts

Command / flagPurpose
redis-cliInteractive REPL
redis-cli -u redis://host:6379URL connect
redis-cli CMD …One-shot command
INFOSections of server info
MONITORStream commands (prod caution)
SCANIterate keys safely
--latencyLatency sampler
Key inspectionNotes
TYPE keyData structure
EXISTS key0/1
MEMORY USAGE keyBytes (if available)
OBJECT ENCODINGInternal encoding

💡 Examples

Connect and ping:

redis-cli -h 127.0.0.1 -p 6379 PING

Scan keys by prefix:

redis-cli --scan --pattern 'user:*'

Info memory:

redis-cli INFO memory

⚠️ Pitfalls

  • KEYS * blocks — never on busy production instances.
  • MONITOR is expensive and leaks command data (including values).
  • Auth: use AUTH / ACL users — don't put passwords in shell history casually.

On this page