Connecting to and Starting Redis
Sveip for å vise menyen
Starting Redis Server
The Redis Server is the core component of Redis, responsible for managing data and handling requests. To get started, you need to launch the Redis server.
You already know how to start the server via the command line on macOS.
redis-server
After running the command, you'll see information about the current server status.
When Redis starts, it logs key information, including the version (7.2.6), port number (typically 6379), and the PID (Process ID), which uniquely identifies the Redis process for management purposes.
It also logs the operating mode (default is standalone mode). The message Ready to accept connections confirms that the server has started successfully and is ready to handle requests.
Working with Redis CLI
Redis CLI is a command-line utility used to interact with the Redis server. It allows you to send commands, check the database status, and troubleshoot.
To connect to the Redis server, run the following command:
redis-cli
Once connected, you'll see the command prompt:
Here, you can enter your commands that will interact with the Redis server. We'll cover that in the next section. But first, let's check if the server is working and if everything is set up correctly.
Checking Server Status
In Redis, the PING command checks the connection to the server, typically responding with PONG. This is often used to test if the Redis server is reachable or to keep the connection alive.
To check the server's status, type the following command in Redis CLI:
PING
When you enter this command, the server responds with PONG, indicating that the connection is established and the server is running correctly.
Disconnecting from the Server
To quit Redis CLI, type the following command:
QUIT
This will close the connection and exit the command line interface.
1. What command is used to start the Redis server?
2. Which command is used to exit the Redis CLI?
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår