Redis › Redis CLI & Basic Commands
What is redis-cli, and how do you use it to connect to and interact with a Redis server?
BeginnerAnswer
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.
redis-cli -h localhost -p 6379
127.0.0.1:6379> SET greeting 'hello'
127.0.0.1:6379> GET greetingReal-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.