redis 设计与实现（1）redis 数据结构
hashtable 的 val 可能存储很多东西
Replication in Redis is like to a dialog between a slave, (or an apprentice), and its master.
This conversation runs along the these lines:
Apprentice: “I want to learn and to become like you.”
Master: “PATIENCE YOU MUST HAVE my young padawan. Hmmmmmm.”
The Master forks itself, and…The forked process dumps the dataset to a disk file (RDB),The main process continues serving regular client requests, and Any changes made to the data are copied to a replication buffer on the main process.
Once the dump is done, the Master says: “Come and get it while, hot, is it.”
The apprentice reads the file over the network and writes it to its own disk.
Once it has the file stored locally, the apprentice loads it.
After loading is finished, the apprentice asks: “Well, I finished my circle. I’m ready.”
If there are any changes in the buffer, the Master says: “Ready you are? What know you of ready? Feel the Force!” and replays the stored changes to the slave.
After there are no changes left to replay from the buffer, the Master says: “No more training do you require. Already know you, that which you need.”
From that moment, any new change request that the master is given is then also replayed to the apprentice.