1. rdb snapshot storage
When the Linux system is shut down, the data in the memory will be released, and the redis data in the memory will be saved to the dump.rdb file before the release.
In the redis.conf file:
……
dbfilename dump.rdb
……
dir ./
……
To ensure data security and prevent data loss
After every 900 seconds (15 minutes), if a key is changed, it will be stored immediately
After every 300 seconds (5 minutes), 10 keys are changed and stored immediately
After every 60 seconds (1 minute), 10,000 keys are changed, and they are stored immediately
In the redis.conf file:
……
save 900 1
save 300 10
save 60 10000
……
2. AOF differential storage
The rdb snapshot storage will save all the data in the memory to the dump.rdb file, which is inefficient, so it provides a differential storage that only saves the changed data.
Note: All data in memory will be saved to the dump.rdb file when shutting down
To use AOF differential storage, you need to set in the configuration file:
…… #appendonly no appendonly yes ……
appendfsync always
#appendfsync everysec
#appendfsync no
……
There are 3 modes of AOF differential storage :
- always, persistent storage for every write
- everysec , automatic persistent storage every minute
- no , do not store