Lesson 3 / 18

redis-cli Basics

The interactive shell for talking to a Redis server.

Connecting

Run without arguments for an interactive prompt, or connect to a remote host and port directly.

redis-cli
127.0.0.1:6379> SET greeting "hello"
OK
127.0.0.1:6379> GET greeting
"hello"

# or connect elsewhere
redis-cli -h cache.example.com -p 6379 -a mypassword

One-shot commands

You don't need the interactive prompt for scripting — pass the command as arguments: redis-cli SET k v, handy inside shell scripts.

Quick check: What does a healthy Redis server reply to `PING`?

  • OK
  • PONG
  • ALIVE
Answer

PONG — `PING` is the standard liveness check and always returns `PONG`.