โ† Redis learning path
Redis ยท Module 7 of 10

Persistence: RDB and AOF

Redis can save data to disk with snapshots or an append-only log.

๐Ÿ“– Key ideas

  1. RDB takes point-in-time snapshots at intervals.
  2. AOF logs every write command and replays it on restart.
  3. AOF with fsync every second loses at most about one second of writes.
  4. Many setups use both: RDB for backups, AOF for durability.
  5. 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