Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the differences between redis persistence

Shulou Source: shulou.com Published: 2022-06-01 03:51:19 09月24日 Update

This article mainly introduces the difference between redis persistence, the introduction in the article is very detailed, has a certain reference value, interested friends must read it!

Redis is an advanced key-value database. It is similar to memcached, but data can be persisted and the supported data types are rich. There are strings, lists, sets and ordered sets. Support server-side computation of set union, intersection and complement (difference), etc., but also support a variety of sorting functions. Redis can also be considered a data structure server.

All data in Redis is stored in memory and then asynchronously saved to disk from time to time (this is called "semi-persistent mode"); each data change can also be written to an append only file(aof)(this is called "fully persistent mode").

Because Redis data are stored in memory, if there is no configuration persistence, all data will be lost after redis restart, so you need to turn on the persistence function of redis and save the data to the magnetic disk. When redis restarts, you can recover the data from the disk.

Redis provides two ways to persist, one is RDB persistence (the principle is to dump Reids database records in memory to RDB persistence on disk at regular intervals), and the other is AOF (append only file) persistence (the principle is to write Reids operation logs to files in an appended manner). So what's the difference between these two persistence methods, and how do you choose them?

difference

RDB persistence refers to writing a snapshot of a dataset in memory to disk within a specified time interval. The actual operation process is to fork a child process, first write the dataset to a temporary file, and then replace the previous file after writing successfully, and store it with binary compression.

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

The above is what the difference between redis persistence is all about. Thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Data mode memory file disk server support service content function principle database log schema order advanced success size binary value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker Xiaomi vpn NVidia