RDB (Redis Database): The RDB persistence performs point-in-time snapshots of your dataset at specified intervals
- Redis saves key-value pairs to dump.rdb for backup
- Redis saves dump.rdb when stop normally, does not automatically save dump.rdb when system crash or the redis processes are killed
- Load dump.rdb when start, makes it persistent
- Pros
- Compact, single file of Redis data
- Perfect for backups
- Performance is good
- Allows Faster Restarts
- Cons
# Edit /usr/local/etc/redis.conf to configure save, restart redis
CONFIG get dir # find the location of dump.rdb, /usr/local/var/db/redis
SAVE # manually save a dump.rdb file
save 60 1000 # dump the dataset to disk every 60 seconds if at least 1000 keys changed
AOF (Append Only File), logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset
- Pros
- High Durability
- Allows different fsync policies
- Append only log, less chances of corruption
- Corrupted file can be fixed by redis-check-aof tool
- AOF File can be parsed, lines can be removed
- Cons
- Size is bigger than RDB
- Slower than RDB
# Edit /usr/local/etc/redis.conf, change "appendonly no" to "appendonly yes", restart redis
# once you set appendonly yes in redis.conf, and restart Redis, it will load data from AOF file instead of dump.rdb