After redis is restarted, should the existing data disappear? after redis is restarted, should the existing data disappear?
Reply content:
Should the existing data disappear after redis is restarted?
RDB persistence is enabled by default in Redis.
There is another persistence AOF, which can be enabled at the same time.
Even if persistence is enabled, it does not mean that your data must be consistent with that before restart after restart. Because Redis may not write a hard disk every time it writes memory (if so, the performance will be poor), according to the rules in your configuration file, RDB can be triggered to write to the hard disk, the part before writing (before triggering the write) will be lost.
For more information, please refer to Redis official documentation: http://redis.io/topics/persistence
Of course, the data in the memory will be lost, but the data can be saved to the file
If persistence is not enabled, data in redis will be lost. The two persistence methods may also be lost. we recommend that you use the cluster mode and use rdb and aof for persistence and high availability.
By default, snapshots are enabled for redis. when you exit redis, all data is saved to the disk.
Similar to the sleep function of the operating system, the system writes data in the memory to a file on the hard disk during sleep, and then reads data from the file and puts it back into the memory.
This is also true for redis, but data may be lost in some unpredictable situations.