Persistence
Redis · Reference cheat sheet
Persistence
Redis · Reference cheat sheet
📋 Overview
Redis can persist in-memory data via RDB snapshots, AOF logs, or both. Persistence improves durability but is not a substitute for backups and replication strategy.
🔧 Core concepts
| Mode | How |
|---|---|
| RDB | Point-in-time .rdb snapshots |
| AOF | Append-only log of write commands |
| RDB+AOF | Common hybrid |
| No persistence | Pure cache (accept data loss) |
| Knob | Meaning |
|---|---|
save | RDB schedule |
appendonly | Enable AOF |
appendfsync | always / everysec / no |
| Replica | Continuity via replication |
💡 Examples
Check persistence config:
redis-cli CONFIG GET save
redis-cli CONFIG GET appendonlyManual save:
BGSAVE
LASTSAVEAOF rewrite:
BGREWRITEAOF⚠️ Pitfalls
appendfsync alwaysis safest and slowest — usuallyeverysecis the compromise.- Forking for
BGSAVEon large datasets needs free memory headroom. - Restoring from outdated RDB after a crash still loses recent writes if AOF is off.