โ Redis learning pathRedis ยท Module 7 of 10
Persistence: RDB and AOF
Redis can save data to disk with snapshots or an append-only log.
๐ Key ideas
- RDB takes point-in-time snapshots at intervals.
- AOF logs every write command and replays it on restart.
- AOF with fsync every second loses at most about one second of writes.
- Many setups use both: RDB for backups, AOF for durability.
- A pure cache can run with persistence off.
๐ก Real-life example: RDB is a photo of the whiteboard every hour; AOF is a diary of every change written as it happens.
RDBPeriodic snapshot of all data
AOFLog of every write command
fsyncForce data from memory onto disk
ReplayRe-run logged commands to rebuild data