Redis is often called an in-memory database because it keeps all the data in memory so that it can continue to be used after the server restarts, and Redis provides two persistence modes for RDB and AOF, respectively.
At Redis runtime, the RDB program saves the current in-memory db snapshot to a disk file, and when Redis restarts, the RDB program can restore the state of the database by loading the Rdb file.
The most core of the RDB functionality is the Rdbsave and rdbload two functions, which are used to generate an RDB file to disk, while the latter is used to reload the data in the Rdb file into memory:
AOF Records all commands (and their parameters) that have been written to the database in the form of protocol text to the AOF file to achieve the purpose of logging the database state.
Redis Source Code Analysis (v): The persistence of Redis