Persistent storage stores the data stored in memory by Redis on the hard disk to achieve permanent storage of data.
We all know that Redis is a memory-based nosql database. Memory storage can easily cause data loss because when the server is shut down, etc. Some abnormal conditions can cause the data stored in the memory to be lost. (Recommended learning: Redis Video Tutorial)
Enable the persistence function of redis and save the data to the disk. When redis is restarted, the data can be restored from the disk.
Redis provides two methods for persistence, one is RDB persistence (the principle is to periodically dump Reids' database records in memory to RDB persistence on disk), and the other is AOF (append only file) persistence (the principle is to write Reids' operation log to the file in an appended manner).
The difference between the two
RDB persistence refers to writing a snapshot of the data set in memory to disk within a specified time interval. The actual operation process is to fork one The child process first writes the data set into a temporary file. After the writing is successful, it replaces the previous file and stores it using binary compression.
AOF persistence records every write and delete operation processed by the server in the form of a log. Query operations will not be recorded, but will be recorded in the form of text. You can open the file to view to detailed operation records.
The above is the detailed content of When does redis persist?. For more information, please follow other related articles on the PHP Chinese website!