What are the Redis persistence options (RDB and AOF)?
Answer
Redis provides two persistence mechanisms. RDB (Redis Database) takes point-in-time snapshots of the entire dataset and saves them to disk as a compact binary .rdb file, configured with rules like "save every 60 seconds if at least 100 keys changed." RDB is fast to restore, produces small files, but can lose up to several minutes of data. AOF (Append-Only File) logs every write command in a text file. On restart, Redis replays the log to reconstruct the dataset. AOF is more durable (can be configured to fsync on every write) but produces larger files and slower restarts. You can enable both simultaneously for maximum durability — Redis will use the AOF for recovery because it's more complete. A third option since Redis 7 is RDB+AOF hybrid persistence.