The Redis website defines its product to be an in-memory data structure store which support strings, hashes, sets and so on.

For the in-memory part, it means that -When the server is started- the processing of the database is done in RAM not in the hard-disk which of-course is much faster as the time for accessing the desk is no longer needed.

Now if the file is loaded in RAM, how does Redis stay persistent?

The persistence is handled in Redis by 2 methods:

  • Redis database files (RDB) (activated by default)

  • Append-only file (AOF)

First, RDB:

It takes snapshots of the data creating point-in-time copies of the data. It is like make a backups after every specific time or changes in the database. Generally it is perfect for backups.

I find it easy to visualize it as a GitHub Repo that keeps track of your changes but it self-commits after a certain number of changes or some specific time.

Second, AOF:

It depends on logs to reconstruct the database when the server is restarted. When you start your Redis server, AOF keeps track of the changes you make to the database and keeps logs describing it. When the server is restarted, Redis makes sure to reconstruct the original database using these log files.

This way the data is always persistent.

This file is named “Appendonly.aof” and kept in the same folder where you installed Redis.

A last note about data persistence, The 2 methods don’t actually oppose each other and can be used together.

#redis #rdb #aof

A Gentle Intro for Redis
1.20 GEEK