All network communications require both parties to comply with the same protocol in order to be interconnected. The Redis protocol makes a compromise between the following points:
Network Layer Redis listens for incoming connections on TCP port 6379. When a client connects, the Redis server creates a TCP connection for it. Each Redis command or data transmitted between the client and the server ends with \r\n. ask Redis receives commands consisting of different parameters. Once a command is received, it will be processed immediately and responded to the client. New Unified Request Protocol The new unified protocol was introduced in Redis 1.2, and in Redis 2.0, it became the standard way to communicate with a Redis server. In this unified protocol, all parameters sent to the Redis server are binary safe. The following is the general form:
Example:
The above command looks like a single-quoted string, so you can see the exact value of each byte in the query:
This format is also used in Redis responses. When replying in bulk, this format is used for each parameter. The actual unified request protocol is what Redis uses to return list items and calls Multi-bulk replies. It is just N different bulk replies prefixed with *\r\n, which is the number of parameters (bulk replies) that follow. response Redis replies to commands with different response types. It may check the reply type from the first byte sent by the server: Single-line response The first byte of the response will be +
Error message The first byte of the response is -
Integer The first byte of the response will be: Batch Response The first byte will be $
Multiple batch responses
|
>>: PAM4 and Coherent Technology in 100G DWDM Optical Modules
At the beginning of 2022, we received New Year pr...
In 2020, the "new crown" black swan cam...
According to a research report released by the Gl...
WebHorizon is a foreign VPS hosting company estab...
In today’s fast-paced, hyper-connected and tech-e...
In the era of information explosion, consumers ar...
Since the Ministry of Industry and Information Te...
TmhHost is a Chinese VPS service provider establi...
[51CTO.com original article] In late summer 2017,...
The data center of the future will rely on cloud ...
SD-WAN became a "hot word" in China in ...
[51CTO.com original article] Seven years of hard ...
Recently, the first quarter results of the three ...
[51CTO.com original article] On September 23, 202...
RackNerd has officially added a self-service IPv4...