Memory data persistence method and apparatus for Redis database
A technology of in-memory data and database, applied in the direction of electrical digital data processing, special data processing applications, instruments, etc., can solve the problems of lost data, unable to ensure data security well, occupying storage space, etc., to ensure security Effect
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0054] refer to figure 1 , which shows a flow chart of the steps of an embodiment of a method for persisting memory data for a Redis database according to the present invention, which may specifically include the following steps:
[0055] Step 101, when there is update data that needs to be written into the memory, sequentially add the first write instruction corresponding to the update data to the incremental file AOF;
[0056] The Redis database is an in-memory database. It is an open-source, log-type, Key-Value database that is written in ANSI C language, supports the network, and can be memory-based or persistent.
[0057] The Redis database stores data in the memory, and directly reads the data in the memory for corresponding operation processing. Since the data reading and writing speed of the memory is several orders of magnitude higher than that of the disk, the Redis database can greatly improve the data efficiency by storing the data in the memory. Processing efficien...
Embodiment 2
[0086] refer to figure 2 , which shows a flow chart of the steps of an embodiment of a method for recovering memory data for a Redis database according to the present invention, which may specifically include the following steps:
[0087] Step 201, when there is disk data that needs to be restored to the memory, extract the data in the snapshot file RDB, and write the extracted data into the memory;
[0088] In the embodiment of the present invention, the Redis database includes an incremental file AOF and a snapshot file RDB located on the disk.
[0089] The snapshot file RDB saves the data in the memory when the failure occurs. Usually, the data is saved to the snapshot file RDB in the form of Snapshot.
[0090] The incremental file AOF stores the first write instruction corresponding to the updated data written in the memory during the period from saving the memory data to the snapshot file RDB to the failure, and the first write instruction corresponding to the same data...
Embodiment 3
[0127] refer to image 3 , which shows a structural block diagram of an embodiment of an in-memory data persistence device for a Redis database of the present invention, the Redis database includes an incremental file AOF and a snapshot file RDB located on a disk, and the device includes:
[0128] The first write instruction adding module 301 is used to sequentially add the first write instruction corresponding to the update data to the incremental file AOF when there is update data that needs to be written into the memory;
[0129] A memory data adding module 302, configured to add existing data in the memory to the snapshot file RDB when the size of the incremental file AOF is greater than or equal to a preset threshold;
[0130] An incremental file AOF clearing module 303, configured to clear the incremental file AOF.
[0131] In a preferred embodiment of the present invention, the memory data adding module 302 may include the following submodules:
[0132] The first memo...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 