The present invention relates to a method for semi-synchronous caching data, belonging to the technical field of
middleware, and includes the following steps: Write and run a
distributed cache proxy layer service using a preset
programming language, receive read and write command requests from application clients, parse the Key consistent hash value, and send it to the backend Redis
shard nodes. The master instance parses the message packet, marks the write operation and records it in the AOF file. After the disk write is completed, the master instance sends an AOF
file transfer command to the slave instance node, and the slave instance executes the
receipt. After the master instance receives the
receipt response, it updates the confirmation offset of the slave node and responds to the
client. When the network latency is high, mark the data of the master and slave nodes as "out of
sync" and automatically degrade to
asynchronous replication. The present invention optimizes the implementation of master-slave semi-synchronization in Redis by self-developing the Redis kernel and using the asynchronous ack mechanism, improves the
data reliability of single-point failures, and solves the problems of
data latency and
data consistency caused by the native Redis
asynchronous replication mechanism.