Video in progress
If Redis keeps data in memory, does everything disappear when the server goes down?
Yes, if persistence is not enabled. With an RDB snapshot or an AOF log enabled, Redis restores the data from disk on restart, but the last few seconds may be lost.
📖 Answer
Redis's working copy is always in RAM. Writing to disk is an extra feature, not a requirement.
There are two ways:
- RDB: a periodic snapshot of the whole dataset (
dump.rdb). For example, "save if there were 1000 changes in 60 seconds". - AOF: every write command is appended to a file, and on restart they are replayed.
# redis.conf
save 60 1000
appendonly yes
appendfsync everysec
For a pure cache, people often turn persistence off completely: if the data is lost, it gets reloaded from the DB anyway. If you store sessions or a queue, it makes sense to enable AOF.
Sign up to mark studied questions and save your progress.