Home >Backend Development >PHP Tutorial >After redis restarts, should the data existing in it disappear?
After restarting redis, should the data existing in it disappear?
After restarting redis, should the data existing in it disappear?
The default setting of Redis will enable RDB persistence.
There is another kind of persistence AOF, and both persistences can be enabled at the same time.
Even if persistence is turned on, it does not mean that your data will be the same after restarting as before. Because Redis cannot write to the hard disk every time it writes to memory (if so, the performance will be very poor), according to the rules in your configuration file, RDB can be triggered to write to the hard disk before writing (before writing is triggered) ) will be lost.
For more information, please view the official Redis documentation: http://redis.io/topics/persistence
Of course the data in the memory will be lost, but the data can be saved to a file
If persistence is not enabled, the data in redis will be lost. There is also the possibility of loss between the two persistence methods. It is recommended to use cluster mode, using rdb and aof for persistence and high availability respectively
Redis will enable snapshots by default, and all data will be saved to disk when exiting redis.
This is similar to the hibernation function of the operating system. During hibernation, the system will write the data in the memory to a file on the hard disk, and when it resumes, it will read the data from the file and put it back into the memory.
The same is true for redis, but data may be lost under certain unpredictable circumstances.