Home >Database >Redis >Redis persistence methods and differences

Redis persistence methods and differences

(*-*)浩
(*-*)浩Original
2019-06-17 16:06:022779browse

Redis is an advanced key-value database. It is similar to memcached, but data can be persisted and supports a wide range of data types. There are strings, linked lists, sets and sorted sets. It supports calculating the union, intersection and complement (difference) of sets on the server side, and also supports a variety of sorting functions. So Redis can also be regarded as a data structure server.

Redis persistence methods and differences

#All data in Redis is stored in memory and then asynchronously saved to disk from time to time (this is called "semi-persistent mode"); also Each data change can be written to an append only file (aof) (this is called "full persistence mode"). (Recommended learning: Redis video tutorial)

Since Redis data is stored in memory, if persistence is not configured, all data will be lost after redis restarts, so redis needs to be enabled. The persistence function saves data to the disk. When redis is restarted, the data can be restored from the disk.

Redis provides two methods for persistence, one is RDB persistence (the principle is to periodically dump Reids' database records in memory to RDB persistence on disk), and the other is AOF (append only file) persistence (the principle is to write Reids' operation log to the file in an appended manner). So what is the difference between these two persistence methods, and how to choose?

Difference

RDB persistence refers to writing a snapshot of the data set in memory to disk within a specified time interval. The actual operation process is to fork one The child process first writes the data set into a temporary file. After the writing is successful, it replaces the previous file and stores it using binary compression.

AOF persistence records every write and delete operation processed by the server in the form of a log. Query operations are not recorded, but are recorded in text. You can open the file to see detailed operation records.

For more Redis-related technical articles, please visit the Introduction to Using Redis Database Tutorial column to learn!

The above is the detailed content of Redis persistence methods and differences. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn