Redis Setup and Connectingπ± Beginner
To interact with Redis, you can run the server locally using Docker, and connect to it using redis-cli, the built-in command line interface.
What is redis-cli?
The redis-cli is the interactive terminal tool used to send commands directly to a Redis server. While your Node.js or Python backend will eventually communicate with Redis programmatically, the CLI is essential for debugging and testing cache entries.
Why Use Docker?
Installing Redis directly on Windows can be incredibly frustrating because Redis was historically built exclusively for Linux. Running it inside a Docker container guarantees a flawless, 1-second setup regardless of your operating system.
How to Install and Run
Open your terminal and start a Redis container in the background, exposing the default port 6379.
# Start a Redis server container
docker run --name my-redis -p 6379:6379 -d redis
# Open the interactive CLI inside that running container
docker exec -it my-redis redis-cliOnce inside the redis-cli, you can run a quick ping test to ensure the server is alive:
127.0.0.1:6379> PING
PONG