As a network server, Redis's internal operations follow a basic execution flow where the server waits and listens for incoming connections on a port by accepting the connection if the inbound client communicates with the correct syntax and format called the REdis Serialization Protocol (RESP). After accepting the socket connection, Redis yields a descriptor for nonblocking read and write operations on the in-memory state of the database.
For the Redis server, the main function creates an event loop calling the
aeMain function that creates an infinite
while loop. This loop tests the event loop's
stop property and exits if the test fails. Each iteration of the
while loop in
aeMain calls the
aeProcessEvents function with a pointer to the event loop along with any flags. The
aeProcessEvents function processes all the time-based events before processing all the file events. Remember that POSIX systems treat running processes as file descriptors, so even...