A method and system for implementing Redis in-memory database on non-volatile memory

By using the LSM tree structure and storage space manager on nonvolatile memory, the problem of long memory latency and recovery time of Redis in-memory databases during data persistence and recovery is solved, and efficient data storage and fast access is achieved.

CN111831423BActive Publication Date: 2024-11-12ALIBABA GROUP HOLDING LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910301040.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-15
Publication Date
2024-11-12
Estimated Expiration
2039-04-15

AI Technical Summary

Technical Problem

During the data persistence and recovery process of existing Redis memory database, frequent fork operations lead to increased memory latency, unlimited file growth, and long recovery time.

Method used

Implement direct storage of Redis data on non-volatile memory, and use the LSM tree structure and storage space manager to migrate using the hot and cold characteristics of the data to avoid fork operations, and store data in non-volatile in sequential writing Sexual memory.

Benefits of technology

It realizes efficient storage and fast access to data, reduces memory latency, reduces data recovery time, and effectively manages memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111831423B_ABST
    Figure CN111831423B_ABST
Patent Text Reader

Abstract

The present application proposes a method and system for implementing a Redis in-memory database on a non-volatile memory, the method comprising: assigning a unique index to each Redis instance; according to the index, allocating storage space for the Redis instance in the non-volatile memory based on the specifications of the Redis instance, and mapping the key value and data of the Redis instance into a storage structure of an LSM tree and storing it in the allocated storage space; and feeding back the allocated index and storage space to the Redis instance. The Redis data is directly stored in the non-volatile memory, and the access speed is maintained close to that of the memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of memory servers, and in particular to a method and system for implementing a Redis memory database on a non-volatile memory. Background Art

[0002] The existing Redis memory database mainly persists data by appending logs, and restores data by replaying the logs after the process is restarted.

[0003] At the same time, since logs are written to files in an append-write manner, in order to avoid unlimited file growth, it is necessary to create a new child process through fork (replication) after the log file grows to a certain threshold. The child process has the full data of the parent process, and the full data is saved to the hard disk in the child process, and the parent process continues to write incremental data to the log file. When the parent process calls fork, the access delay of the in-memory database will increase greatly, and due to the Copy-On-Write feature, if the parent process frequently performs write operations, the child process still maintains the original full data, and the memory usage will increase exponentially. In addition, after the process is restarted, it is necessary to restore the data by loading the full data and replaying the log file. If the full data or log file is large, the recovery time will be very long. Summary of the invention

[0004] The present invention provides a method and system for implementing a Redis memory database on a non-volatile memory, so as to directly store Redis data in the non-volatile memory and maintain an access speed close to that of the memory.

[0005] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is as follows:

[0006] In a first aspect, the present invention provides a method for implementing a Redis in-memory database on a non-volatile memory, comprising:

[0007] Assign a unique index to each Redis instance;

[0008] According to the index, based on the specification of the Redis instance, storage space is allocated to the Redis instance in a non-volatile memory, and the key value and data of the Redis instance are mapped into a storage structure of an LSM tree and stored in the allocated storage space;

[0009] Feedback the allocated index and storage space to the Redis instance.

[0010] Preferably, the method further comprises:

[0011] The Redis instance maps the corresponding non-volatile memory storage space to the virtual address space of the current process based on the acquired storage space.

[0012] Preferably, the method further comprises:

[0013] Receive a space release operation request sent by the Redis instance;

[0014] Parsing the space release operation request, and deleting the storage space corresponding to the non-volatile memory requested to be released in the space release operation request according to the parsed index;

[0015] Feedback the release result to the Redis instance.

[0016] Preferably, mapping the key value and data of the Redis instance into a storage structure of an LSM tree and storing the stored data in the allocated storage space includes:

[0017] Parse the data information sent by the Redis instance, and summarize the data information into the storage space corresponding to the parsed index in the non-volatile memory;

[0018] Map each parsed key value and data of the Redis instance into an LSM tree and store it in the storage address of the non-volatile memory in a sequential write manner.

[0019] Preferably, mapping each parsed key value and data of the Redis instance into an LSM tree and storing it in a storage address of the non-volatile memory in a sequential write manner includes:

[0020] Parse the key value and data corresponding to the data information sent by the Redis instance, and save them in the storage address of the LSM tree corresponding to the level where the key value is located;

[0021] The inactive data in the upper layer of the LSM tree is merged into ordered data and written into the storage address of the next layer of the LSM tree.

[0022] Preferably, the method further comprises:

[0023] Based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory, the data information of one or more Redis instances determined to be cold data is migrated from the non-volatile memory to the hard disk;

[0024] Alternatively, based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory, one or more groups of data of the Redis instance determined to be cold data are migrated from the non-volatile memory to the hard disk.

[0025] Preferably, the method further comprises:

[0026] Receive the read space operation request sent by the Redis instance;

[0027] Parsing the read space operation request, and searching for a storage space corresponding to the non-volatile memory according to the parsed index;

[0028] When the corresponding storage space is found in the non-volatile memory, the data information of the Redis instance is returned based on the storage space corresponding to the non-volatile memory;

[0029] When the corresponding storage space is not found in the non-volatile memory, the corresponding storage space on the hard disk is searched according to the parsed index; and the data information of the Redis instance is returned based on the storage space corresponding to the hard disk.

[0030] Preferably, the method further comprises:

[0031] When data information of one or more Redis instances stored on the hard disk is determined to be hot data, the data information of the Redis instances is migrated from the hard disk to the non-volatile memory;

[0032] Alternatively, when one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, one or more groups of data in the Redis instance are migrated from the hard disk to a non-volatile memory.

[0033] In a second aspect, the present invention provides a system for implementing a Redis in-memory database on a non-volatile memory, comprising:

[0034] Storage Space Manager and Non-Volatile Memory,

[0035] The storage space manager is configured to assign a unique index to each Redis instance; and according to the index, based on the specifications of the Redis instance, the storage space is allocated to the Redis instance in the non-volatile memory, and the key value and data of the Redis instance are mapped into the storage structure of the LSM tree and stored in the allocated storage space;

[0036] The storage space manager is further configured to feed back the allocated index and storage space to the Redis instance.

[0037] The system further comprises: a hard disk,

[0038] The storage space manager migrates data information of one or more Redis instances determined to be cold data from the non-volatile memory to the hard disk based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory;

[0039] Alternatively, the storage space manager migrates one or more groups of data of the Redis instance determined to be cold data from the non-volatile memory to the hard disk based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory.

[0040] The storage space manager receives a read space operation request sent by the Redis instance; parses the read space operation request, and searches for a storage space corresponding to the non-volatile memory according to the parsed index;

[0041] When the corresponding storage space is found in the non-volatile memory, the storage space manager returns the data information of the Redis instance based on the storage space corresponding to the non-volatile memory;

[0042] When the corresponding storage space is not found in the non-volatile memory, the storage space manager searches for the corresponding storage space on the hard disk according to the parsed index; and returns the data information of the Redis instance based on the storage space corresponding to the hard disk.

[0043] When data information of one or more Redis instances stored on the hard disk is determined to be hot data, the storage space manager migrates the data information of the Redis instances from the hard disk to the non-volatile memory;

[0044] When one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, the storage space manager migrates one or more groups of data of the Redis instance from the hard disk to a non-volatile memory.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] 1. Data is directly stored in non-volatile memory and maintains access speed close to that of memory;

[0047] 2. Convert the Redis data structure into LSM tree KV operation;

[0048] 3. Use the LSM tree hierarchy to separate hot and cold data;

[0049] 4. Remove the fork subprocess and export the full data. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A flowchart of a method for implementing a Redis in-memory database on a non-volatile memory according to an embodiment of the present invention;

[0051] Figure 2 A schematic diagram of the structure of a system for implementing a Redis in-memory database on a non-volatile memory according to an embodiment of the present invention;

[0052] Figure 3 This is a flowchart of writing an LSM tree according to an embodiment of the present invention;

[0053] Figure 4 This is a flow chart of LSM tree reading according to an embodiment of the present invention;

[0054] Figure 5 A schematic diagram of the Redis set structure conversion according to an embodiment of the present invention;

[0055] Figure 6 A schematic diagram of the Redis hash structure conversion according to an embodiment of the present invention;

[0056] Figure 7 Schematic diagram of linked list conversion according to an embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the invention objectives, technical solutions and beneficial effects of the present invention more clear, the embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be noted that, unless there is a conflict, the embodiments in this application and the features in the embodiments can be combined with each other arbitrarily.

[0058] like Figure 1 As shown, an embodiment of the present invention provides a method for implementing a Redis memory database on a non-volatile memory, characterized in that it includes:

[0059] S101. Assign a unique index to each Redis instance;

[0060] S102: Allocate storage space for the Redis instance in a non-volatile memory according to the index and based on the specification of the Redis instance, and map the key value and data of the Redis instance into a storage structure of an LSM tree and store them in the allocated storage space;

[0061] S103: Feedback the allocated index and storage space to the Redis instance.

[0062] In the prior art, there are three ways to write logs:

[0063] (1) Each sync: After each data entry is written into the memory, the database records the operation in the log file and calls the system's sync interface to ensure that the log data is written to the disk. Although this method ensures data persistence, it greatly increases access latency, and the write speed of the memory database is reduced to the write speed of the hard disk.

[0064] (2) Sync every second: After writing each piece of data to the memory, the database calls the operating system write interface to record the log. The log data will first be saved in the operating system cache, and the sync interface will be called every 1 second to write the data in the cache to the hard disk. In this way, if the machine restarts abnormally or loses power, the data in the operating system cache that has not been written to the disk will be lost. At the same time, when IO blocking occurs, the operating system write interface delay will also increase significantly.

[0065] (3) Asynchronous thread writes logs: After each data entry is written to the memory, the database writes the log of the operation to the queue. The background thread reads the log data from the queue, writes it to the hard disk in batches, and calls the sync interface to ensure that the data is written to the disk. In this way, if the process exits abnormally, the operating system restarts abnormally, or there is a power outage, the log data that has not been written to the disk will be lost. At the same time, caching the log data in the queue requires additional memory space. Due to the speed difference between the memory and the hard disk, frequent memory write operations will cause the queue for caching log data to be filled. In this case, the write delay of the memory database will inevitably increase.

[0066] The embodiment of the present invention maps the key value and data of the Redis instance to the storage structure of the LSM tree, so that the Redis instance is stored in the non-volatile memory with the LSM tree as the basic data structure. By utilizing the characteristics of the non-volatile memory, the data is stored in the non-volatile memory in a synchronous manner while maintaining the memory access speed, thereby improving the reliability of the memory database.

[0067] In an embodiment of the present invention, the method further includes:

[0068] The Redis instance maps the corresponding non-volatile memory storage space to the virtual address space of the current process based on the acquired storage space.

[0069] In an embodiment of the present invention, the method further includes:

[0070] Receive a space release operation request sent by the Redis instance;

[0071] Parsing the space release operation request, and deleting the storage space corresponding to the non-volatile memory requested to be released in the space release operation request according to the parsed index;

[0072] Feedback the release result to the Redis instance.

[0073] In the embodiment of the present invention, in step S102, mapping the key value and data of the Redis instance into a storage structure of an LSM tree and storing it in the allocated storage space includes:

[0074] Parse the data information sent by the Redis instance, and summarize the data information into the storage space corresponding to the parsed index in the non-volatile memory;

[0075] Map each parsed key value and data of the Redis instance into an LSM tree and store it in the storage address of the non-volatile memory in a sequential write manner.

[0076] Specifically, each parsed key value and data of the Redis instance is mapped into an LSM tree and stored in the non-volatile memory in a sequential write manner. The storage addresses include:

[0077] Parse the key value and data corresponding to the data information sent by the Redis instance, and save them in the storage address of the LSM tree corresponding to the level where the key value is located;

[0078] The inactive data in the upper layer of the LSM tree is merged into ordered data and written into the storage address of the next layer of the LSM tree.

[0079] In an embodiment of the present invention, the method further includes:

[0080] Based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory, the data information of one or more Redis instances determined to be cold data is migrated from the non-volatile memory to the hard disk;

[0081] Alternatively, based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory, one or more groups of data of the Redis instance determined to be cold data are migrated from the non-volatile memory to the hard disk.

[0082] The embodiment of the present invention can save cold data on a hard disk such as an SSD with a slower speed but larger capacity based on the cold and hot characteristics of the data. In addition, the embodiment of the present invention supports running multiple redis instance data information at the same time.

[0083] In an embodiment of the present invention, the method further includes:

[0084] Receive the read space operation request sent by the Redis instance;

[0085] Parsing the read space operation request, and searching for a storage space corresponding to the non-volatile memory according to the parsed index;

[0086] When the corresponding storage space is found in the non-volatile memory, the data information of the Redis instance is returned based on the storage space corresponding to the non-volatile memory;

[0087] When the corresponding storage space is not found in the non-volatile memory, the corresponding storage space on the hard disk is searched according to the parsed index; and the data information of the Redis instance is returned based on the storage space corresponding to the hard disk.

[0088] In an embodiment of the present invention, the method further includes:

[0089] When data information of one or more Redis instances stored on the hard disk is determined to be hot data, the data information of the Redis instances is migrated from the hard disk to the non-volatile memory;

[0090] Alternatively, when one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, one or more groups of data in the Redis instance are migrated from the hard disk to a non-volatile memory.

[0091] like Figure 2 As shown, an embodiment of the present invention is a system for implementing a Redis memory database on a non-volatile memory, including a storage space manager and a non-volatile memory.

[0092] The storage space manager is configured to assign a unique index to each Redis instance; and according to the index, based on the specifications of the Redis instance, the storage space is allocated to the Redis instance in the non-volatile memory, and the key value and data of the Redis instance are mapped into the storage structure of the LSM tree and stored in the allocated storage space;

[0093] The storage space manager is further configured to feed back the allocated index and storage space to the Redis instance.

[0094] In the embodiment of the present invention, the system further comprises: a hard disk,

[0095] The storage space manager migrates data information of one or more Redis instances determined to be cold data from the non-volatile memory to the hard disk based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory;

[0096] Alternatively, the storage space manager migrates one or more groups of data of the Redis instance determined to be cold data from the non-volatile memory to the hard disk based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory.

[0097] In an embodiment of the present invention, the storage space manager receives a read space operation request sent by a Redis instance; parses the read space operation request, and searches for a storage space corresponding to the non-volatile memory according to the parsed index;

[0098] When the corresponding storage space is found in the non-volatile memory, the storage space manager returns the data information of the Redis instance based on the storage space corresponding to the non-volatile memory;

[0099] When the corresponding storage space is not found in the non-volatile memory, the storage space manager searches for the corresponding storage space on the hard disk according to the parsed index; and returns the data information of the Redis instance based on the storage space corresponding to the hard disk.

[0100] In the embodiment of the present invention, when data information of one or more Redis instances stored on the hard disk is determined to be hot data, the storage space manager migrates the data information of the Redis instances from the hard disk to the non-volatile memory;

[0101] When one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, the storage space manager migrates one or more groups of data of the Redis instance from the hard disk to a non-volatile memory.

[0102] Embodiment 1

[0103] like Figure 2 As shown, the system structure of the embodiment of the present invention, Redis is a kind of KV database, the present invention is compatible with the Redis protocol but changes its storage method. Based on the non-volatile memory, it also has the characteristic that sequential write performance is better than random write performance, and the LSM tree is used as the basic data structure. SST data at different levels on the LSM tree are stored in the non-volatile memory, and the cold data can be stored on hard disks such as SSDs with slower speed but larger capacity based on the hot and cold characteristics of the data. The LSM tree provides GET and SET KV interfaces to the outside, which are used for reading and writing data respectively. The system supports running multiple redis instance databases at the same time, so it is necessary to divide and manage the space of the non-volatile memory.

[0104] The structure of this system is as follows Figure 2 As shown, its main components are: LSM tree: stored in non-volatile memory and SSD hard disk, providing KV interface GET and SET to the outside world.

[0105] Space Meta: metadata information about space division, recording the space ranges occupied by different Redis instances.

[0106] Instance Meta: Instance metadata information, which records the spatial information of the LSM tree SST table and the structural information of the LSM tree under a single instance.

[0107] Space Manager: Responsible for the management of instance storage space allocation and release. Network IO: Responsible for sending and receiving network data.

[0108] Protocol Parser: responsible for parsing the redis protocol.

[0109] Replication: Responsible for data synchronization between instances.

[0110] Struct Map: responsible for mapping redis list, set, hash, string and other operations into Get / Set KV operations.

[0111] Index: Create an index for part of the LSM tree SST table data in DRAM.

[0112] In this embodiment, the non-volatile space management process is as follows:

[0113] 1. Allocation

[0114] After the instance process is started, it requests the Space Manager to allocate non-volatile memory space through the inter-process communication interface. The Space Manager allocates non-volatile memory space based on the instance specifications and informs the relevant instances of the allocated space range. Based on the allocated space range, the instance maps the corresponding non-volatile memory space to the virtual address space of the process through the mmap interface.

[0115] 2. Release

[0116] The instance munmaps the space to be released, notifies the Space Manager of the non-volatile memory space range to be released through the inter-process communication interface, and the Space Manager releases the corresponding space, updates the relevant metadata information, and informs the release result;

[0117] 3. LSM tree writing process

[0118] The LSM tree writing process is as follows Figure 3As shown. The LSM tree is divided into several layers from 0 to N, and the upper layer data will be written to the lower layer data after being merged. The L0 SST table data is stored out of order, and the data is stored in order starting from L1. Each L0 SST table has a corresponding Skiplist in the DRAM memory. The Skiplist stores the corresponding key value in the memory and the storage address saved in the non-volatile memory. At the same time, L0 has only one active SST table. When the active SST table is full, a new active SST table will be created; the inactive SST tables of L0 are merged into ordered storage data and written to the SST table of the next layer L1. The specific process is as follows: The SET operation writes the corresponding key and value to the L0 active SST table in a sequential manner, inserts the corresponding key and the data into the Skiplist of DRAM and stores them in the non-volatile memory address of the SST table, and creates a new L0 active SST table after the L0 active SST table is full. The original L0 inactive table is set to an inactive table. The inactive table is merged into ordered data and stored as the SST table of the next layer L1. The data of each layer of SST tables is merged to remove duplicate and old data, and a new SST table is generated and saved to the next layer.

[0119] 4. LSM tree reading process

[0120] The LSM tree reading process is as follows Figure 4 As shown. Search for the corresponding key in the Skiplist of L0. If found, read the value from the corresponding non-volatile memory address. If not found, execute the next step from L1 to LN to search for the corresponding key based on the index data of each layer. 2.1 If the data is stored in the non-volatile memory, return the corresponding data based on the non-volatile memory address. 2.2 If the data is stored in the hard disk, read the corresponding data into the memory and return it. 2.3 If no relevant data is found, repeat step 2 at the next layer.

[0121] 5. Redis data type conversion

[0122] In the Redis KV database, the data types of Value mainly include String, Set, Hash, and List. Although the LSM tree is also a KV storage, Value only supports the String type format. Set, Hash, and List need to be converted and stored in the LSM tree.

[0123] 1. Redis set structure conversion

[0124] Redis set represents a set. The characteristics of the set determine that the data in the set is unique. The conversion method is to combine each member in the redis set with the redis key value to form a new key. The LSM tree stores this new key and the value is empty. Figure 5 shown.

[0125] 2. Redis hash structure conversion

[0126] The redis hash structure indicates that the value corresponding to the key is a hash table structure. Since each item in the hash table is also in KV format, the conversion method is to form a new key from the key and the key of the item in the hash table. The LSM tree stores this new key and the value of the item in the hash table. Figure 6 shown.

[0127] 3. Redis list structure conversion

[0128] The redis list structure indicates that the value corresponding to the key is a list structure. Since the linked list may have many data members and may be read, inserted, or deleted at any position in the linked list, the index data of the linked list needs to be saved in the KV structure of the LSM tree. At the same time, in order to support fast access to a large amount of data, the index is divided into two layers. The main function of the index is to record the correspondence between the member serial number and the RowID in the list. The conversion structure of the relevant linked list is as follows: Figure 7 shown.

[0129] The structure is as follows: Create a KV in the LSM tree to save the metadata of the Redis list. The key is the key value of Redis, and the value metadata includes:

[0130] 1.1RowID: This value always increases. Each time data is inserted into the list, the value increases by 1. Deleting data from the list does not affect the value.

[0131] 1.2I0_Num: indicates the number of indexes at level 0;

[0132] 1.3I1_Size: indicates the number of index values ​​stored in each item of the first-level index;

[0133] 1.4ItemsNum: indicates the number of members in the list structure.

[0134] 2. Create the KV structure of the Redis list's 0th-level index in the LSM tree. Each item in the 0th-level index corresponds to the corresponding item in the 1st-level index. The key consists of the redis key value, I0 identifier, and I0 sequence number. The value consists of the starting sequence number and the number of corresponding 1st-level index values.

[0135] 3. Create the KV structure of the first-level index of the Redis list in the LSM tree. The key consists of the redis key value, I1 identifier, and I1 sequence number; the value is the RowID array. The first-level index is sorted by sequence number, and the sequence of the index value corresponds to the sequence of each item in the list.

[0136] 4. Create a KV structure for each item in the Redis list in the LSM tree. The key consists of the redis key value and RowID, and the value is the value of the item in the redis list.

[0137] 6. Separation of hot and cold data

[0138] The LSM tree has a hierarchical structure. The newly written data is stored in the active SST table of L0, and then the upper layer data is written to the next layer through continuous merging operations. The amount of data in the lower layer is larger, and the data in the lowest layers can be stored in hard disks with larger capacity but slower speed. Therefore, in terms of write operations, the deeper the level of the LSM tree, the colder the data. For the hot and cold data of the read operation, the hot and cold data characteristics of the write operation can be used. The specific process is as follows:

[0139] Search for data layer by layer starting from L0; if the data is stored in non-volatile memory, directly return the corresponding storage value; if the data is stored in the hard disk, read the corresponding value and return the corresponding storage value; if the data is accessed multiple times and meets the hot data standard, re-execute the write operation and store the data in L0.

[0140] Although the embodiments disclosed in the present invention are as above, the contents are only embodiments adopted for facilitating understanding of the technical solution of the present invention, and are not used to limit the present invention. Any technician in the technical field to which the present invention belongs can make any modifications and changes in the form and details of the implementation without departing from the core technical solution disclosed in the present invention, but the protection scope defined by the present invention shall still be subject to the scope defined in the attached claims.

Claims

1. A method for implementing a Redis in-memory database on a non-volatile memory, characterized in that: include: Assign a unique index to each Redis instance; According to the index, allocating storage space for the Redis instance in a non-volatile memory based on the specification of the Redis instance; Parse the data information sent by the Redis instance, and summarize the data information into the storage space corresponding to the parsed index in the non-volatile memory; Parse the key value and data corresponding to the data information sent by the Redis instance, and save them in the storage address of the LSM tree corresponding to the level where the key value is located; Merge the inactive data in the previous layer of the LSM tree into ordered data and write them into the storage address of the next layer of the LSM tree; Feedback the allocated index and storage space to the Redis instance.

2. The method according to claim 1, characterized in that: The method further comprises: The Redis instance maps the corresponding non-volatile memory storage space to the virtual address space of the current process based on the acquired storage space.

3. The method according to claim 1, characterized in that The method further comprises: Receive a space release operation request sent by the Redis instance; Parsing the space release operation request, and deleting the storage space corresponding to the non-volatile memory requested to be released in the space release operation request according to the parsed index; Feedback the release result to the Redis instance.

4. The method according to claim 1, characterized in that: The method further comprises: Based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory, the data information of one or more Redis instances determined to be cold data is migrated from the non-volatile memory to the hard disk; Alternatively, based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory, one or more groups of data of the Redis instance determined to be cold data are migrated from the non-volatile memory to the hard disk.

5. The method according to claim 4, characterized in that The method further comprises: Receive the read space operation request sent by the Redis instance; Parsing the read space operation request, and searching for a storage space corresponding to the non-volatile memory according to the parsed index; When the corresponding storage space is found in the non-volatile memory, the data information of the Redis instance is returned based on the storage space corresponding to the non-volatile memory; When the corresponding storage space is not found in the non-volatile memory, the corresponding storage space on the hard disk is searched according to the parsed index; and the data information of the Redis instance is returned based on the storage space corresponding to the hard disk.

6. The method according to claim 4, characterized in that The method further comprises: When data information of one or more Redis instances stored on the hard disk is determined to be hot data, the data information of the Redis instances is migrated from the hard disk to the non-volatile memory; Alternatively, when one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, one or more groups of data in the Redis instance are migrated from the hard disk to a non-volatile memory.

7. A system for implementing a Redis in-memory database on a non-volatile memory, characterized in that: Includes storage space manager and non-volatile memory, The storage space manager is configured to allocate a unique index to each Redis instance; and according to the index, allocate storage space for the Redis instance in the non-volatile memory based on the specifications of the Redis instance; parse the data information sent by the Redis instance, and summarize the data information into the storage space corresponding to the parsed index in the non-volatile memory; parse the key value and data corresponding to the data information sent by the Redis instance, and save them in the storage address of the LSM tree corresponding to the level where the key value is located; merge the inactive data in the upper layer of the LSM tree into ordered data and write them into the storage address of the next layer of the LSM tree; The storage space manager is further configured to feed back the allocated index and storage space to the Redis instance.

8. The system according to claim 7, characterized in that Also includes: harddisk, The storage space manager is based on the hot and cold characteristics of the data of each Redis instance stored in the non-volatile memory; Migrate the data information of one or more Redis instances that are determined to be cold data from non-volatile memory to the hard disk; Alternatively, the storage space manager migrates one or more groups of data of the Redis instance determined to be cold data from the non-volatile memory to the hard disk based on the hot and cold characteristics of each group of data of the Redis instance stored in the non-volatile memory.

9. The system according to claim 8, characterized in that The storage space manager receives a read space operation request sent by the Redis instance; parses the read space operation request, and searches for a storage space corresponding to the non-volatile memory according to the parsed index; When the corresponding storage space is found in the non-volatile memory, the storage space manager returns the data information of the Redis instance based on the storage space corresponding to the non-volatile memory; When the corresponding storage space is not found in the non-volatile memory, the storage space manager searches for the corresponding storage space on the hard disk according to the parsed index; and returns the data information of the Redis instance based on the storage space corresponding to the hard disk.

10. The system according to claim 8, characterized in that When data information of one or more Redis instances stored on the hard disk is determined to be hot data, the storage space manager migrates the data information of the Redis instances from the hard disk to the non-volatile memory; When one or more groups of data in a Redis instance stored on a hard disk are determined to be hot data, the storage space manager migrates one or more groups of data of the Redis instance from the hard disk to a non-volatile memory.