Basic Knowledge Section
If you need to master the implementation of the entire Redis command, then you must master some basic concepts! Otherwise do not understand, below I have some in my opinion necessary basic knowledge to summarize, hope can for the subsequent command of the entire implementation process to pave the way.
Event
The Redis server is an event driver and the server needs to handle the following two types of events:
- File event: The Redis server connects to the client (or other Redis server) through a socket, and the file event is the server's abstraction of the socket operation. The communication between the server and the client (or other server) generates corresponding file events, and the server completes a series of network communication operations by listening for and processing these events;
- • Time Event: Some operations in the Redis server (such as the Servercron function) need to be performed at a given point in time, and the time event is the server's abstraction of such timed operations.
File events
The file event handler is the function that is used to handle this file event when the file event is generated;
- The file event handler uses an I/O multiplexing (multiplexing) program to listen to multiple sockets at the same time and correlate different event handlers for sockets based on the tasks currently performed by the socket;
- When a listening socket is ready to perform an operation such as a connection answer (accept), read (read), write (write), close (close), the file event corresponding to the operation is generated, and the file event handler invokes the associated event handler before the socket to handle these events.
- Cond....
Redis Learning Notes-command execution flow