A data storage method and apparatus
By writing data to a target list and deleting cached historical values when receiving data to be updated in internet finance scenarios, and synchronizing distributed database values to the cache after a preset time, the accuracy problem caused by untimely data synchronization is solved, and the accuracy and consistency of data acquisition are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEBANK (CHINA)
- Filing Date
- 2022-06-15
- Publication Date
- 2026-05-29
AI Technical Summary
In internet finance scenarios, existing technologies suffer from reduced accuracy and the problem of retrieving outdated data due to untimely data synchronization between relational databases and Redis.
Upon receiving data to be updated, the storage key and value are determined and written to the target list. Historical values in the cache are deleted, and after a preset time, the target storage value is retrieved from the distributed database and synchronized to the cache to ensure data consistency.
This improves the accuracy of data acquisition, avoids erroneous data issues caused by reading historical values from the cache, and ensures consistency after data synchronization.
Smart Images

Figure CN115098519B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage technology, and in particular to a data storage method and apparatus. Background Technology
[0002] In internet finance scenarios, data is typically stored in storage locations with low latency and high throughput, such as Redis. However, since Redis can only store a small amount of data, it is usually used to store a portion of the data, while other databases with larger storage capacities (such as relational databases) are used to store the full amount of data.
[0003] In existing technologies, data is first stored in a relational database. If storage is successful in the relational database, a success response is sent. Then, the data is synchronized from the relational database to Redis. When retrieving data, it is first retrieved from Redis. If the stored data is updated data, and the updated data is successfully stored in the relational database but not synchronized to Redis in a timely manner, when a data retrieval command is received, because the old data in Redis has not been updated with the updated data, the old data will be retrieved from Redis according to the data retrieval command, i.e., incorrect data will be retrieved, which reduces the accuracy of data retrieval. Summary of the Invention
[0004] To address the aforementioned technical problems, this application aims to provide a data storage method and apparatus that can improve the accuracy of data acquisition.
[0005] The technical solution of this application is implemented as follows:
[0006] This application provides a data storage method, the data storage method comprising:
[0007] Upon receiving the data to be updated transmitted by the first client, determine the first storage key and the first storage value of the data to be updated, and write the first storage key into the target list;
[0008] Write the first storage key and the first storage value into the distributed database;
[0009] Locate the historical value corresponding to the first storage key in the cache and delete the historical value;
[0010] When the preset time arrives, the target storage value corresponding to the target storage key in the target list is retrieved from the distributed database; the target storage key includes the first storage key.
[0011] The target stored value is synchronized to the cache.
[0012] This application provides a data storage device, the device comprising:
[0013] The determining unit is configured to determine the first storage key and the first storage value of the data to be updated upon receiving the data to be updated transmitted by the first client.
[0014] The writing unit is used to write the first storage key into the target list; and to write the first storage key and the first storage value into the distributed database.
[0015] The lookup unit is used to look up the historical value corresponding to the first storage key in the cache;
[0016] The deletion unit is used to delete the historical value;
[0017] The acquisition unit is configured to acquire, upon arrival of a preset time, the target storage value corresponding to the target storage key in the target list from the distributed database; the target storage key includes the first storage key;
[0018] A synchronization unit is used to synchronize the target stored value to the cache.
[0019] This application provides a data storage device, the device comprising:
[0020] The system includes a memory, a processor, and a communication bus. The memory communicates with the processor via the communication bus. The memory stores a program for storing data that the processor can execute. When the program for storing data is executed, the processor performs the data storage method described above.
[0021] This application provides a data storage method and apparatus. The data storage method includes: upon receiving data to be updated transmitted from a first client, determining a first storage key and a first storage value for the data to be updated, and writing the first storage key into a target list; writing the first storage key and the first storage value into a distributed database; searching for a historical value corresponding to the first storage key in a cache and deleting the historical value; upon reaching a preset time, retrieving a target storage value corresponding to a target storage key in the target list from the distributed database; the target storage key includes the first storage key; and synchronizing the target storage value to the cache. By employing the above method, after writing the data to be updated into the distributed database, the data storage apparatus deletes the historical value corresponding to the first storage key from the cache before updating the data in the cache with the data to be updated. This ensures that upon receiving a data retrieval command, the historical value corresponding to the first storage key will not be read from the cache, allowing data to be retrieved from the distributed database and thus obtaining the first storage value, i.e., obtaining accurate data, thereby improving the accuracy of data retrieval. Attached Figure Description
[0022] Figure 1 This application provides a schematic diagram of data storage in the prior art.
[0023] Figure 2 A flowchart illustrating a data storage method provided in this application embodiment;
[0024] Figure 3 An exemplary data storage method flow provided for embodiments of this application Figure 1 ;
[0025] Figure 4 An exemplary data storage method flow provided for embodiments of this application Figure 2 ;
[0026] Figure 5 An exemplary data storage method flow provided for embodiments of this application Figure 3 ;
[0027] Figure 6 A schematic diagram of the composition structure of a data storage device provided in this application embodiment. Figure 1 ;
[0028] Figure 7 A schematic diagram of the composition structure of a data storage device provided in this application embodiment. Figure 2 . Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0030] In internet finance scenarios, Redis, an in-memory key-value database, is widely used due to its low latency and high throughput. Although Redis offers persistence solutions such as AOF (Append Only File, which appends Redis operation logs to a file) and RDB (Redis Database, which periodically dumps Redis database records from memory to disk), master-slave replication is still asynchronous. When the master node fails, the slave node may lose data that hasn't been synchronized. Therefore, when data is critical, Redis cannot be used as persistent storage; a relational database is typically used as a fallback.
[0031] like Figure 1As shown: The application simultaneously writes data to both a Redis database and a relational database. Once the write to the relational database is successful, the application returns a success message. Data can then be read from both databases. A separate asynchronous process compares the data in the relational and Redis databases (verifying data consistency). If inconsistencies are found, the data in the relational database takes precedence.
[0032] Example 1
[0033] This application provides a data storage method, which is applied to a data storage device. Figure 2 A flowchart of a data storage method provided in an embodiment of this application is shown below. Figure 2 As shown, data storage methods may include:
[0034] S101. Upon receiving the data to be updated transmitted by the first client, determine the first storage key and the first storage value of the data to be updated, and write the first storage key into the target list.
[0035] The data storage method provided in this application embodiment is applicable to scenarios where distributed databases and caches are used to store data to be updated.
[0036] In the embodiments of this application, the data storage device can be implemented in various forms. For example, the data storage device described in this application may include devices such as mobile phones, cameras, tablet computers, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, etc., as well as devices such as digital TVs, desktop computers, servers, etc.
[0037] In this embodiment of the application, the data to be updated can be data from the Internet finance field; the data to be updated can also be other data; the specific data to be updated can be determined according to the actual situation, and this embodiment of the application does not limit it.
[0038] In this embodiment of the application, the number of data to be updated can be one, two, or multiple; the specific number of data to be updated can be determined according to the actual situation, and this embodiment of the application does not limit it.
[0039] In this embodiment of the application, the number of first clients can be one, two, or multiple; the specific number of first clients can be determined according to the actual situation, and this embodiment of the application does not limit this.
[0040] In this embodiment, the target list is a list that records the first storage key. The target list can be a list configured in the data storage device.
[0041] For example, the target list can be a do_key_list list.
[0042] In this embodiment, both the distributed database and the cache are databases using Key-Value (KV) data storage format. Here, K represents the key of the data, and V represents the value of the data.
[0043] It should be noted that the first storage key is K, which is the data to be updated, and the first storage value is V, which is the data to be updated.
[0044] S102. Write the first storage key and the first storage value into the distributed database.
[0045] In this embodiment of the application, after the data storage device determines the first storage key and the first storage value of the data to be updated, the data storage device can write the first storage key and the first storage value into the distributed database.
[0046] In this embodiment, the distributed database can be a TiKV database; it can also be other key-value stores based on the Raft protocol, with corresponding customizations, such as LevelDB and RocksDB. The specific distributed database can be determined according to the actual situation, and this embodiment does not limit it.
[0047] In this embodiment of the application, if the distributed data is a TIKV database, then TIKV may include a serial advanced technology attachment (SATA) and a memory machine.
[0048] In this embodiment of the application, the data storage device is provided with a key-value database proxy gateway. When the proxy gateway in the data storage device receives the data to be updated transmitted by the first client, the data storage device uses the proxy gateway to store the first storage key and the first storage value into the distributed database.
[0049] In this embodiment of the application, before the data storage device determines the first storage key and the first storage value of the data to be updated, the data storage device, upon receiving the data to be updated transmitted by the first client, will also determine the timestamp of the received data; correspondingly, the process of the data storage device writing the first storage key into the target list includes: the data storage device writing the timestamp and the first storage key into the target list.
[0050] In the embodiments of this application, the timestamp is the time accurate to the second, such as: year, month, day, hour, minute, second.
[0051] In this embodiment of the application, after the data storage device determines that it has received the timestamp of the data to be updated, if it fails to write the timestamp and the first storage key into the target list, the data storage device transmits a response message indicating that the data to be updated has failed to be written to the first client.
[0052] In this embodiment, after the data storage device writes the first storage key into the target list, if writing the data to be updated to the distributed database fails, the data storage device transmits a response message indicating that the data to be updated has failed to be written to the first client. If writing the data to be updated to the distributed database is successful, the data storage device transmits a response message indicating that the data to be updated has been successfully written to the first client.
[0053] In this embodiment, the process of the data storage device writing the first storage key and the first storage value into the distributed database includes: the data storage device storing the first storage key and the first storage value into the master node of the distributed database; if the data storage device successfully stores the first storage key and the first storage value using the master node, synchronizing the first storage key and the first storage value in the master node to the slave nodes in the distributed database, so that when retrieving stored data from the distributed database, the first storage value is preferentially retrieved from the slave nodes; if the data storage device successfully stores the first storage key and the first storage value using the slave nodes, it determines that the data to be updated has been successfully stored using the distributed database.
[0054] It should be noted that the master node is used for reading or writing data; the slave node is used for reading data. There can be one slave node, two slave nodes, or multiple slave nodes; the specific number of slave nodes can be determined based on the actual situation, and this application embodiment does not limit this.
[0055] It should also be noted that the number of master nodes can be one; the number of master nodes can be two; the number of master nodes can also be multiple; the specific number of master nodes can be determined according to the actual situation, and this application embodiment does not limit this.
[0056] It should also be noted that if the distributed data is a TiKV database, the master node can be a SATA master node; the master node can also be other types of master nodes; the specific choice can be determined based on the actual situation, and this application embodiment does not limit this. If the distributed data is a TiKV database, the slave node can be a SATA slave node; the slave node can also be a Memory Machine slave node; the slave node can also be a Memory Machine slave node and a SATA slave node; the specific choice can be determined based on the actual situation, and this application embodiment does not limit this.
[0057] In this embodiment of the application, the process by which the data storage device stores the data to be updated in the master node of the distributed database includes: the proxy gateway first accesses the cluster management module (Placement Driver Server, PD), obtains the storage block (region) information corresponding to the first storage key of the data to be updated from the PD, and then stores the data to be updated (the first storage key and the first storage value) in the region of the distributed database, that is, stores it in the master node and the slave node of the distributed database.
[0058] In this embodiment, if there are multiple slave nodes, the process by which the data storage device determines that the distributed database has been successfully used to store the first storage key and the first storage value when the data storage device successfully stores the first storage key and the first storage value using the slave nodes can be as follows: the data storage device determines that the distributed database has been successfully used to store the data to be updated when the data storage device successfully stores the first storage key and the first storage value using multiple slave nodes; or the data storage device determines that the distributed database has been successfully used to store the data to be updated when the data storage device successfully stores the first storage key and the first storage value using some of the multiple slave nodes. The specific determination can be made according to the actual situation, and this embodiment does not limit it in this way.
[0059] In this embodiment, the data storage device may determine that the data to be updated has been successfully stored using the distributed database when some slave nodes and some master nodes (the sum of the number of some master nodes and some slave nodes is a preset number of nodes) successfully store the first storage key and the first storage value; or when some master nodes successfully store the first storage key and the first storage value; or when all master nodes successfully store the first storage key and the first storage value. The specific determination can be made according to the actual situation, and this embodiment does not limit it.
[0060] S103. Locate the historical value corresponding to the first storage key in the cache and delete the historical value.
[0061] In this embodiment, the data storage device can first write the first storage key and the first storage value into the distributed database, and then the data storage device searches for the historical value corresponding to the first storage key in the cache and deletes the historical value; the data storage device can also search for the historical value corresponding to the first storage key in the cache and delete the historical value at the same time as writing the first storage key and the first storage value into the distributed database; the specific method can be determined according to the actual situation, and this embodiment does not limit it.
[0062] In this embodiment of the application, after the data storage device searches for the historical value corresponding to the first storage key in the cache and deletes the historical value, if the data storage device determines that the deletion of the historical value has failed, it retrieves the first storage value from the distributed database and retrieves the second storage value corresponding to the first storage key from the cache; if the first storage value and the second storage value are different, the data storage device deletes the second storage value.
[0063] In this embodiment of the application, if the data storage device determines that deleting the historical value has failed, the data storage device continues to delete the historical value.
[0064] It should be noted that the second stored value is the historical value.
[0065] S104. When the preset time arrives, retrieve the target storage value corresponding to the target storage key in the target list from the distributed database; the target storage key includes the first storage key.
[0066] In this embodiment of the application, after the data storage device searches for the historical value corresponding to the first storage key in the cache and deletes the historical value, when the preset time arrives, the data storage device can obtain the target storage value corresponding to the target storage key in the target list from the distributed database.
[0067] It should be noted that the target storage key includes the first storage key.
[0068] In this embodiment, the preset time can be the time configured in the data storage device, or the time when other devices transmit data to the data storage device; the preset time can also be data obtained by the data storage device in other ways; the specific way the data storage device obtains the preset time can be determined according to the actual situation, and this embodiment does not limit it.
[0069] In this embodiment, there are multiple preset times. For example, a preset time can be set every 5 minutes; or a preset time can be set every 3 minutes; the specific time interval between preset times can be determined according to the actual situation, and this embodiment does not limit it.
[0070] In this embodiment of the application, the target storage key can be the storage key corresponding to the received data, which is the time period between the preset time and the previous preset time.
[0071] In this embodiment of the application, the process by which the data storage device retrieves the target storage value corresponding to the target storage key in the target list from the distributed database when the preset time arrives includes: the data storage device determining the target storage key written within the last preset time and preset time period from the target list; and the data storage device retrieving the target storage value corresponding to the target storage key from the distributed database when the preset time arrives.
[0072] In the embodiments of this application, the number of target storage keys can be one, two, or multiple. The specific number of target storage keys can be determined according to the actual situation, and this application does not limit this.
[0073] For example, if the number of target storage keys can be one, then the target storage key is the first storage key.
[0074] S105. Synchronize the target stored value to the cache.
[0075] In this embodiment of the application, after the data storage device obtains the target storage value corresponding to the target storage key in the target list in the distributed database, the data storage device can synchronize the target storage value to the cache.
[0076] In this embodiment of the application, the process of the data storage device synchronizing the target stored value to the cache can be that the data storage device uses a proxy gateway to synchronize the target stored value to the cache.
[0077] It should be noted that the cache and the distributed database have the same data storage format, both being key-value data storage databases.
[0078] In this embodiment, the cache can be Redis, or other storage modules. The specific cache module can be determined according to the actual situation, and this embodiment does not limit it.
[0079] In this embodiment of the application, the process of the data storage device synchronizing the target stored value to the cache includes: the data storage device using a proxy gateway to synchronize the target stored value to the cache master node; and the data storage device determining that the cache has successfully synchronized the data to be updated when the target stored value is successfully stored using the cache master node.
[0080] In this embodiment of the application, the number of cache master nodes can be one, two, or multiple; the specific number of cache master nodes can be determined according to the actual situation, and this embodiment of the application does not limit this.
[0081] In this embodiment, after the data storage device synchronizes the target stored value to the cache master node using the proxy gateway, if the data storage device fails to store the target stored value using the cache master node, it continues to write the target stored value to the cache master node using the verification component until the cache master node successfully stores the data to be updated.
[0082] It should be noted that the data storage device is equipped with a verification component.
[0083] In this embodiment, the data storage device can continue writing the target stored value to the cache master node using a verification component if the first attempt to store the target stored value using the cache master node fails, until the cache master node successfully stores the target stored value; the data storage device can also continue writing the target stored value to the cache master node using a verification component if the number of storage failures using the cache master node is greater than or equal to a preset number, until the cache master node successfully stores the target stored value; the specific method can be determined according to the actual situation, and this embodiment does not limit it.
[0084] It should be noted that the preset number of times can be the number of times configured in the data storage device; the preset number of times can be the number of times transmitted from other devices to the data storage device; the specific way the data storage device obtains the preset number of times can be determined according to the actual situation, and this application embodiment does not limit this.
[0085] For example, the preset number of times can be 3 times, the preset number of times can be 5 times, or other preset number of times values can be used; the specific preset number of times can be determined according to the actual situation, and this application embodiment does not limit it in this way.
[0086] In this embodiment, after the data storage device synchronizes the target stored value to the cache, when the verification time arrives, the data storage device uses the verification component to compare the first data written to the distributed database by the proxy gateway with the second data synchronized to the cache by the proxy gateway; if it is determined that the first data and the second data are different, the second data is modified using the first data.
[0087] It should be noted that the first data includes the data to be updated. The second data is all the data in the cache; the first data and the second data have the same data key.
[0088] In this embodiment, the verification time can be the time configured in the data storage device; the verification time can also be the time information transmitted from other devices to the data storage device; the specific way the data storage device obtains the verification time can be determined according to the actual situation, and this embodiment does not limit it.
[0089] For example, the verification time can be 12 o'clock every night; the verification time can also be every Monday; the verification time can also be other regular times; the specific verification time can be determined according to the actual situation, and this application embodiment does not limit it.
[0090] In this embodiment, there are multiple first data and second data. The process by which the data storage device compares the first data written to the distributed database by the proxy gateway and the second data synchronized to the cache by the proxy gateway using a verification component includes: the data storage device obtaining multiple first keys and multiple first values corresponding to multiple first data, and multiple first keys and multiple second values corresponding to multiple second data; the data storage device grouping the multiple first keys according to a preset group number to obtain multiple sets of first keys; the data storage device obtaining multiple sets of first values and multiple sets of second values corresponding to the multiple sets of first keys; the data storage device encrypting each set of first values in the multiple sets of first values to obtain multiple first encrypted values; encrypting each set of second values in the multiple sets of second values to obtain multiple second encrypted values; the data storage device comparing the multiple first encrypted values with the multiple second encrypted values; correspondingly, the process by which the data storage device modifies the second data using the first data when it determines that the first data and the second data are different includes: the data storage device determining that the first data and the second data are different when the multiple first encrypted values are different from the multiple second encrypted values; the data storage device modifying the second data using the first data.
[0091] It should be noted that multiple first keys include the first storage key.
[0092] In this embodiment of the application, the multiple first keys are the keys of multiple first data, and the multiple first values are the values of multiple first data, that is, one first key corresponds to one first value and one first data.
[0093] In this embodiment of the application, the multiple first keys are the keys of multiple second data, and the multiple second values are the values of multiple second data, that is, one first key corresponds to one second value and one second data.
[0094] In this embodiment, the preset number of groups can be the number configured in the data storage device; the preset number of groups can also be the number transmitted to the data storage device by other devices; the preset number of groups can also be the number obtained by the data storage device in other ways; the specific number can be determined according to the actual situation, and this embodiment does not limit it.
[0095] For example, the preset number of groups can be 10, 20, or 5; the specific number of preset groups can be determined according to the actual situation, and this application embodiment does not limit it.
[0096] In the embodiments of this application, multiple sets of first keys correspond one-to-one with multiple sets of first values, that is, one set of first keys corresponds to one set of first values; multiple sets of first keys correspond one-to-one with multiple sets of second values, that is, one set of first keys corresponds to one set of second values.
[0097] In this embodiment of the application, the process by which the data storage device encrypts each of the multiple sets of first values to obtain multiple first encrypted values can be that the data storage device uses MD5 to encrypt each of the multiple sets of first values to obtain multiple first encrypted values; or the data storage device uses other encryption algorithms to encrypt each of the multiple sets of first values to obtain multiple first encrypted values. The specific method can be determined according to the actual situation, and this embodiment of the application does not limit it.
[0098] In this embodiment, the process by which the data storage device encrypts each of the multiple sets of second values to obtain multiple second encrypted values can be as follows: the data storage device can use MD5 to encrypt each of the multiple sets of second values to obtain multiple second encrypted values; or the data storage device can use other encryption algorithms to encrypt each of the multiple sets of second values to obtain multiple second encrypted values. The specific method can be determined according to the actual situation, and this embodiment does not limit it.
[0099] In this embodiment of the application, when multiple first encrypted values are different from multiple second encrypted values, the data storage device determines that the first data and the second data are different; then the data storage device deletes the second data and synchronizes the first data to the cache, that is, it uses the first data to modify the second data.
[0100] In this embodiment of the application, the data storage device compares the first encrypted value among a plurality of first encrypted values with the first encrypted value among a plurality of second encrypted values; then the data storage device compares the second encrypted value among a plurality of first encrypted values with the second encrypted value among a plurality of second encrypted values; ..., until the data storage device compares the last encrypted value among a plurality of first encrypted values with the last encrypted value among a plurality of second encrypted values, thereby realizing the comparison process of a plurality of first encrypted values with a plurality of second encrypted values.
[0101] In this embodiment, the target storage key is a subset of storage keys in the target list. The data storage device can also periodically retrieve multiple incremental storage keys within a specific time period from the target list, retrieve multiple first incremental storage values corresponding to these multiple incremental storage keys from the distributed database, and retrieve multiple second incremental storage values corresponding to these multiple incremental storage keys from the cache. The multiple incremental storage keys are grouped according to a preset grouping number to obtain multiple sets of storage keys. Multiple sets of first incremental storage values and multiple sets of second incremental values corresponding to the multiple sets of storage keys are retrieved. The multiple sets of first incremental storage values are encrypted to obtain multiple third encrypted values. The multiple sets of second incremental storage values are encrypted to obtain multiple fourth encrypted values. The multiple third encrypted values are compared with the multiple fourth encrypted values. If the multiple third encrypted values are different from the multiple fourth encrypted values, the multiple fourth incremental storage values are modified using the multiple first incremental storage values.
[0102] In this embodiment of the application, after determining the first storage key and the first storage value of the data to be updated, and before synchronizing the target storage value to the cache, the data storage device retrieves the first storage value from the distributed database and the second storage value corresponding to the first storage key from the cache in the event of a cache master node switch; if the first storage value and the second storage value are different, the data storage device deletes the second storage value.
[0103] In this embodiment of the application, when the data storage device receives a hot data caching instruction, the data storage device retrieves the hot data from the caching instruction and writes the hot data into the cache.
[0104] In this embodiment, the data storage device deletes cached data when it determines that the access frequency of cached data in the cache is less than or equal to the access frequency threshold; or, the data storage device deletes cached data when it determines that the time length between the last access time of the cached data and the current time is greater than or equal to the time length threshold.
[0105] In this embodiment, access popularity can be popularity information configured in the data storage device; access popularity can also be popularity information transmitted to the data storage device by other devices; the specific way the data storage device obtains access popularity can be determined according to the actual situation, and this embodiment does not limit it.
[0106] In this embodiment, the time length threshold can be a threshold configured in the data storage device; the time length threshold can also be a threshold transmitted from other devices to the data storage device; the specific way the data storage device obtains the time length threshold can be determined according to the actual situation, and this embodiment does not limit it.
[0107] It's worth noting that the Redis cache is built on a Docker platform. The Redis instance is configured with an LFU (Least Recently Accessed) memory eviction policy, retaining only recently accessed hot data. Specifically, the LFU policy includes: storing only a portion of the data in Redis, eviction of historical data that hasn't been accessed in a long time based on access time (ensuring that hot data is not evicted); and adding a management console connection to Redis, allowing the management console to specify which data is not evicted.
[0108] In this embodiment, the distributed database contains multiple slave nodes. After the data storage device synchronizes the target stored value to the cache, upon receiving a data retrieval instruction from the second client, the data storage device retrieves the data to be retrieved corresponding to the retrieval instruction from the cache. If the data to be retrieved is not retrieved from the cache, the data storage device retrieves the first read latency parameter and the slave node identifier corresponding to the slave node in the distributed database. Based on the first read latency parameter and the slave node identifier, the data storage device determines the target slave node from the multiple slave nodes. The data storage device then reads the data to be retrieved from the target slave node.
[0109] In this embodiment, the first client and the second client can be the same client; or the first client and the second client can be different clients; the specific choice can be determined according to the actual situation, and this embodiment does not limit this. The first client or the second client is a WeKV client.
[0110] In this embodiment of the application, the process by which the data storage device retrieves the data to be retrieved corresponding to the retrieval instruction from the cache includes the data storage device retrieving the data to be retrieved corresponding to the retrieval instruction from the cache using a proxy gateway.
[0111] In this embodiment, the first read latency parameter is the read latency parameter corresponding to multiple slave nodes in the distributed database. The slave node identifier is the identifier corresponding to multiple slave nodes in the distributed database.
[0112] It should be noted that the slave node identifier includes the memory machine slave node identifier and the serial hard drive (SATA) slave node identifier.
[0113] In this embodiment, the process by which the data storage device determines a target slave node from multiple slave nodes based on a first read latency parameter and a slave node identifier includes: the data storage device filtering memory slave nodes with memory machine slave node identifiers from the slave node identifiers, and obtaining multiple read latency parameters corresponding to the memory slave node from the first read latency parameter; the data storage device sorting the multiple read latency parameters in ascending order of latency parameters to obtain a latency parameter sequence; and the data storage device obtaining a preset number of slave nodes corresponding to the latency parameters starting from the first latency parameter in the latency parameter sequence as the target slave node.
[0114] In this embodiment of the application, after the data storage device determines the target slave node from multiple slave nodes, if the data storage device fails to obtain the data to be obtained from the target slave node, it obtains the first slave node corresponding to the first slave node identifier; the data storage device determines the target node from the first slave node; and reads the data to be obtained from the target node.
[0115] It should be noted that the first slave node identifier is a partial identifier of the slave node identifier, specifically the serial hard drive slave node identifier.
[0116] In this embodiment of the application, the number of first slave nodes is multiple.
[0117] In this embodiment of the application, the process of the data storage device determining the target node from the first slave node includes: the data storage device obtaining multiple target read delay parameters corresponding to multiple first slave nodes from the first read delay parameters; the data storage device sorting the multiple target read delay parameters in ascending order of delay parameters to obtain a target delay parameter sequence; and the data storage device obtaining a preset number of slave nodes corresponding to the target delay parameters, starting from the first target delay parameter in the target delay parameter sequence, as target slave nodes.
[0118] In this embodiment of the application, there are multiple master nodes in the distributed database; after the data storage device determines the target node from the first slave node, the data storage device also obtains the second read latency parameter corresponding to the master node in the distributed database; the data storage device determines the target master node from the master nodes according to the second read latency parameter; and reads the data to be obtained from the target master node.
[0119] In this embodiment of the application, the method by which the data storage device determines the target master node from the master nodes based on the second read delay parameter can be that the data storage device obtains a preset number of target delay parameters with the smallest delay parameter value from the second read delay parameter, and takes the master node corresponding to the target delay parameter as the target master node.
[0120] In this embodiment of the application, before obtaining the first read latency parameter and slave node identifier corresponding to the slave node in the distributed database, the data storage device also marks the number of times the data to be obtained is to be acquired; if the number of acquisitions is greater than or equal to the threshold of the number of acquisitions, the data storage device obtains the data to be acquired from the distributed database; the data storage device synchronizes the data to be acquired to the cache.
[0121] In this embodiment, the acquisition count threshold can be a threshold configured in the data storage device; the acquisition count threshold can also be a threshold transmitted from other devices to the data storage device; the specific way the data storage device acquires the acquisition count threshold can be determined according to the actual situation, and this embodiment does not limit it.
[0122] In this embodiment, the data loading and eviction strategy of Redis can be to use the preload component to load data (frequently accessed data, data with hot data tags) into Redis according to the business preset rules; or to write data that has not been read from Redis multiple times into Redis by receiving a notification from the proxy.
[0123] For example, such as Figure 3As shown: When the data storage device receives the data to be updated transmitted by the first client through the proxy gateway, the data storage device uses the proxy gateway to write the data to be updated (first storage key and first storage value) into the distributed database (TIKV cluster). Specifically: the proxy gateway first accesses the cluster management module (PD1, PD2, PD3) to obtain the storage block (region) information (including master node and slave node) corresponding to the first storage key from the cluster management module. That is, it determines the master node to store the data to be updated in the distributed database and stores the first storage key and first storage value in the master node. If the data storage device successfully stores the first storage key and first storage value using the master node, it synchronizes the first storage key and first storage value in the master node to the slave node in the distributed database. If the data storage device successfully stores the first storage key and first storage value using the slave node, it determines that the distributed database has successfully stored the first storage key and first storage value. The data storage device searches for the historical value corresponding to the first storage key in the cache and deletes the historical value; when the preset time arrives, it retrieves the target storage value corresponding to the target storage key in the target list from the distributed database; the data storage device synchronizes the first storage value to the cache: that is, after the data storage device synchronizes the first storage value to the cache master node ([1]Master, [2]Master, [3]Master) of the cache (Redis cluster) using the proxy gateway, if the data storage device fails to store the first storage value using the cache master node, it continues to write the first storage value to the cache master node using the verification component until the cache master node successfully stores the first storage value. If the cache master node successfully stores the first storage value, the data storage device synchronizes the first storage value in the cache master node to the cache slave node ([1]Slave, [2]Master, [3]Master). After the data storage device synchronizes the target stored value to the cache, when the perload verification time arrives, the data storage device also uses a verification component to compare the first data written to the distributed database by the proxy gateway with the second data synchronized to the cache using the proxy gateway. If the data storage device determines that the first data and the second data are different, it modifies the second data using the first data. When the data storage device receives a data retrieval instruction transmitted by the second client, it retrieves the data to be retrieved corresponding to the retrieval instruction from the cache (Redis). If the data to be retrieved is not retrieved from the cache, the data storage device retrieves the first read latency parameter and the slave node identifier corresponding to the slave node in the distributed database. Based on the first read latency parameter and the slave node identifier, it determines the target slave node (MemoryMachine slave node) from multiple slave nodes and reads the data to be retrieved from the target slave node.If the data storage device fails to obtain the data to be acquired from the target slave node, it acquires the first slave node corresponding to the first slave node identifier; determines the target node (SATA slave node) from the first slave nodes; and reads the data to be acquired from the target node. If the data to be acquired still cannot be acquired, the data storage device acquires the second read latency parameter corresponding to the master node in the distributed database; determines the target master node (SATA master node) from the master nodes based on the second read latency parameter; and reads the data to be acquired from the target master node.
[0124] It should be noted that the master nodes in the TIKV cluster include SATA master nodes (region[1](master), region[2](master), ..., region[n](master)); the slave nodes in the TIKV cluster include SATA slave nodes (region[1](slave), region[2](slave), ..., region[n](slave)) and Memory Machine slave nodes (region[1](slave), region[2](slave), ..., region[n](slave)).
[0125] For example, such as Figure 4As shown: When receiving the data to be updated from the first client using a proxy, the system determines the timestamp of the received data, as well as the first storage key and first storage value. It then writes the timestamp and first storage key into a target list (writing the key and timestamp to `do_key_list`). If writing to the target list fails, a response indicating a failure to write the data is sent to the first client. If writing to the target list succeeds, the system writes the first storage key and first storage value into the distributed database (business data is written to TiKV). If writing to the distributed database fails, a response indicating a failure to write the data is sent to the first client. If writing to the distributed database succeeds, a response indicating a successful write is sent to the first client. Simultaneously, the system searches for the historical value corresponding to the first storage key in the cache (Redis) and deletes the historical value (delete the key). If deleting the historical value fails, the system retrieves the first storage value from the distributed database and the second storage value corresponding to the first storage key from the cache. If the first and second storage values differ (verify by comparing the key values in TiKV and Redis), the second storage value is deleted (delete the key). When the preset time arrives, retrieve the target storage value corresponding to the target storage key in the target list from the distributed database (perload performs data synchronization periodically, reads kitv, and queries kitv data); the target storage key includes the first storage key; synchronize the target storage value to the cache (write data to Redis).
[0126] For example, such as Figure 5As shown: When the proxy receives a data retrieval command from the second client, it retrieves the data to be retrieved corresponding to the command from the cache (Redis) (initiating a data read); if the data to be retrieved is not retrieved from the cache (read from Redis failed), it marks the number of times the data to be retrieved has been retrieved (recording keymiss); if the number of retrievals is greater than or equal to the threshold (perload triggers synchronization), it retrieves the data to be retrieved from the distributed database (reading data from TiKV); and synchronizes the data to be retrieved to the cache (writing to Redis). It retrieves the first read latency parameter and slave node identifier corresponding to the slave node in the distributed database; based on the first read latency parameter and slave node identifier, it determines the target slave node from multiple slave nodes; and reads the data to be retrieved from the target slave node (retrieving data from the TiKV read-only node). If the data to be retrieved cannot be retrieved from the target slave node, it retrieves the first slave node corresponding to the first slave node identifier; the first slave node identifier is a partial identifier from the slave node identifiers; it determines the target node from the first slave node; and reads the data to be retrieved from the target node (data retrieval from the TiKV read-only node failed). Obtain the second read latency parameter corresponding to the master node in the distributed database; there are multiple master nodes; determine the target master node from the master nodes according to the second read latency parameter; and read the data to be obtained from the target master node (obtain data from the TIKV master node). If the read is successful, send the read data to the second client; if the read fails, read the failure response information to the second client.
[0127] Understandably, after the data storage device writes the data to be updated into the distributed database, before updating the data in the cache with the data to be updated, it deletes the historical value corresponding to the first storage key in the cache. This ensures that when a data retrieval command is received, the historical value corresponding to the first storage key will not be read from the cache. The device can then retrieve the data from the distributed database to obtain the first storage value, thus obtaining accurate data and improving the accuracy of data retrieval.
[0128] Example 2
[0129] Based on the same inventive concept as Embodiment 1, this application provides a data storage device 1, corresponding to a data storage method; Figure 6 A schematic diagram of the composition structure of a data storage device provided in this application embodiment. Figure 1 The data storage device 1 may include:
[0130] The determining unit 11 is used to determine the first storage key and the first storage value of the data to be updated when it receives the data to be updated transmitted by the first client;
[0131] The writing unit 12 is used to write the first storage key into the target list; and to write the first storage key and the first storage value into the distributed database.
[0132] The lookup unit 13 is used to look up the historical value corresponding to the first storage key in the cache;
[0133] Deletion unit 14 is used to delete the historical value;
[0134] The acquisition unit 15 is configured to acquire, in the distributed database, the target storage value corresponding to the target storage key in the target list when a preset time is reached; the target storage key includes the first storage key;
[0135] Synchronization unit 16 is used to synchronize the target stored value to the cache.
[0136] In some embodiments of this application, the determining unit 11 is used to determine the timestamp of receiving the data to be updated;
[0137] Accordingly, the writing unit 12 is used to write the timestamp and the first storage key into the target list.
[0138] In some embodiments of this application, the determining unit 11 is used to determine, from the target list, the target storage key written within the preset time period and the preset time period last time.
[0139] The acquisition unit 15 is used to acquire the target storage value corresponding to the target storage key from the distributed database when a preset time arrives.
[0140] In some embodiments of this application, the device further includes a storage unit;
[0141] The storage unit is used to store the first storage key and the first storage value in the master node of the distributed database; the master node is used to read data or write data.
[0142] The synchronization unit 16 is used to synchronize the first storage key and the first storage value in the master node to the slave node in the distributed database when the master node successfully stores the first storage key and the first storage value, so that when retrieving the stored data from the distributed database, the first storage value is preferentially retrieved from the slave node; the slave node is used to read data;
[0143] The determining unit 11 is used to determine that the data to be updated has been successfully stored using the distributed database if the first storage key and the first storage value are successfully stored using the slave node.
[0144] In some embodiments of this application, the apparatus further includes a comparison unit and a modification unit;
[0145] The comparison unit is used to compare, when the verification time arrives, the first data written to the distributed database by the proxy gateway using the verification component and the second data synchronized to the cache by the proxy gateway using the verification component; the first data includes the data to be updated; the second data is all the data in the cache; the data keys of the first data and the second data are the same.
[0146] The modification unit is used to modify the second data using the first data when it is determined that the first data and the second data are different.
[0147] In some embodiments of this application, the number of the first data and the second data is multiple; the device further includes a grouping unit and an encryption unit;
[0148] The acquisition unit 15 is used to acquire multiple first keys and multiple first values corresponding to multiple first data, and multiple first keys and multiple second values corresponding to multiple second data; the multiple first keys include the first storage key; and to acquire multiple sets of first values and multiple sets of second values corresponding to multiple sets of first keys;
[0149] The grouping unit is used to group the plurality of first keys according to a preset number of groups to obtain multiple groups of first keys;
[0150] The encryption unit is used to encrypt each of the multiple sets of first values to obtain multiple first encrypted values; and to encrypt each of the multiple sets of second values to obtain multiple second encrypted values.
[0151] The comparison unit is used to compare the plurality of first encrypted values with the plurality of second encrypted values;
[0152] Accordingly, the determining unit 11 is used to determine that the first data is different from the second data when the plurality of first encrypted values are different from the plurality of second encrypted values respectively;
[0153] The modification unit is used to modify the second data using the first data.
[0154] In some embodiments of this application, the acquisition unit 15 is used to acquire the first stored value from the distributed database and the second stored value corresponding to the first stored key from the cache when the deletion of the historical value fails.
[0155] The deletion unit 14 is used to delete the second storage value when the first storage value is different from the second storage value.
[0156] In some embodiments of this application, the acquisition unit 15 is used to acquire the first storage value from the distributed database and the second storage value corresponding to the first storage key from the cache when the cache master node in the cache is switched.
[0157] The deletion unit 14 is used to delete the second storage value when the first storage value is different from the second storage value.
[0158] In some embodiments of this application, the acquisition unit 15 is configured to acquire the hot data from the cache instruction upon receiving a hot data cache instruction;
[0159] The writing unit 12 is used to write the hot data into the cache.
[0160] In some embodiments of this application, the deletion unit 14 is used to delete the cached data when it is determined that the access popularity of the cached data in the cache is less than or equal to the access popularity threshold; the cached data is a portion of the second data; or, when it is determined that the time length between the last access time of the cached data and the current time is greater than or equal to the time length threshold, the cached data is deleted.
[0161] In some embodiments of this application, the device further includes a reading unit;
[0162] The acquisition unit 15 is configured to, upon receiving a data acquisition instruction transmitted by a second client, acquire the data to be acquired corresponding to the acquisition instruction from the cache; and, if the data to be acquired is not acquired from the cache, acquire the first read delay parameter and the slave node identifier corresponding to the slave node in the distributed database; the number of slave nodes is multiple.
[0163] The determining unit 11 is configured to determine a target slave node from a plurality of slave nodes based on the first read delay parameter and the slave node identifier;
[0164] The reading unit is used to read the data to be acquired from the target slave node.
[0165] In some embodiments of this application, the acquisition unit 15 is configured to acquire a first slave node corresponding to a first slave node identifier when the data to be acquired cannot be acquired from the target slave node; the first slave node identifier is a partial identifier of the slave node identifiers.
[0166] The determining unit 11 is used to determine the target node from the first slave node;
[0167] The reading unit is used to read the data to be acquired from the target node.
[0168] In some embodiments of this application, the acquisition unit 15 is used to acquire a second read latency parameter corresponding to a master node in the distributed database; the number of master nodes is multiple.
[0169] The determining unit 11 is used to determine the target master node from the master node based on the second read delay parameter;
[0170] The reading unit is used to read the data to be acquired from the target master node.
[0171] In some embodiments of this application, the device further includes a marking unit;
[0172] The marking unit is used to mark the number of times the data to be acquired has been acquired;
[0173] The acquisition unit 15 is used to acquire the data to be acquired from the distributed database when the number of acquisitions is greater than or equal to the acquisition number threshold.
[0174] The synchronization unit 16 is used to synchronize the data to be acquired to the cache.
[0175] It should be noted that, in practical applications, the aforementioned determining unit 11, writing unit 12, searching unit 13, deleting unit 14, obtaining unit 15, and synchronization unit 16 can be implemented by the processor 17 on the data storage device 1, specifically by a CPU (Central Processing Unit), MPU (Microprocessor Unit), DSP (Digital Signal Processor), or Field Programmable Gate Array (FPGA), etc.; the aforementioned data storage can be implemented by the memory 18 on the data storage device 1.
[0176] This application embodiment also provides a data storage device 1, such as Figure 7 As shown, the data storage device 1 includes a processor 17, a memory 18, and a communication bus 19. The memory 18 communicates with the processor 17 through the communication bus 19. The memory 18 stores programs executable by the processor 17. When the program is executed, the data storage method described above is executed by the processor 17.
[0177] In practical applications, the aforementioned memory 18 can be volatile memory, such as random-access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 17.
[0178] Understandably, after the data storage device writes the data to be updated into the distributed database, before updating the data in the cache with the data to be updated, it deletes the historical value corresponding to the first storage key in the cache. This ensures that when a data retrieval command is received, the historical value corresponding to the first storage key will not be read from the cache. The device can then retrieve the data from the distributed database to obtain the first storage value, thus obtaining accurate data and improving the accuracy of data retrieval.
[0179] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0180] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0181] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0182] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0183] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.
Claims
1. A data storage method, characterized in that, The method includes: Upon receiving the data to be updated transmitted by the first client, determine the first storage key and the first storage value of the data to be updated, and write the first storage key into the target list; Write the first storage key and the first storage value into the distributed database; Locate the historical value corresponding to the first storage key in the cache and delete the historical value; When the preset time arrives, the target storage value corresponding to the target storage key in the target list is retrieved from the distributed database; the target storage key includes the first storage key. Synchronize the target stored value to the cache; When the verification time arrives, the verification component compares the first data written to the distributed database by the proxy gateway with the second data synchronized to the cache by the proxy gateway; the first data includes the data to be updated; the second data is all the data in the cache; the data keys of the first data and the second data are the same; if it is determined that the first data and the second data are different, the second data is modified using the first data. The first data and the second data are of multiple quantities. The step of comparing the first data written to the distributed database by the proxy gateway using the verification component with the second data synchronized to the cache by the proxy gateway includes: obtaining multiple first keys and multiple first values corresponding to the multiple first data, and multiple first keys and multiple second values corresponding to the multiple second data; the multiple first keys include the first storage key; grouping the multiple first keys according to a preset grouping number to obtain multiple groups of first keys; obtaining multiple groups of first values and multiple groups of second values corresponding to the multiple groups of first keys; encrypting each group of first values in the multiple groups of first values to obtain multiple first encrypted values; encrypting each group of second values in the multiple groups of second values to obtain multiple second encrypted values; comparing the multiple first encrypted values with the multiple second encrypted values; correspondingly, the step of modifying the second data using the first data when it is determined that the first data and the second data are different includes: determining that the first data and the second data are different when the multiple first encrypted values are respectively different from the multiple second encrypted values; modifying the second data using the first data.
2. The method according to claim 1, characterized in that, Before determining the first storage key and the first storage value of the data to be updated, the method further includes: Determine the timestamp at which the data to be updated was received; Accordingly, writing the first storage key into the target list includes: Write the timestamp and the first storage key into the target list.
3. The method according to claim 2, characterized in that, The step of retrieving the target storage value corresponding to the target storage key in the target list from the distributed database when the preset time arrives includes: From the target list, determine the target storage key written within the last preset time and the preset time. When the preset time arrives, the target storage value corresponding to the target storage key is retrieved from the distributed database.
4. The method according to claim 1, characterized in that, The step of writing the first storage key and the first storage value into the distributed database includes: The first storage key and the first storage value are stored in the master node of the distributed database; the master node is used to read or write data. If the first storage key and the first storage value are successfully stored using the master node, the first storage key and the first storage value in the master node are synchronized to the slave node in the distributed database, so that when retrieving stored data from the distributed database, the first storage value can be retrieved from the slave node; the slave node is used to read data; If the first storage key and the first storage value are successfully stored using the slave node, it is determined that the data to be updated is successfully stored using the distributed database.
5. The method according to claim 1, characterized in that, After searching for the historical value corresponding to the first storage key in the cache and deleting the historical value, the method further includes: If deleting the historical value fails, retrieve the first stored value from the distributed database and retrieve the second stored value corresponding to the first stored key from the cache; If the first stored value is different from the second stored value, delete the second stored value.
6. The method according to claim 1, characterized in that, After determining the first storage key and the first storage value of the data to be updated, and before synchronizing the target storage value to the cache, the method further includes: In the event of a cache master node switch in the cache, the first stored value is retrieved from the distributed database, and the second stored value corresponding to the first stored key is retrieved from the cache. If the first stored value is different from the second stored value, delete the second stored value.
7. The method according to claim 1, characterized in that, The method further includes: Upon receiving a hot data caching instruction, the hot data is retrieved from the caching instruction; The hot data is written into the cache.
8. The method according to claim 1, characterized in that, The method further includes: If it is determined that the access frequency of cached data in the cache is less than or equal to the access frequency threshold, the cached data is deleted; the cached data is a portion of the second data. Alternatively, if it is determined that the time between the last access time of the cached data and the current time is greater than or equal to a time length threshold, the cached data may be deleted.
9. The method according to claim 1, characterized in that, After synchronizing the target stored value to the cache, the method further includes: Upon receiving a data retrieval instruction transmitted by the second client, the data to be retrieved corresponding to the retrieval instruction is retrieved from the cache; If the data to be retrieved is not retrieved from the cache, the first read latency parameter and the slave node identifier corresponding to the slave node in the distributed database are obtained; the number of slave nodes is multiple. Based on the first read latency parameter and the slave node identifier, a target slave node is determined from a plurality of slave nodes; The target node reads the data to be acquired.
10. The method according to claim 9, characterized in that, After determining the target slave node from multiple slave nodes, the method further includes: If the data to be acquired cannot be obtained from the target slave node, the first slave node corresponding to the first slave node identifier is acquired; the first slave node identifier is a partial identifier of the slave node identifier. The target node is determined from the first slave node; and the data to be acquired is read from the target node.
11. The method according to claim 10, characterized in that, After determining the target node from the first slave node, the method further includes: Obtain the second read latency parameter corresponding to the master node in the distributed database; the number of master nodes is multiple. The target master node is determined from the master nodes based on the second read delay parameter; and the data to be acquired is read from the target master node.
12. The method according to claim 9, characterized in that, Before obtaining the first read latency parameter and slave node identifier corresponding to the slave node in the distributed database, the method further includes: Mark the number of times the data to be acquired is retrieved; If the number of retrievals is greater than or equal to the retrieval threshold, the data to be retrieved is retrieved from the distributed database; The data to be acquired is synchronized to the cache.
13. A data storage device for implementing the method according to any one of claims 1-12, characterized in that, The device includes: The determining unit is configured to determine the first storage key and the first storage value of the data to be updated upon receiving the data to be updated transmitted by the first client. The writing unit is used to write the first storage key into the target list; and to write the first storage key and the first storage value into the distributed database. The lookup unit is used to look up the historical value corresponding to the first storage key in the cache; The deletion unit is used to delete the historical value; The acquisition unit is configured to acquire, upon arrival of a preset time, the target storage value corresponding to the target storage key in the target list from the distributed database; the target storage key includes the first storage key. A synchronization unit is used to synchronize the target stored value to the cache; The comparison unit is used to compare, when the verification time arrives, the first data written to the distributed database by the proxy gateway using the verification component and the second data synchronized to the cache by the proxy gateway using the verification component; the first data includes the data to be updated; the second data is all the data in the cache; the data keys of the first data and the second data are the same. The modification unit is used to modify the second data using the first data when it is determined that the first data is different from the second data. The first data and the second data are of multiple quantities; the device also includes a grouping unit and an encryption unit; The acquisition unit is configured to acquire multiple first keys and multiple first values corresponding to multiple first data, and multiple first keys and multiple second values corresponding to multiple second data; the multiple first keys include the first storage key; and acquire multiple sets of first values and multiple sets of second values corresponding to multiple sets of first keys. The grouping unit is used to group the plurality of first keys according to a preset number of groups to obtain multiple groups of first keys; The encryption unit is used to encrypt each of the multiple sets of first values to obtain multiple first encrypted values; and to encrypt each of the multiple sets of second values to obtain multiple second encrypted values. The comparison unit is used to compare the plurality of first encrypted values with the plurality of second encrypted values; The determining unit is configured to determine that the first data is different from the second data when the plurality of first encrypted values are different from the plurality of second encrypted values respectively; The modification unit is used to modify the second data using the first data.
14. A data storage device, characterized in that, The device includes: The system includes a memory, a processor, and a communication bus, wherein the memory communicates with the processor via the communication bus, the memory stores a program of data that is executable by the processor, and when the program of the data is executed, the processor performs the method as described in any one of claims 1 to 12.