Advertisement
Beginner Redis, Redis CLI & Basic Commands

What is redis-cli, and how do you use it to connect to and interact with a Redis server?

Short answer

redis-cli is the official command line tool for connecting directly to a Redis server, letting you run commands interactively and see their results immediately, which is useful for quick testing, troubleshooting, and learning how specific commands behave before using them in…

Save Redis mock interview
Advertisement
AModel answer
redis-cli is the official command line tool for connecting directly to a Redis server, letting you run commands interactively and see their results immediately, which is useful for quick testing, troubleshooting, and learning how specific commands behave before using them in application code.
Example

redis-cli -h localhost -p 6379 127.0.0.1:6379> SET greeting 'hello' 127.0.0.1:6379> GET greeting

Real-world example
A developer uses redis-cli to quickly test how a new command behaves before writing the equivalent code in their application, confirming the exact syntax and expected response format.
Likely follow-ups
  • How do you connect redis-cli to a remote Redis server with a password?
  • How do you exit the redis-cli interactive session?
Related topics