[go: up one dir, main page]

CN115098519A - Data storage method and device - Google Patents

Data storage method and device Download PDF

Info

Publication number
CN115098519A
CN115098519A CN202210677973.3A CN202210677973A CN115098519A CN 115098519 A CN115098519 A CN 115098519A CN 202210677973 A CN202210677973 A CN 202210677973A CN 115098519 A CN115098519 A CN 115098519A
Authority
CN
China
Prior art keywords
data
target
storage
value
cache
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210677973.3A
Other languages
Chinese (zh)
Inventor
邵宇
胡盼盼
卢道和
杨军
冼立志
苏钰
蒋俊钊
熊梦飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202210677973.3A priority Critical patent/CN115098519A/en
Publication of CN115098519A publication Critical patent/CN115098519A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data storage method and a data storage device, wherein the data storage method comprises the following steps: under the condition of receiving data to be updated transmitted by a first client, determining a first storage key and a first storage value of the data to be updated, and writing the first storage key into a target list; writing a first storage key and a first stored value to a distributed database; searching a history value corresponding to the first storage key in a cache, and deleting the history value; when the preset time is up, acquiring a target storage value corresponding to a target storage key in a target list from a distributed database; the target storage key comprises a first storage key; the targeted stored value is synchronized into the cache.

Description

一种数据存储方法及装置A data storage method and device

技术领域technical field

本申请涉及数据存储技术领域,尤其涉及一种数据存储方法及装置。The present application relates to the technical field of data storage, and in particular, to a data storage method and device.

背景技术Background technique

在互联网金融场景中,通常将数据存储在具有低时延、高吞吐性能的存储位置,如Redis中,由于Redis可以存储的数据量小,通常会利用Redis存储部分数据,利用其他的存储容量较大的数据库(如关系型数据库)来存储全量数据。In Internet finance scenarios, data is usually stored in a storage location with low latency and high throughput performance, such as Redis. Since Redis can store a small amount of data, Redis is usually used to store some data, and other storage capacity is relatively small. Large databases (such as relational databases) to store full data.

现有技术中,是先将数据存储在关系型数据库中,在利用关系型数据库存储成功的情况下,就会反馈存储成功的响应信息,然后再将数据从关系型数据库同步至Redis中,数据获取时会先从Redis中获取数据,在存储的数据为更新数据、且更新数据在关系型数据库中存储成功、却未及时同步至Redis时,在接收到数据获取指令的情况下,由于未利用更新数据更新Redis中的旧数据,根据数据获取指令会从Redis中获取到旧数据,即获取到错误数据,降低了获取数据时的准确性。In the prior art, the data is first stored in the relational database, and if the relational database is successfully stored, the response information of the successful storage will be fed back, and then the data will be synchronized from the relational database to Redis. When acquiring, the data will be acquired from Redis first. When the stored data is updated data, and the updated data is successfully stored in the relational database, but not synchronized to Redis in time, when the data acquisition instruction is received, it is not used. Update data Update the old data in Redis. According to the data acquisition instruction, the old data will be obtained from Redis, that is, the wrong data will be obtained, which reduces the accuracy of data acquisition.

发明内容SUMMARY OF THE INVENTION

为解决上述技术问题,本申请实施例期望提供一种数据存储方法及装置,能够提高获取数据时的准确性。In order to solve the above technical problems, the embodiments of the present application expect to provide a data storage method and apparatus, which can improve the accuracy of data acquisition.

本申请的技术方案是这样实现的:The technical solution of the present application is realized as follows:

本申请实施例提供一种数据存储方法,所述数据存储方法包括:An embodiment of the present application provides a data storage method, and the data storage method includes:

在接收到第一客户端传输的待更新数据的情况下,确定所述待更新数据的第一存储键和第一存储值,并将所述第一存储键写入目标列表;In the case of 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;

将所述第一存储键和所述第一存储值写入分布式数据库;writing the first storage key and the first storage value into a distributed database;

在缓存中查找所述第一存储键对应的历史值,并删除所述历史值;Find the historical value corresponding to the first storage key in the cache, and delete the historical value;

在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值;所述目标存储键包括所述第一存储键;When the preset time arrives, in the distributed database, obtain the target storage value corresponding to the target storage key in the target list; the target storage key includes the first storage key;

将所述目标存储值同步至所述缓存中。Synchronizing the target storage value into the cache.

本申请实施例提供了一种数据存储装置,所述装置包括:An embodiment of the present application provides a data storage device, and the device includes:

确定单元,用于在接收到第一客户端传输的待更新数据的情况下,确定所述待更新数据的第一存储键和第一存储值;a determining unit, configured to determine a first storage key and a first storage value of the to-be-updated data when receiving the to-be-updated data transmitted by the first client;

写入单元,用于将所述第一存储键写入目标列表;将所述第一存储键和所述第一存储值写入分布式数据库;a writing unit, used for writing the first storage key into a target list; writing the first storage key and the first storage value into a distributed database;

查找单元,用于在缓存中查找所述第一存储键对应的历史值;a search unit, used to search the cache for the historical value corresponding to the first storage key;

删除单元,用于删除所述历史值;a deletion unit for deleting the historical value;

获取单元,用于在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值;所述目标存储键包括所述第一存储键;an obtaining unit, configured to obtain, in the distributed database, the target storage value corresponding to the target storage key in the target list when the preset time arrives; the target storage key includes the first storage key;

同步单元,用于将所述目标存储值同步至所述缓存中。A synchronization unit, configured to synchronize the target stored value to the cache.

本申请实施例提供了一种数据存储装置,所述装置包括:An embodiment of the present application provides a data storage device, and the device includes:

存储器、处理器和通信总线,所述存储器通过所述通信总线与所述处理器进行通信,所述存储器存储所述处理器可执行的数据存储的程序,当所述数据存储的程序被执行时,通过所述处理器执行上述所述的数据存储方法。A memory, a processor, and a communication bus through which the memory communicates with the processor, the memory storing a datastored program executable by the processor when the datastored program is executed , and the above-mentioned data storage method is executed by the processor.

本申请实施例提供了一种数据存储方法及装置,数据存储方法包括:在接收到第一客户端传输的待更新数据的情况下,确定待更新数据的第一存储键和第一存储值,并将第一存储键写入目标列表;将第一存储键和第一存储值写入分布式数据库;在缓存中查找第一存储键对应的历史值,并删除历史值;在预设时间到达时,在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值;目标存储键包括第一存储键;将目标存储值同步至缓存中。采用上述方法实现方案,数据存储装置在将待更新数据写入分布式数据库后,在利用待更新数据更新缓存中的数据之前,通过删除缓存中该第一存储键对应的历史值,使得在接收到数据获取指令的情况下,不会在缓存中读取到第一存储键对应的历史值,就可以再去分布式数据库中进行数据读取,从而得到第一存储值,即获取到准确的数据,从而提高了获取数据时的准确性。Embodiments of the present application provide a data storage method and device, where the data storage method includes: in the case of receiving data to be updated transmitted by a first client, determining a first storage key and a first storage value of the data to be updated, Write the first storage key into the target list; write the first storage key and the first storage value into the distributed database; look up the historical value corresponding to the first storage key in the cache, and delete the historical value; arrive at the preset time When , in the distributed database, the target storage value corresponding to the target storage key in the target list is obtained; the target storage key includes the first storage key; the target storage value is synchronized to the cache. By adopting the above method implementation scheme, after the data storage device writes the data to be updated into the distributed database, before using the data to be updated to update the data in the cache, the data storage device deletes the historical value corresponding to the first storage key in the cache, so that in the receiving In the case of the data acquisition instruction, the historical value corresponding to the first storage key will not be read in the cache, and the data can be read from the distributed database to obtain the first storage value, that is, to obtain the accurate value. data, thereby improving the accuracy of data acquisition.

附图说明Description of drawings

图1为本申请实施例提供的一种现有技术中的数据存储示意图;1 is a schematic diagram of data storage in the prior art provided by an embodiment of the present application;

图2为本申请实施例提供的一种数据存储方法流程图;2 is a flowchart of a data storage method provided by an embodiment of the present application;

图3为本申请实施例提供的一种示例性的数据存储方法流程图一;FIG. 3 is a flowchart 1 of an exemplary data storage method provided by an embodiment of the present application;

图4为本申请实施例提供的一种示例性的数据存储方法流程图二;FIG. 4 is a flowchart 2 of an exemplary data storage method provided by an embodiment of the present application;

图5为本申请实施例提供的一种示例性的数据存储方法流程图三;FIG. 5 is a flowchart 3 of an exemplary data storage method provided by an embodiment of the present application;

图6为本申请实施例提供的一种数据存储装置的组成结构示意图一;FIG. 6 is a schematic diagram 1 of the composition structure of a data storage device according to an embodiment of the present application;

图7为本申请实施例提供的一种数据存储装置的组成结构示意图二。FIG. 7 is a second schematic diagram of the composition and structure of a data storage device according to an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application.

在互联网金融场景中,因为拥有低时延高吞吐的特性,内存型kv数据库redis被广泛使用。Redis虽然有aof(AOF(Append Only File),是通过将Reids的操作日志以追加的方式写入文件)和rdb(RDB(Redis DataBase),是通过将Reids在内存中的数据库记录定时dump到磁盘上的RDB持久化)的持久化方案,主从之间还是异步同步,当主节点故障后,从节点有可能丢失还没同步的数据。所以在数据很重要时,redis不能作为持久化存储,一般将使用关系型数据库作为兜底。In Internet finance scenarios, the in-memory kv database redis is widely used because of its low latency and high throughput. Although Redis has aof (AOF (Append Only File), which is written by appending the operation log of Reids to the file) and rdb (RDB (Redis DataBase), it is by regularly dumping the database records of Reids in memory to disk The persistence scheme of the RDB persistence on the above), the master and slave are still asynchronously synchronized. When the master node fails, the slave node may lose the data that has not been synchronized. Therefore, when the data is very important, redis cannot be used as a persistent storage, and a relational database is generally used as the bottom line.

如图1所示:应用同时将数据写入redis数据库和关系型数据库,当关系型数据库写成功后,应用返回写成功的响应信息。之后也可以redis数据库和关系型数据库中读取数据。另启一个异步进程对关系型数据库和redis数据库中的数据进行比对(校验数据一致),如果存在不一致的,则以关系型数据库中的数据为准。As shown in Figure 1: The application writes data to the redis database and the relational database at the same time. When the relational database is successfully written, the application returns a response message of successful writing. After that, you can also read data from redis database and relational database. Another asynchronous process is started to compare the data in the relational database and the redis database (check the data to be consistent). If there is any inconsistency, the data in the relational database shall prevail.

实施例一Example 1

本申请实施例提供了一种数据存储方法,一种数据存储方法应用于数据存储装置,图2为本申请实施例提供的一种数据存储方法流程图,如图2所示,数据存储方法可以包括:An embodiment of the present application provides a data storage method, and a data storage method is applied to a data storage device. FIG. 2 is a flowchart of a data storage method provided by an embodiment of the present application. As shown in FIG. 2 , the data storage method may be include:

S101、在接收到第一客户端传输的待更新数据的情况下,确定待更新数据的第一存储键和第一存储值,并将第一存储键写入目标列表。S101. In the case of receiving the data to be updated transmitted by the first client, determine a first storage key and a first storage value of the data to be updated, and write the first storage key into a target list.

本申请实施例提供的一种数据存储方法适用于利用分布式数据库和缓存对待更新数据进行存储的场景下。The data storage method provided by the embodiment of the present application is suitable for a scenario where a distributed database and a cache are used to store data to be updated.

在本申请实施例中,数据存储装置可以以各种形式来实施。例如,本申请中描述的数据存储装置可以包括诸如手机、照相机、平板电脑、笔记本电脑、掌上电脑、个人数字助理(Personal Digital Assistant,PDA)、便捷式媒体播放器(Portable Media Player,PMP)、导航装置、可穿戴设备、智能手环、计步器等装置,以及诸如数字TV、台式计算机、服务器等装置。In the embodiments of the present application, the data storage device may be implemented in various forms. For example, the data storage devices described in this application may include, for example, cell phones, cameras, tablet computers, notebook computers, palmtop computers, Personal Digital Assistants (PDAs), Portable Media Players (PMPs), Navigation devices, wearable devices, smart bracelets, pedometers and other devices, as well as devices such as digital TVs, desktop computers, servers, etc.

在本申请实施例中,待更新数据可以为互联网金融领域的数据;待更新数据也可以为其他的数据;具体的待更新数据可以根据实际情况进行确定,本申请实施例对此不作限定。In the embodiment of the present application, the data to be updated may be data in the field of Internet finance; the data to be updated may also be other data; the specific data to be updated may be determined according to the actual situation, which is not limited in the embodiment of the present application.

在本申请实施例中,待更新数据的数量可以为一个,待更新数据的数量也可以为两个,待更新数据的数量还可以为多个;具体的待更新数据的数量可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the quantity of data to be updated may be one, the quantity of data to be updated may also be two, and the quantity of data to be updated may also be multiple; the specific quantity of data to be updated may be determined according to the actual situation It is determined that this embodiment of the present application does not limit this.

在本申请实施例中,第一客户端的数量可以为一个,第一客户端的数量也可以为两个,第一客户端的数量还可以为多个;具体的第一客户端的数量可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the number of first clients may be one, the number of first clients may also be two, and the number of first clients may also be multiple; the specific number of first clients may be determined according to actual conditions It is determined that this embodiment of the present application does not limit this.

在本申请实施例中,目标列表为记录第一存储键的列表。目标列表可以为数据存储装置中配置的列表。In this embodiment of the present application, the target list is a list in which the first storage key is recorded. The target list may be a list configured in the data storage device.

示例性的,目标列表可以为do_key_list列表。Exemplarily, the target list may be a do_key_list list.

在本申请实施例中,分布式数据库和缓存都为Key-Value(K-V)数据存储格式的数据库。其中,K为数据的键,V为数据的值。In the embodiments of the present application, both the distributed database and the cache are databases in the Key-Value (K-V) data storage format. Among them, K is the key of the data, and V is the value of the data.

需要说明的是,第一存储键即为待更新数据的K,第一存储值即为待更新数据的V。It should be noted that the first storage key is K of the data to be updated, and the first stored value is V of the data to be updated.

S102、将第一存储键和第一存储值写入分布式数据库。S102. Write the first storage key and the first storage value into the distributed database.

在本申请实施例中,数据存储装置确定待更新数据的第一存储键和第一存储值之后,数据存储装置就可以将第一存储键和第一存储值写入分布式数据库。In the embodiment of the present application, after the data storage apparatus determines the first storage key and the first storage value of the data to be updated, the data storage apparatus may write the first storage key and the first storage value into the distributed database.

在本申请实施例中,分布式数据库可以为tikv数据库;分布式数据库也可以为其他基于raft协议的kv存储,再进行相应的定制的数据库,比如:leveldb Rocksdb等。具体的分布式数据库可以根据实际情况进行确定,本申请实施例对此不作限定。In the embodiment of the present application, the distributed database may be a tikv database; the distributed database may also be other kv storage based on the raft protocol, and then a corresponding customized database, such as leveldb Rocksdb, etc. The specific distributed database may be determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,若分布式数据为tikv数据库,则tikv可以包括串口硬盘(Serial Advanced Technology Attachment,SATA)和存储器(Memory Machine)。In this embodiment of the present application, if the distributed data is a tikv database, the tikv may include a serial hard disk (Serial Advanced Technology Attachment, SATA) and a memory (Memory Machine).

在本申请实施例中,数据存储装置中设置有kv数据库代理网关(proxy),在数据存储装置中的代理网关接收到第一客户端传输的待更新数据的情况下,数据存储装置利用代理网关将第一存储键和第一存储值存储至分布式数据库。In the embodiment of the present application, a kv database proxy gateway (proxy) is set in the data storage device, and 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 The first stored key and the first stored value are stored in the distributed database.

在本申请实施例中,数据存储装置确定待更新数据的第一存储键和第一存储值之前,数据存储装置在接收到第一客户端传输的待更新数据的情况下,数据存储装置还会确定接收到待更新数据的时间戳;相应的,数据存储装置将第一存储键写入目标列表的过程,包括:数据存储装置将时间戳和第一存储键写入目标列表。In this embodiment of the present application, before the data storage device determines the first storage key and the first storage value of the data to be updated, when the data storage device receives the to-be-updated data transmitted by the first client, the data storage device will also Determine the time stamp of receiving the data to be updated; correspondingly, the process of writing the first storage key into the target list by the data storage device includes: the data storage device writes the time stamp and the first storage key into the target list.

在本申请实施例中,时间戳为精确到秒的时间,如:年月日时分秒。In this embodiment of the present application, the time stamp is time accurate to seconds, such as year, month, day, hour, minute, second.

在本申请实施例中,数据存储装置确定接收到待更新数据的时间戳之后,在将时间戳和第一存储键写入目标列表失败的情况下,数据存储装置向第一客户端传输待更新数据写入失败的响应信息。In the embodiment of the present application, after the data storage device determines that the time stamp of the data to be updated is received, in the case where writing the time stamp and the first storage key into the target list fails, the data storage device transmits the data to be updated to the first client Response message for data write failure.

在本申请实施例中,数据存储装置将第一存储键写入目标列表之后,在将待更新数据写入分布式数据库失败的情况下,数据存储装置就向第一客户端传输待更新数据写入失败的响应信息。在将待更新数据写入分布式数据库成功的情况下,数据存储装置就向第一客户端传输待更新数据写入成功的响应信息。In the embodiment of the present application, after the data storage device writes the first storage key into the target list, in the case where writing the data to be updated into the distributed database fails, the data storage device transmits the data to be updated to the first client. Enter the failed response information. In the case that the writing of the data to be updated into the distributed database is successful, the data storage apparatus transmits the response information that the writing of the data to be updated is successful to the first client.

在本申请实施例中,数据存储装置将第一存储键和第一存储值写入分布式数据库的过程,包括:数据存储装置将第一存储键和第一存储值存储至分布式数据库中的主节点中;数据存储装置在利用主节点对第一存储键和第一存储值存储成功的情况下,将主节点中的第一存储键和第一存储值同步至分布式数据库中的从节点中,以在从分布式数据库中获取存储数据的情况下,优先从从节点中获取第一存储值;数据存储装置在利用从节点对第一存储键和第一存储值存储成功的情况下,确定利用分布式数据库对待更新数据存储成功。In the embodiment of the present application, the process of writing the first storage key and the first stored value by the data storage device into the distributed database includes: the data storage device stores the first storage key and the first stored value in the distributed database. In the master node; the data storage device synchronizes the first storage key and the first storage value in the master node to the slave node in the distributed database under the condition that the first storage key and the first storage value are successfully stored by the master node In the case of obtaining the stored data from the distributed database, the first storage value is preferentially obtained from the slave node; when the data storage device uses the slave node to successfully store the first storage key and the first stored value, Determine the success of using the distributed database to store the updated data.

需要说明的是,主节点用于读数据或者写数据;从节点用于读数据。从节点的数量可以为一个,从节点的数据也可以为两个,从节点的数量还可以为多个;具体的从节点的数量可以根据实际情况进行确定,本申请实施例对此不作限定。It should be noted that the master node is used to read or write data; the slave node is used to read data. The number of slave nodes may be one, the data of the slave nodes may also be two, and the number of slave nodes may also be multiple; the specific number of slave nodes may be determined according to the actual situation, which is not limited in this embodiment of the present application.

还需要说明的是,主节点的数量可以为一个;主节点的数量也可以为两个;主节点的数量还可以为多个;具体的主节点的数量可以根据实际情况进行确定,本申请实施例对此不作限定。It should also be noted that the number of master nodes can be one; the number of master nodes can also 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 implements The example does not limit this.

还需要说明的是,若分布式数据为tikv数据库,则主节点可以为SATA主节点;主节点也可以为其他的主节点;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。若分布式数据为tikv数据库,则从节点可以为SATA从节点;从节点也可以为MemoryMachine从节点;从节点还可以为Memory Machine从节点和SATA从节点;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。It should also be noted that, if the distributed data is a tikv database, the master node may be a SATA master node; the master node may also be other master nodes; the specifics can be determined according to the actual situation, which is not limited in the embodiments of this application. . If the distributed data is a tikv database, the slave node can be a SATA slave node; the slave node can also be a MemoryMachine slave node; the slave node can also be a Memory Machine slave node and a SATA slave node; the specific can be determined according to the actual situation. This is not limited in the application examples.

在本申请实施例中,数据存储装置将待更新数据存储至分布式数据库中的主节点中的过程,包括:代理网关先访问集群管理模块(Placement Driver Server,PD),从PD中获取待更新数据的第一存储键(key)对应的存储区块(region)信息,然后将待更新数据(第一存储键和第一存储值)存储至分布式数据库中的region中,即存储至分布式数据库的主节点和分布式数据库的从节点中。In the embodiment of the present application, the process of storing the data to be updated in the master node in the distributed database by the data storage device includes: the proxy gateway first accesses the cluster management module (Placement Driver Server, PD), and obtains the to-be-updated data from the PD The storage block (region) information corresponding to the first storage key (key) of the data, and then the data to be updated (the first storage key and the first storage value) are stored in the region in the distributed database, that is, stored in the distributed database. In the master node of the database and the slave node of the distributed database.

在本申请实施例中,若从节点的数量为多个。数据存储装置在利用从节点对第一存储键和第一存储值存储成功的情况下,确定利用分布式数据库对待更新数据存储成功的过程,可以为数据存储装置在利用多个从节点对第一存储键和第一存储值存储成功的情况下,确定利用分布式数据库对待更新数据存储成功;也可以为数据存储装置在利用多个从节点中的部分从节点对第一存储键和第一存储值存储成功的情况下,确定利用分布式数据库对待更新数据存储成功;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, if the number of slave nodes is multiple. When the data storage device uses the slave node to successfully store the first storage key and the first stored value, and determines that the process of using the distributed database to store the data to be updated is successful, it may be that the data storage device uses a plurality of slave nodes to store the first storage key successfully. When the storage key and the first storage value are successfully stored, it is determined that the data to be updated is stored successfully by using the distributed database; it may also be that the data storage device uses some slave nodes in the plurality of slave nodes to store the first storage key and the first storage key. If the value is stored successfully, it is determined that the data to be updated is stored successfully by using the distributed database; the specific value can be determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,数据存储装置还可以在部分从节点与部分主节点(部分主节点与部分从节点的数量之和为预设节点数量)对第一存储键和第一存储值存储成功的情况下,就确定利用分布式数据库对待更新数据存储成功;或者是数据存储装置在部分主节点对第一存储键和第一存储值存储成功的情况下,就确定利用分布式数据库对待更新数据存储成功;再或者是数据存储装置在全部的主节点对第一存储键和第一存储值存储成功的情况下,就确定利用分布式数据库对待更新数据存储成功;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the data storage device may also successfully store the first storage key and the first stored value on some slave nodes and some master nodes (the sum of the number of some master nodes and some slave nodes is the preset number of nodes) Under the circumstance, it is determined to use the distributed database to store the updated data successfully; or the data storage device determines to use the distributed database to store the updated data in the case of successful storage of the first storage key and the first stored value by some master nodes. The storage is successful; or the data storage device determines that the distributed database is used to store the updated data successfully when all the master nodes successfully store the first storage key and the first storage value; the specific can be determined according to the actual situation. , which is not limited in the embodiments of the present application.

S103、在缓存中查找第一存储键对应的历史值,并删除历史值。S103. Search the cache for the historical value corresponding to the first storage key, and delete the historical value.

在本申请实施例中,数据存储装置可以先将第一存储键和第一存储值写入分布式数据库,然后数据存储装置就在缓存中查找第一存储键对应的历史值,并删除历史值;数据存储装置也可以在将第一存储键和第一存储值写入分布式数据库的同时;数据存储装置就在缓存中查找第一存储键对应的历史值,并删除历史值;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In the embodiment of the present application, the data storage device may first write the first storage key and the first storage value into the distributed database, and then the data storage device searches the cache for the historical value corresponding to the first storage key, and deletes the historical value The data storage device can also write the first storage key and the first storage value into the distributed database; the data storage device searches the cache for the historical value corresponding to the first storage key, and deletes the historical value; It is determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,数据存储装置在缓存中查找第一存储键对应的历史值,并删除历史值之后,数据存储装置在确定出删除历史值失败的情况下,从分布式数据库中获取第一存储值,从缓存中获取第一存储键对应的第二存储值;数据存储装置在第一存储值与第二存储值不同的情况下,删除第二存储值。In the embodiment of the present application, the data storage device searches the cache for the historical value corresponding to the first storage key, and deletes the historical value. In the case where the data storage device determines that the deletion of the historical value fails, the data storage device obtains the first storage key from the distributed database. For a stored value, the second stored value corresponding to the first storage key is obtained from the cache; the data storage device deletes the second stored value when the first stored value is different from the second stored value.

在本申请实施例中,数据存储装置在确定出删除历史值失败的情况下数据存储装置就继续删除该历史值。In the embodiment of the present application, the data storage device continues to delete the historical value when it is determined that the deletion of the historical value fails.

需要说明的是,第二存储值即为历史值。It should be noted that the second stored value is the historical value.

S104、在预设时间到达时,在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值;目标存储键包括第一存储键。S104. When the preset time arrives, in the distributed database, obtain the target storage value corresponding to the target storage key in the target list; the target storage key includes the first storage key.

在本申请实施例中,数据存储装置在缓存中查找第一存储键对应的历史值,并删除历史值之后,在预设时间到达时,数据存储装置就可以在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值。In the embodiment of the present application, the data storage device searches the cache for the historical value corresponding to the first storage key, and deletes the historical value. When the preset time arrives, the data storage device can obtain the target list in the distributed database. The target storage value corresponding to the target storage key in .

需要说明的是,目标存储键包括第一存储键。It should be noted that the target storage key includes the first storage key.

在本申请实施例中,预设时间可以为数据存储装置中配置的时间,预设时间也可以为其他装置传输至数据存储装置中的时间;预设时间也可以为数据存储装置以其他的方式得到的数据;具体的数据存储装置得到预设时间的方式可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the preset time may be the time configured in the data storage device, the preset time may also be the time transmitted by other devices to the data storage device; the preset time may also be the data storage device in other ways The obtained data; the specific manner in which the data storage device obtains the preset time may be determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,预设时间的数量为多个。示例性的,每隔5分钟可以设置有一个预设时间;也可以每隔3分钟设置有一个预设时间;具体的预设时间之间的时间间隔可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the number of preset times is multiple. Exemplarily, a preset time can be set every 5 minutes; a preset time can also be set every 3 minutes; the time interval between the specific preset times can be determined according to the actual situation, the embodiment of the present application This is not limited.

在本申请实施例中,目标存储键可以为预设时间与上一个预设时间之间的时间段,接收到的数据对应的存储键。In this embodiment of the present application, the target storage key may be a time period between the preset time and the last preset time, and the storage key corresponding to the received data.

在本申请实施例中,数据存储装置在预设时间到达时,在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值的过程,包括:数据存储装置从目标列表中,确定上一次预设时间与预设时间段内写入的目标存储键;数据存储装置在预设时间到达时,在分布式数据库中,获取目标存储键对应的目标存储值。In the embodiment of the present application, when the data storage device arrives at the preset time, in the distributed database, the process of obtaining the target storage value corresponding to the target storage key in the target list includes: the data storage device determines from the target list. The last preset time and the target storage key written in the preset time period; when the preset time arrives, the data storage device obtains the target storage value corresponding to the target storage key in the distributed database.

在本申请实施例中,目标存储键的数量可以为一个,目标存储键的数量也可以为两个,目标存储键的数量还可以为多个,具体的目标存储键的数量可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the number of target storage keys may be one, the number of target storage keys may also be two, and the number of target storage keys may also be multiple, and the specific number of target storage keys may be determined according to the actual situation It is determined that this embodiment of the present application does not limit this.

示例性的,若目标存储键的数量可以为一个,则目标存储键为第一存储键。Exemplarily, if the number of target storage keys can be one, the target storage key is the first storage key.

S105、将目标存储值同步至缓存中。S105. Synchronize the target stored value to the cache.

在本申请实施例中,数据存储装置在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值之后,数据存储装置就可以将目标存储值同步至缓存中。In the embodiment of the present 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.

在本申请实施例中,数据存储装置将目标存储值同步至缓存中的过程,可以为数据存储装置利用代理网关将目标存储值同步至缓存中。In this embodiment of the present application, the process of synchronizing the target storage value into the cache by the data storage device may be a proxy gateway for the data storage device to synchronize the target storage value into the cache.

需要说明的是,缓存与分布式数据库的数据存储格式相同,都为key-value数据存储格式的数据库。It should be noted that the data storage format of the cache is the same as that of the distributed database, and both are databases in the key-value data storage format.

在本申请实施例中,缓存可以为Redis,缓存也可以为其他的存储模块,具体的缓存模块可以根据实际情况进行确定,本申请实施例对此不作限定。In the embodiment of the present application, the cache may be Redis, and the cache may also be other storage modules, and the specific cache module may be determined according to the actual situation, which is not limited in the embodiment of the present application.

在本申请实施例中,数据存储装置将目标存储值同步至缓存中的过程,包括:数据存储装置利用代理网关将目标存储值同步至缓存的缓存主节点;数据存储装置在利用缓存主节点对目标存储值存储成功的情况下,确定缓存对待更新数据同步成功。In the embodiment of the present application, the process of the data storage device synchronizing the target storage value to the cache includes: the data storage device uses the proxy gateway to synchronize the target storage value to the cache master node of the cache; the data storage device uses the cache master node to synchronize the cache master node. If the target storage value is successfully stored, it is determined that the cache is successfully synchronized with the data to be updated.

在本申请实施例中,缓存主节点的数量可以为一个,缓存主节点的数量也可以为两个;缓存主节点的数量还可以为多个;具体的缓存主节点的数量可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the number of cache master nodes may be one, and the number of cache master nodes may also be two; the number of cache master nodes may also be multiple; the specific number of cache master nodes may be determined according to actual conditions It is determined that this embodiment of the present application does not limit this.

在本申请实施例中,数据存储装置利用代理网关将目标存储值同步至缓存的缓存主节点之后,数据存储装置在利用缓存主节点对目标存储值存储失败的情况下,利用校验组件继续向缓存主节点中写入目标存储值,直至缓存主节点对待更新数据存储成功。In the embodiment of the present application, after the data storage device uses the proxy gateway to synchronize the target storage value to the cache master node of the cache, in the case that the data storage device fails to store the target storage value by using the cache master node, the data storage device uses the verification component to continue to the cache. The target storage value is written in the cache master node until the cache master node successfully stores the updated data.

需要说明的是,数据存储装置中设置有校验组件(verify)。It should be noted that a verification component (verify) is provided in the data storage device.

在本申请实施例中,数据存储装置可以在第一次利用缓存主节点对目标存储值存储失败的情况下,利用校验组件继续向缓存主节点中写入目标存储值,直至缓存主节点对目标存储值存储成功;数据存储装置可以在利用缓存主节点对目标存储值存储失败、且存储失败的次数大于或者等于预设次数的情况下,数据存储装置就利用校验组件继续向缓存主节点中写入目标存储值,直至缓存主节点对目标存储值存储成功;具体得可以根据实际情况进行确定,本申请实施例对此不作限定。In the embodiment of the present application, the data storage device may use the verification component to continue to write the target storage value to the cache master node when the cache master node fails to store the target storage value for the first time, until the cache master node fails to store the target storage value. The target storage value is successfully stored; the data storage device can use the verification component to continue to the cache master node when the target storage value fails to be stored by the cache master node and the number of storage failures is greater than or equal to the preset number of times. The target storage value is written in the cache until the cache master node successfully stores the target storage value; the specific value can be determined according to the actual situation, which is not limited in this embodiment of the present application.

需要说明的是,预设次数可以为数据存储装置中配置的次数;预设次数可以为其他装置传输至数据存储装置中的次数;具体的数据存储装置获取到预设次数的方式可以根据实际情况进行确定,本申请实施例对此不作限定。It should be noted that the preset number of times may be the number of times configured in the data storage device; the preset number of times may be the number of times that other devices transmit to the data storage device; the specific method of obtaining the preset number of times by the data storage device may be based on the actual situation. It is determined, which is not limited in this embodiment of the present application.

示例性的,预设次数可以为3次,预设次数可以为5次,预设次数还可以为其他的次数值;具体的预设次数可以根据实际情况进行确定,本申请实施例对此不作限定。Exemplarily, the preset number of times may be 3 times, the preset number of times may be 5 times, and the preset number of times may also be other times. limited.

在本申请实施例中,数据存储装置将目标存储值同步至缓存中之后,在校验时间到达时,数据存储装置就利用校验组件将代理网关写入分布式数据库中的第一数据和利用代理网关同步至缓存中的第二数据进行对比;在确定出第一数据与第二数据不同的情况下,利用第一数据修改第二数据。In the embodiment of the present application, after the data storage device synchronizes the target storage value into the cache, when the verification time arrives, the data storage device uses the verification component to write the proxy gateway into the first data in the distributed database and use The proxy gateway synchronizes to the second data in the cache for comparison; when it is determined that the first data is different from the second data, the second data is modified by using the first data.

需要说明的是,第一数据包括待更新数据。第二数据为缓存中的全部数据;第一数据与第二数据的数据键相同。It should be noted that the first data includes 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.

在本申请实施例中,校验时间可以为数据存储装置中配置的时间;校验时间也可以为其他装置传输至数据存储装置中的时间信息;具体的数据存储装置获取到校验时间的方式可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the verification time may be the time configured in the data storage device; the verification time may also be the time information transmitted by other devices to the data storage device; the specific method for the data storage device to obtain the verification time It may be determined according to the actual situation, which is not limited in this embodiment of the present application.

示例性的,校验时间可以为每天晚上12点;校验时间也可以为每一个周一;校验时间还可以为其他的定期时间;具体的校验时间可以根据实际情况进行确定,本申请实施例对此不作限定。Exemplarily, the verification time can be every night at 12:00; 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 implements The example does not limit this.

在本申请实施例中,第一数据和第二数据的数量为多个;数据存储装置利用校验组件将代理网关写入分布式数据库中的第一数据和利用代理网关同步至缓存中的第二数据进行对比的过程,包括:数据存储装置获取多个第一数据对应的多个第一键和多个第一值,以及多个第二数据对应的多个第一键和多个第二值;数据存储装置按照预设分组数对多个第一键进行分组,得到多组第一键;数据存储装置获取多组第一键对应的多组第一值和多组第二值;数据存储装置对多组第一值中的每一组第一值进行加密处理,得到多个第一加密值;对多组第二值中的每一组第二值进行加密处理,得到多个第二加密值;数据存储装置对比多个第一加密值与多个第二加密值;相应的,数据存储装置在确定出第一数据与第二数据不同的情况下,利用第一数据修改第二数据的过程,包括:数据存储装置在多个第一加密值分别与多个第二加密值不同的情况下,确定第一数据与第二数据不同;数据存储装置利用第一数据修改第二数据。In the embodiment of the present application, the number of the first data and the second data is multiple; the data storage device uses the verification component to write the first data written by the proxy gateway into the distributed database and use the proxy gateway to synchronize the first data in the cache The process of comparing the two data includes: the data storage device obtains a plurality of first keys and a plurality of first values corresponding to a plurality of first data, and a plurality of first keys and a plurality of second data corresponding to the plurality of second data value; the data storage device groups multiple first keys according to the preset number of groups to obtain multiple sets of first keys; the data storage device obtains multiple sets of first values and multiple sets of second values corresponding to multiple sets of first keys; data The storage device performs encryption processing on each set of first values in the multiple sets of first values to obtain multiple first encrypted values; performs encryption processing on each set of second values in the multiple sets of second values to obtain multiple first encrypted values. Two encrypted values; the data storage device compares a plurality of first encrypted values with a plurality of second encrypted values; correspondingly, the data storage device uses the first data to modify the second data when it is determined that the first data is different from the second data The process of data includes: the data storage device determines 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 data storage device uses the first data to modify the second data .

需要说明的是,多个第一键包括第一存储键。It should be noted that the plurality of first keys include first storage keys.

在本申请实施例中,多个第一键为多个第一数据的Key,多个第一值为多个第一数据的Value,即一个第一键对应一个第一值对应一个第一数据。In this embodiment of the present application, multiple first keys are keys of multiple first data, and multiple first values are values of multiple first data, that is, one first key corresponds to one first value and one first data .

在本申请实施例中,多个第一键为多个第二数据的Key,多个第二值为多个第二数据的Value,即一个第一键对应一个第二值对应一个第二数据。In this embodiment of the present application, multiple first keys are keys of multiple second data, and multiple second values are values of multiple second data, that is, one first key corresponds to one second value and one second data corresponds to one .

在本申请实施例中,预设分组数可以为数据存储装置中配置的数量;预设分组数也可以为其他装置传输至数据存储装置中的数量;预设分组数还可以为数据存储装置以其他的方式的到的数量;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the preset number of groups may be the number configured in the data storage device; the preset number of groups may also be the number transmitted by other devices to the data storage device; the preset number of groups may also be the number of data storage devices The number obtained in other ways; the specific can be determined according to the actual situation, which is not limited in this embodiment of the present application.

示例性的,预设分组数可以为10,预设分组数也可以为20,预设分组数还可以为5;具体的预设分组数的数量可以根据实际情况进行确定,本申请实施例对此不作限定。Exemplarily, the preset number of groups may be 10, the preset number of groups may also be 20, and the preset number of groups may also be 5; the specific number of preset groups may be determined according to the actual situation. This is not limited.

在本申请实施例中,多组第一键与多组第一值一一对应,即一组第一键对应一组第一值;多组第一键与多组第二值一一对应,即一组第一键对应一组第二值。In the embodiment of the present application, multiple sets of first keys correspond to multiple sets of first values one-to-one, that is, a set of first keys corresponds to a set of first values; multiple sets of first keys correspond to multiple sets of second values one-to-one, That is, a set of first keys corresponds to a set of second values.

在本申请实施例中,数据存储装置对多组第一值中的每一组第一值进行加密处理,得到多个第一加密值的过程,可以为数据存储装置利用MD5对多组第一值中的每一组第一值进行加密处理,得到多个第一加密值;也可以为数据存储装置利用其他的加密算法对多组第一值中的每一组第一值进行加密处理,得到多个第一加密值;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the data storage device performs encryption processing on each set of first values in the multiple sets of first values to obtain multiple first encrypted values. Each group of first values in the value is encrypted to obtain a plurality of first encrypted values; other encryption algorithms may also be used for the data storage device to perform encryption processing on each group of first values in the plurality of groups of first values, A plurality of first encrypted values are obtained; the specific value may be determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,数据存储装置对多组第二值中的每一组第二值进行加密处理,得到多个第二加密值的过程,可以为数据存储装置利用MD5对多组第二值中的每一组第二值进行加密处理,得到多个第二加密值;也可以为数据存储装置利用其他的加密算法对多组第二值中的每一组第二值进行加密处理,得到多个第二加密值;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the data storage device performs encryption processing on each of the multiple sets of second values to obtain multiple second encrypted values. The data storage device may use MD5 to encrypt the multiple sets of second values Each group of second values in the value is encrypted to obtain a plurality of second encrypted values; other encryption algorithms can also be used for the data storage device to perform encryption processing on each group of second values in the plurality of groups of second values, A plurality of second encrypted values are obtained; the specific value may be determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,在多个第一加密值分别与多个第二加密值不同的情况下,数据存储装置就确定第一数据与第二数据不同;然后数据存储装置就删除第二数据,再将第一数据同步至缓存中,即利用第一数据修改第二数据。In this embodiment of the present application, when the plurality of first encrypted values are different from the plurality of second encrypted values respectively, the data storage device determines that the first data is different from the second data; then the data storage device deletes the second data , and then synchronize the first data to the cache, that is, use the first data to modify the second data.

在本申请实施例中,数据存储装置将多个第一加密值中的第一个加密值与多个第二加密值中的第一个加密值进行对比;然后数据存储装置将多个第一加密值中的第二个加密值与多个第二加密值中的第二个加密值进行对比;…,直至数据存储装置将多个第一加密值中的最后一个加密值与多个第二加密值中的最后一个加密值进行对比,从而实现多个第一加密值与多个第二加密值的对比过程。In this embodiment of the present application, the data storage device compares the first encrypted value of the plurality of first encrypted values with the first encrypted value of the plurality of second encrypted values; then the data storage device stores the first encrypted value of the plurality of first encrypted values comparing a second encrypted value of the plurality of encrypted values with a second encrypted value of the plurality of second encrypted values; . . . until the data storage device compares the last encrypted value of the plurality of first encrypted values with the plurality of second encrypted values The last encrypted value in the encrypted values is compared, so as to realize the comparison process of the plurality of first encrypted values and the plurality of second encrypted values.

在本申请实施例中,目标存储键为目标列表中的部分存储键,数据存储装置也可以定期从目标列表中获取定期时间段内的多个增量存储键,在分布式数据库中获取该多个增量存储键对应的多个第一增量存储值,在缓存中获取该多个增量存储键对应的多个第二增量存储值;按照预设分组数对多个增量存储键进行分组,得到多组存储键;获取多组存储键对应的多组第一增量存储值和多组第二增量存储值;对多组第一增量存储值进行加密处理,得到多个第三加密值;对多组第二增量存储值进行加密处理,得到多个第四加密值;对比多个第三加密值与多个第四加密值,在多个第三加密值分别与多个第四加密值不同的情况下,利用多个第一增量存储值修改多个第四增量存储值。In this embodiment of the present application, the target storage key is a partial storage key in the target list, and the data storage device may also periodically obtain multiple incremental storage keys within a regular time period from the target list, and obtain the multiple storage keys from the distributed database. Multiple first incremental storage values corresponding to each incremental storage key, obtain multiple second incremental storage values corresponding to the multiple incremental storage keys in the cache; Perform grouping to obtain multiple sets of storage keys; obtain multiple sets of first incremental storage values and multiple sets of second incremental storage values corresponding to multiple sets of storage keys; perform encryption processing on multiple sets of first incremental storage values to obtain multiple the third encrypted value; perform encryption processing on multiple sets of second incremental storage values to obtain multiple fourth encrypted values; compare the multiple third encrypted values with the multiple fourth encrypted values, where the multiple third encrypted values are When the plurality of fourth encrypted values are different, the plurality of fourth incremental storage values are modified by using the plurality of first incremental storage values.

在本申请实施例中,数据存储装置在确定待更新数据的第一存储键和第一存储值之后,将目标存储值同步至缓存中之前,数据存储装置在缓存中的缓存主节点切换的情况下,从分布式数据库中获取第一存储值,从缓存中获取第一存储键对应的第二存储值;数据存储装置在第一存储值与第二存储值不同的情况下,删除第二存储值。In the embodiment of the present application, after the data storage device determines the first storage key and the first storage value of the data to be updated, and before synchronizing the target storage value into the cache, the data storage device switches the cache master node in the cache , obtain the first storage value from the distributed database, and obtain the second storage value corresponding to the first storage key from the cache; the data storage device deletes the second storage value when the first storage value is different from the second storage value. value.

在本申请实施例中,数据存储装置在接收到热数据缓存指令的情况下,数据存储装置就从缓存指令中获取热数据;数据存储装置将热数据写入缓存中。In the embodiment of the present application, when the data storage device receives the hot data cache instruction, the data storage device obtains the hot data from the cache instruction; the data storage device writes the hot data into the cache.

在本申请实施例中,数据存储装置在确定出缓存中的缓存数据的访问热度小于或者等于访问热度阈值的情况下,删除缓存数据;或者,数据存储装置在确定出缓存数据的最后一次访问时间与当前时刻的时间长度大于或者等于时间长度阈值的情况下,删除缓存数据。In this embodiment of the present application, the data storage device deletes the cached data when it is determined that the access heat of the cached data in the cache is less than or equal to the access heat threshold; or the data storage device determines the last access time of the cached data If the time length from the current moment is greater than or equal to the time length threshold, the cached data is deleted.

在本申请实施例中,访问热度可以为数据存储装置中配置的热度信息;访问热度也可以为其他设备传输至数据存储装置中的热度信息;具体的数据存储装置获取到访问热度的方式可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the access heat may be the heat information configured in the data storage device; the access heat may also be the heat information transmitted to the data storage device by other devices; the specific data storage device obtains the access heat according to the method. The actual situation is determined, which is not limited in this embodiment of the present application.

在本申请实施例中,时间长度阈值可以为数据存储装置中配置的阈值;时间长度阈值也可以为其他设备传输至数据存储装置中的阈值;具体的数据存储装置获取到时间长度阈值的方式可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the time length threshold may be a threshold configured in the data storage device; the time length threshold may also be a threshold transmitted by other devices to the data storage device; the specific data storage device obtains the time length threshold by a method. It is determined according to the actual situation, which is not limited in this embodiment of the present application.

需要说明的是,Redis缓存搭建在docker平台中。Redis中配置了LFU内存淘汰策略,只保留最近访问的热数据。其中,LFU内存淘汰策略具体包括:只在redis上存储了部分数据,根据访问时间淘汰很久没有访问的历史数据(保证热点数据不被淘汰);并新增管理台连接redis,通过管理台指定管理台中的部分数据不被淘汰。It should be noted that the Redis cache is built on the docker platform. The LFU memory elimination strategy is configured in Redis, and only recently accessed hot data is retained. Among them, the LFU memory elimination strategy specifically includes: only part of the data is stored on redis, and historical data that has not been accessed for a long time is eliminated according to the access time (to ensure that hotspot data is not eliminated); and a new management console is connected to redis, and designated management through the management console Part of the data in Taichung will not be eliminated.

在本申请实施例中,分布式数据库中的从节点的数量为多个。数据存储装置将目标存储值同步至缓存中之后,数据存储装置在接收到第二客户端传输的数据获取指令的情况下,数据存储装置就从缓存中获取获取指令对应的待获取数据;数据存储装置在未从缓存中获取到待获取数据的情况下,获取分布式数据库中的从节点对应的第一读取延迟参数和从节点标识;数据存储装置根据第一读取延迟参数和从节点标识,从多个从节点中确定目标从节点;数据存储装置从目标从节点中读取待获取数据。In this embodiment of the present application, the number of slave nodes in the distributed database is multiple. After the data storage device synchronizes the target storage value to the cache, when the data storage device receives the data acquisition instruction transmitted by the second client, the data storage device acquires the data to be acquired corresponding to the acquisition instruction from the cache; data storage The device acquires the first read delay parameter and the identifier of the slave node corresponding to the slave node in the distributed database without acquiring the data to be acquired from the cache; the data storage device obtains the first read delay parameter and the identifier of the slave node according to the first read delay parameter and the identifier of the slave node. , the target slave node is determined from the plurality of slave nodes; the data storage device reads the data to be acquired from the target slave node.

在本申请实施例中,第一客户端和第二客户端可以为同一客户端;第一客户端和第二客户端也可以为不同的客户端;具体的可以根据实际情况进行确定,本申请实施例对此不作限定。其中,第一客户端或者第二客户端为wekv客户端。In this embodiment of the present application, the first client and the second client may be the same client; the first client and the second client may also be different clients; The embodiment does not limit this. Wherein, the first client or the second client is a wekv client.

在本申请实施例中,数据存储装置就从缓存中获取获取指令对应的待获取数据的过程,包括数据存储存储装置利用代理网关从缓存中获取获取指令对应的待获取数据。In the embodiment of the present application, the process of acquiring the data to be acquired corresponding to the acquisition instruction from the cache by the data storage device includes that the data storage device uses the proxy gateway to acquire the data to be acquired corresponding to the acquisition instruction from the cache.

在本申请实施例中,第一读取延迟参数为分布式数据库中的多个从节点对应的读取延迟参数。从节点标识为分布式数据库中的多个从节点对应的标识。In this embodiment of the present application, the first read delay parameter is a read delay parameter corresponding to multiple slave nodes in the distributed database. The slave node identifiers are identifiers corresponding to multiple slave nodes in the distributed database.

需要说明的是,从节点标识包括存储器(Memory Machine)从节点标识和串口硬盘(SATA)从节点标识。It should be noted that the slave node identification includes a memory (Memory Machine) slave node identification and a serial hard disk (SATA) slave node identification.

在本申请实施例中,数据存储装置根据第一读取延迟参数和从节点标识,从多个从节点中确定目标从节点的过程,包括数据存储装置从从节点标识中筛选存储器(MemoryMachine)从节点标识的存储器从节点,并从第一读取延迟参数中获取该存储器从节点对应的多个读取延迟参数;数据存储装置对多个读取延迟参数按照延迟参数从小到大的顺序进行排序,得到延迟参数序列;数据存储装置从延迟参数序列的第一个延迟参数开始,获取预设数量的延迟参数对应的从节点,作为目标从节点。In this embodiment of the present application, a process in which the data storage device determines a target slave node from a plurality of slave nodes according to the first read delay parameter and the slave node identifier includes the process that the data storage device selects the memory (MemoryMachine) The memory slave node identified by the node obtains multiple read delay parameters corresponding to the memory slave node from the first read delay parameter; the data storage device sorts the multiple read delay parameters in an ascending order of the delay parameters , to obtain a delay parameter sequence; starting from the first delay parameter of the delay parameter sequence, the data storage device obtains slave nodes corresponding to a preset number of delay parameters as target slave nodes.

在本申请实施例中,数据存储装置从多个从节点中确定目标从节点之后,数据存储装置在未能从目标从节点中获取待获取数据的情况下,获取第一从节点标识对应的第一从节点;数据存储装置从第一从节点中确定目标节点;并从目标节点中读取待获取数据。In this embodiment of the present application, after the data storage device determines a target slave node from a plurality of slave nodes, the data storage device obtains the first slave node identifier corresponding to the first slave node in the case that the data storage device fails to obtain the data to be obtained from the target slave node. a slave node; the data storage device determines a target node from the first slave node; and reads the data to be acquired from the target node.

需要说明的是,第一从节点标识为从节点标识中的部分标识,具体的第一从节点标识为串口硬盘从节点标识。It should be noted that the first slave node identifier is a partial identifier in the slave node identifier, and the specific first slave node identifier is the serial port hard disk slave node identifier.

在本申请实施例中,第一从节点的数量为多个。In this embodiment of the present application, the number of the first slave nodes is multiple.

在本申请实施例中,数据存储装置从第一从节点中确定目标节点的过程,包括:数据存储装置从第一读取延迟参数中获取多个第一从节点对应的多个目标读取延迟参数;数据存储装置对多个目标读取延迟参数按照延迟参数从小到大的顺序进行排序,得到目标延迟参数序列;数据存储装置从目标延迟参数序列的第一个目标延迟参数开始,获取预设数量的目标延迟参数对应的从节点,作为目标从节点。In this embodiment of the present application, the process for the data storage device to determine the target node from the first slave node includes: the data storage device obtains multiple target read delays corresponding to multiple first slave nodes from the first read delay parameter parameters; the data storage device sorts a plurality of target read delay parameters according to the order of delay parameters from small to large, to obtain a target delay parameter sequence; the data storage device starts from the first target delay parameter of the target delay parameter sequence, and obtains the preset The number of slave nodes corresponding to the target delay parameter, as the target slave node.

在本申请实施例中,分布式数据库中的主节点的数量为多个;数据存储装置从第一从节点中确定目标节点之后,数据存储装置还会获取分布式数据库中的主节点对应的第二读取延迟参数;数据存储装置根据第二读取延迟参数从主节点中确定出目标主节点;并从目标主节点中读取待获取数据。In the embodiment of the present application, the number of master nodes in the distributed database is multiple; after the data storage device determines the target node from the first slave node, the data storage device further obtains the first slave node corresponding to the master node in the distributed database. 2. The read delay parameter; the data storage device determines the target master node from the master nodes according to the second read delay parameter; and reads the data to be acquired from the target master node.

在本申请实施例中,数据存储装置根据第二读取延迟参数从主节点中确定出目标主节点的方式,可以为数据存储装置从第二读取延迟参数中获取延迟参数值最小的预设数量的目标延迟参数,并将目标延迟参数对应的主节点作为目标主节点。In this embodiment of the present application, the manner in which the data storage device determines the target master node from the master nodes according to the second read delay parameter may be a preset for the data storage device to obtain the smallest delay parameter value from the second read delay parameter The number of target delay parameters, and the master node corresponding to the target delay parameter is used as the target master node.

在本申请实施例中,获取分布式数据库中的从节点对应的第一读取延迟参数和从节点标识之前,数据存储装置还会标记待获取数据的获取次数;数据存储装置在获取次数大于或者等于获取次数阈值的情况下,从分布式数据库中获取待获取数据;数据存储装置将待获取数据同步至缓存中。In the embodiment of the present application, before acquiring the first read delay parameter corresponding to the slave node and the identifier of the slave node in the distributed database, the data storage device will also mark the acquisition times of the data to be acquired; When it is equal to the threshold of the number of acquisitions, the data to be acquired is acquired from the distributed database; the data storage device synchronizes the data to be acquired into the cache.

在本申请实施例中,获取次数阈值可以为数据存储装置中配置的阈值;获取次数阈值也可以为其他设备传输至数据存储装置中的阈值;具体的数据存储装置获取到获取次数阈值的方式可以根据实际情况进行确定,本申请实施例对此不作限定。In this embodiment of the present application, the threshold for the number of acquisitions may be a threshold configured in the data storage device; the threshold for the number of acquisitions may also be a threshold for other devices to transmit to the data storage device; the specific data storage device may acquire the threshold for the number of acquisitions in a way that It is determined according to the actual situation, which is not limited in this embodiment of the present application.

在本申请实施例中,Redis的数据加载和淘汰策略可以为为利用preload组件根据业务预设的规则加载(频繁访问的数据、设置有热数据标签的数据)数据到redis中;还可以通过接收proxy的通知,将多次未从redis中读取到的数据写入Redis中。In the embodiment of the present application, the data loading and elimination strategy of Redis may be to use the preload component to load (frequently accessed data, data with hot data labels) data into redis according to the rules preset by the business; The proxy's notification writes data that has not been read from redis many times to Redis.

示例性的,如图3所示:数据存储装置在通过代理网关(proxy)接收到第一客户端(client)传输的待更新数据的情况下,数据存储装置就利用代理网关将待更新数据(第一存储键和第一存储值)写入分布式数据库(tikv集群),具体的:代理网关先访问集群管理模块(PD1、PD2、PD3),从集群管理模块中获取第一存储键对应的存储区块(region)信息(包括主节点和从节点),即在分布式数据库中确定存储待更新数据的主节点,并将第一存储键和第一存储值存储至主节点(master)中;数据存储装置在利用主节点对第一存储键和第一存储值存储成功的情况下,将主节点中的第一存储键和第一存储值同步至分布式数据库中的从节点中,在利用从节点对第一存储键和第一存储值存储成功的情况下,确定分布式数据库存储对第一存储键和第一存储值存储成功。数据存储装置在缓存中查找第一存储键对应的历史值,并删除历史值;在预设时间到达时,在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值;数据存储装置将第一存储值同步至缓存中:即数据存储装置利用代理网关将第一存储值同步至缓存(Redis集群)的缓存主节点([1]Master、[2]Master、[3]Master)之后,数据存储装置在利用缓存主节点对第一存储值存储失败的情况下,利用校验组件(verify)继续向缓存主节点中写入第一存储值,直至缓存主节点对第一存储值存储成功。在缓存主节点对第一存储值存储成功的情况下,数据存储装置就将缓存主节点中的第一存储值同步至缓存从节点([1]Slave、[2]Master、[3]Master)中。数据存储装置将目标存储值同步至缓存中之后,在校验时间(perload)到达时,数据存储装置还会利用校验组件将代理网关写入分布式数据库中的第一数据和利用代理网关同步至缓存中的第二数据进行对比;数据存储装置在确定出第一数据与第二数据不同的情况下,就利用第一数据修改第二数据。数据存储装置在接收到第二客户端(client)传输的数据获取指令的情况下,从缓存(Redis)中获取获取指令对应的待获取数据;数据存储装置在未从缓存中获取到待获取数据的情况下,获取分布式数据库中的从节点对应的第一读取延迟参数和从节点标识;根据第一读取延迟参数和从节点标识,从多个从节点中确定目标从节点(MemoryMachine从节点);从目标从节点中读取待获取数据。数据存储装置在未能从目标从节点中获取待获取数据的情况下,获取第一从节点标识对应的第一从节点;从第一从节点中确定目标节点(SATA从节点);并从目标节点中读取待获取数据。若还是未能获取到待获取数据,则数据存储装置会获取分布式数据库中的主节点对应的第二读取延迟参数;根据第二读取延迟参数从主节点中确定出目标主节点(SATA主节点);并从目标主节点中读取待获取数据。Exemplarily, as shown in FIG. 3 : when the data storage device receives the data to be updated transmitted by the first client (client) through the proxy gateway (proxy), the data storage device uses the proxy gateway to store the data to be updated ( The first storage key and the first storage value) are written into the distributed database (tikv cluster), specifically: the proxy gateway first accesses the cluster management module (PD1, PD2, PD3), and obtains the corresponding first storage key from the cluster management module. Storage block (region) information (including master node and slave node), that is, determine the master node that stores the data to be updated in the distributed database, and store the first storage key and first storage value in the master node (master) ; The data storage device synchronizes 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 is used to store the first storage key and the first storage value successfully. Using the condition that the first storage key and the first stored value are successfully stored by the slave node, it is determined that the distributed database storage successfully stores the first storage key and the first stored value. The data storage device searches the cache for the historical value corresponding to the first storage key, and deletes the historical value; when the preset time arrives, obtains the target storage value corresponding to the target storage key in the target list in the distributed database; the data storage The device synchronizes the first stored value to the cache: that is, the data storage device uses the proxy gateway to synchronize the first stored value to the cache master node ([1]Master, [2]Master, [3]Master) of the cache (Redis cluster). Afterwards, in the case where the data storage device fails to store the first stored value by using the cache master node, the data storage device continues to write the first stored value into the cache master node by using the verification component (verify), until the cache master node stores the first stored value Storage succeeded. When the cache master node successfully stores the first stored value, the data storage device synchronizes the first stored value in the cache master node to the cache slave node ([1]Slave, [2]Master, [3]Master) middle. After the data storage device synchronizes the target storage value into the cache, when the verification time (perload) arrives, the data storage device will also use the verification component to write the proxy gateway to the first data in the distributed database and synchronize using the proxy gateway Compare with the second data in the cache; when the data storage device determines that the first data is different from the second data, it modifies the second data by using the first data. When the data storage device receives the data acquisition instruction transmitted by the second client (client), the data to be acquired corresponding to the acquisition instruction is acquired from the cache (Redis); the data storage device does not acquire the to-be-obtained data from the cache In the case of obtaining the first read delay parameter and the slave node identifier corresponding to the slave node in the distributed database; according to the first read delay parameter and the slave node identifier, determine the target slave node (MemoryMachine from a plurality of slave nodes) from a plurality of slave nodes. node); read the data to be obtained from the target slave node. In the case where the data storage device fails to obtain the data to be obtained from the target slave node, obtain the first slave node corresponding to the first slave node identifier; determine the target node (SATA slave node) from the first slave node; Read the data to be obtained from the node. If the data to be acquired still fails to be acquired, the data storage device will acquire the second read delay parameter corresponding to the master node in the distributed database; determine the target master node (SATA) from the master node according to the second read delay parameter. master node); and read the data to be obtained from the target master node.

需要说明的是,tikv集群中的主节点包括SATA主节点(region[1](master)、region[2](master)、…、region[n](master));tikv集群中的从节点包括SATA从节点(region[1](slave)、region[2](slave)、…、region[n](slave))和Memory Machine从节点(region[1](slave)、region[2](slave)、…、region[n](slave))。It should be noted that the master node in the tikv cluster includes the SATA master node (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)).

示例性的,如图4所示:在利用proxy接收到第一客户端(client)传输的待更新数据的情况下,确定接收到待更新数据的时间戳,以及待更新数据的第一存储键和第一存储值,并将时间戳和第一存储键写入目标列表(将key和时间戳写入do_key_list);在写入目标列表失败的情况下,向第一客户端传输待更新数据写入失败的响应信息。在写入目标列表成功的情况下,将第一存储键和第一存储值写入分布式数据库(业务数据写入tikv);在写入分布式数据库失败的情况下,向第一客户端传输待更新数据写入失败的响应信息;在写入分布式数据库成功的情况下,向第一客户端传输待更新数据写入成功的响应信息。同时,在缓存(Redis)中查找第一存储键对应的历史值,并删除历史值(删除key);在删除历史值失败的情况下,从分布式数据库中获取第一存储值,从缓存中获取第一存储键对应的第二存储值;在第一存储值与第二存储值不同(verify对比tikv和redis中key的值是否一致)的情况下,删除第二存储值(删除key)。在预设时间到达时,在分布式数据库中,获取目标列表中的目标存储键对应的目标存储值(perload定时进行数据同步,读取kitv,查询kitv数据);目标存储键包括第一存储键;将目标存储值同步至缓存中(写入数据到redis)。Exemplarily, as shown in Figure 4: in the case of using the proxy to receive the data to be updated transmitted by the first client (client), determine the timestamp of the received data to be updated, and the first storage key of the data to be updated and the first stored value, and write the timestamp and the first storage key into the target list (write the key and timestamp into do_key_list); in the case of failure to write the target list, transmit the data to be updated to the first client and write Enter the failed response information. In the case of successful writing to the target list, the first storage key and the first storage value are written to the distributed database (the business data is written to tikv); in the case of failure to write to the distributed database, the first storage key is transmitted to the first client. The response information of the failure to write the data to be updated; in the case of successful writing to the distributed database, the response information of the successful writing of the data to be updated is transmitted to the first client. At the same time, look up the historical value corresponding to the first storage key in the cache (Redis), and delete the historical value (delete the key); in the case of failure to delete the historical value, obtain the first storage value from the distributed database, from the cache Obtain the second storage value corresponding to the first storage key; if the first storage value is different from the second storage value (verify compares whether the values of the keys in tikv and redis are consistent), delete the second storage value (delete the key). When the preset time arrives, in the distributed database, the target storage value corresponding to the target storage key in the target list is obtained (perload periodically performs data synchronization, reads kitv, and queries kitv data); the target storage key includes the first storage key ; Synchronize the target stored value into the cache (write data to redis).

示例性的,如图5所示:在proxy接收到第二客户端(client)传输的数据获取指令的情况下,从缓存(Redis)中获取获取指令对应的待获取数据(发起数据读取);在未从缓存中获取到待获取数据(从Redis读取失败)的情况下,标记待获取数据的获取次数(记录keymiss);在获取次数大于或者等于获取次数阈值的情况下(perload触发同步),从分布式数据库中获取待获取数据(读取tikv的数据);将待获取数据同步至缓存中(写入redis)。获取分布式数据库中的从节点对应的第一读取延迟参数和从节点标识;根据第一读取延迟参数和从节点标识,从多个从节点中确定目标从节点;从目标从节点中读取待获取数据(从tikv只读节点获取数据)。在未能从目标从节点中获取待获取数据的情况下,获取第一从节点标识对应的第一从节点;第一从节点标识为从节点标识中的部分标识;从第一从节点中确定目标节点;并从目标节点中读取待获取数据(从tikv只读节点获取数据失败)。获取分布式数据库中的主节点对应的第二读取延迟参数;主节点的数量为多个;根据第二读取延迟参数从主节点中确定出目标主节点;并从目标主节点中读取待获取数据(从tikv主节点获取数据),在读取成功的情况下,向第二客户端发送读取的数据;在读取失败的情况下,向第二客户端读取失败的响应信息。Exemplarily, as shown in Figure 5: when the proxy receives the data acquisition instruction transmitted by the second client (client), it acquires the data to be acquired corresponding to the acquisition instruction from the cache (Redis) (initiating data reading) ; In the case that the data to be acquired is not obtained from the cache (failed to read from Redis), mark the number of acquisitions of the data to be acquired (record keymiss); when the number of acquisitions is greater than or equal to the threshold of the number of acquisitions (perload triggers synchronization ), obtain the data to be obtained from the distributed database (read the data of tikv); synchronize the data to be obtained into the cache (write to redis). Obtain the first read delay parameter and the slave node identifier corresponding to the slave node in the distributed database; determine the target slave node from the multiple slave nodes according to the first read delay parameter and the slave node identifier; read from the target slave node Get data to be acquired (get data from tikv read-only node). In the case that the data to be acquired cannot be acquired from the target slave node, acquire the first slave node corresponding to the first slave node identifier; the first slave node identifier is a partial identifier in the slave node identifier; determine from the first slave node The target node; and read the data to be obtained from the target node (failed to obtain data from the tikv read-only node). Obtain the second read delay parameter corresponding to the master node in the distributed database; the number of master nodes is multiple; determine the target master node from the master nodes according to the second read delay parameter; and read from the target master node The data to be acquired (obtain data from the tikv master node), in the case of successful reading, send the read data to the second client; in the case of failure to read, read the failed response information to the second client .

可以理解的是,数据存储装置在将待更新数据写入分布式数据库后,在利用待更新数据更新缓存中的数据之前,通过删除缓存中该第一存储键对应的历史值,使得在接收到数据获取指令的情况下,不会在缓存中读取到第一存储键对应的历史值,就可以再去分布式数据库中进行数据读取,从而得到第一存储值,即获取到准确的数据,从而提高了获取数据时的准确性。It can be understood that, after writing the data to be updated into the distributed database, the data storage device deletes the historical value corresponding to the first storage key in the cache before using the data to be updated to update the data in the cache, so that when the data is received In the case of the data acquisition instruction, the historical value corresponding to the first storage key will not be read in the cache, and the data can be read from the distributed database to obtain the first storage value, that is, to obtain accurate data. , thereby improving the accuracy of data acquisition.

实施例二Embodiment 2

基于实施例一同一发明构思,本申请实施例提供了一种数据存储装置1,对应于一种数据存储方法;图6为本申请实施例提供的一种数据存储装置的组成结构示意图一,该数据存储装置1可以包括:Based on the same inventive concept of the first embodiment, an embodiment of the present application provides a data storage device 1, which corresponds to a data storage method; FIG. 6 is a schematic structural diagram of a data storage device according to the first embodiment of the present application. The data storage device 1 may comprise:

确定单元11,用于在接收到第一客户端传输的待更新数据的情况下,确定所述待更新数据的第一存储键和第一存储值;a determining unit 11, configured to determine a first storage key and a first storage value of the to-be-updated data when receiving the to-be-updated data transmitted by the first client;

写入单元12,用于将所述第一存储键写入目标列表;将所述第一存储键和所述第一存储值写入分布式数据库;a writing unit 12, configured to write the first storage key into a target list; write the first storage key and the first storage value into a distributed database;

查找单元13,用于在缓存中查找所述第一存储键对应的历史值;Searching unit 13, for searching the historical value corresponding to the first storage key in the cache;

删除单元14,用于删除所述历史值;a deletion unit 14 for deleting the historical value;

获取单元15,用于在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值;所述目标存储键包括所述第一存储键;The obtaining unit 15 is configured to obtain, in the distributed database, the target storage value corresponding to the target storage key in the target list when the preset time arrives; the target storage key includes the first storage key;

同步单元16,用于将所述目标存储值同步至所述缓存中。The synchronization unit 16 is configured to synchronize the target stored value to the cache.

在本申请的一些实施例中,所述确定单元11,用于确定接收到所述待更新数据的时间戳;In some embodiments of the present application, the determining unit 11 is configured to determine the time stamp when the data to be updated is received;

相应的,所述写入单元12,用于将所述时间戳和所述第一存储键写入目标列表。Correspondingly, the writing unit 12 is configured to write the timestamp and the first storage key into the target list.

在本申请的一些实施例中,所述确定单元11,用于从所述目标列表中,确定上一次预设时间与所述预设时间段内写入的目标存储键;In some embodiments of the present application, the determining unit 11 is configured to, from the target list, determine the last preset time and the target storage key written in the preset time period;

所述获取单元15,用于在预设时间到达时,在所述分布式数据库中,获取所述目标存储键对应的目标存储值。The obtaining unit 15 is configured to obtain the target storage value corresponding to the target storage key in the distributed database when the preset time arrives.

在本申请的一些实施例中,所述装置还包括存储单元;In some embodiments of the present application, the apparatus further includes a storage unit;

所述存储单元,用于将所述第一存储键和所述第一存储值存储至所述分布式数据库中的主节点中;所述主节点用于读数据或者写数据;the storage unit, configured to store the first storage key and the first storage value in the master node in the distributed database; the master node is used for reading data or writing data;

所述同步单元16,用于在利用所述主节点对所述第一存储键和所述第一存储值存储成功的情况下,将所述主节点中的第一存储键和所述第一存储值同步至所述分布式数据库中的从节点中,以在从所述分布式数据库中获取所述存储数据的情况下,优先从所述从节点中获取所述第一存储值;所述从节点用于读数据;The synchronization unit 16 is configured to store the first storage key and the first storage value in the master node with the first storage key and the first storage key in the master node. The stored value is synchronized to the slave node in the distributed database, so that when the stored data is obtained from the distributed database, the first stored value is preferentially obtained from the slave node; the The slave node is used to read data;

所述确定单元11,用于在利用所述从节点对所述第一存储键和所述第一存储值存储成功的情况下,确定利用所述分布式数据库对所述待更新数据存储成功。The determining unit 11 is configured to determine that the data to be updated is successfully stored by using the distributed database when the first storage key and the first stored value are successfully stored by the slave node.

在本申请的一些实施例中,所述装置还包括对比单元和修改单元;In some embodiments of the present application, the device further includes a comparison unit and a modification unit;

所述对比单元,用于在校验时间到达时,利用校验组件将代理网关写入所述分布式数据库中的第一数据和利用所述代理网关同步至所述缓存中的第二数据进行对比;所述第一数据包括所述待更新数据;所述第二数据为所述缓存中的全部数据;所述第一数据与所述第二数据的数据键相同;The comparison unit is configured to use the verification component to write the first data in the distributed database by the proxy gateway and use the proxy gateway to synchronize the second data in the cache when the verification time arrives. Contrast; 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 modifying unit is configured to modify the second data by using the first data when it is determined that the first data is different from the second data.

在本申请的一些实施例中,所述第一数据和所述第二数据的数量为多个;所述装置还包括分组单元和加密单元;In some embodiments of the present application, the number of the first data and the second data is multiple; the apparatus further includes a grouping unit and an encryption unit;

所述获取单元15,用于获取多个第一数据对应的多个第一键和多个第一值,以及多个第二数据对应的多个第一键和多个第二值;所述多个第一键包括所述第一存储键;获取多组第一键对应的多组第一值和多组第二值;The acquiring unit 15 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 The multiple first keys include the first storage keys; obtain multiple sets of first values and multiple sets of second values corresponding to multiple sets of first keys;

所述分组单元,用于按照预设分组数对所述多个第一键进行分组,得到多组第一键;The grouping unit is configured 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 configured to perform encryption processing on each set of first values in the multiple sets of first values to obtain multiple first encrypted values; for each set of second values in the multiple sets of second values The value is encrypted to obtain a plurality of second encrypted values;

所述对比单元,用于对比所述多个第一加密值与所述多个第二加密值;the comparison unit, configured to compare the plurality of first encrypted values with the plurality of second encrypted values;

相应的,所述确定单元11,用于在所述多个第一加密值分别与所述多个第二加密值不同的情况下,确定所述第一数据与所述第二数据不同;Correspondingly, the determining unit 11 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 modifying unit is configured to modify the second data by using the first data.

在本申请的一些实施例中,所述获取单元15,用于在删除所述历史值失败的情况下,从所述分布式数据库中获取所述第一存储值,从所述缓存中获取所述第一存储键对应的第二存储值;In some embodiments of the present application, the obtaining unit 15 is configured to obtain the first stored value from the distributed database and obtain the first stored value from the cache in the case of failure to delete the historical value. the second storage value corresponding to the first storage key;

所述删除单元14,用于在所述第一存储值与所述第二存储值不同的情况下,删除所述第二存储值。The deleting unit 14 is configured to delete the second stored value when the first stored value is different from the second stored value.

在本申请的一些实施例中,所述获取单元15,用于在所述缓存中的缓存主节点切换的情况下,从所述分布式数据库中获取所述第一存储值,从所述缓存中获取所述第一存储键对应的第二存储值;In some embodiments of the present application, the obtaining unit 15 is configured to obtain the first stored value from the distributed database when the cache master node in the cache is switched, and obtain the first stored value from the cache Obtain the second storage value corresponding to the first storage key;

所述删除单元14,用于在所述第一存储值与所述第二存储值不同的情况下,删除所述第二存储值。The deleting unit 14 is configured to delete the second stored value when the first stored value is different from the second stored value.

在本申请的一些实施例中,所述获取单元15,用于在接收到热数据缓存指令的情况下,从所述缓存指令中获取所述热数据;In some embodiments of the present application, the obtaining unit 15 is configured to obtain the hot data from the cache instruction in the case of receiving the hot data cache instruction;

写入单元12,用于将所述热数据写入所述缓存中。The writing unit 12 is configured to write the hot data into the cache.

在本申请的一些实施例中,所述删除单元14,用于在确定出所述缓存中的缓存数据的访问热度小于或者等于访问热度阈值的情况下,删除所述缓存数据;所述缓存数据为第二数据中的部分数据;或者,在确定出所述缓存数据的最后一次访问时间与当前时刻的时间长度大于或者等于时间长度阈值的情况下,删除所述缓存数据。In some embodiments of the present application, the deletion unit 14 is configured to delete the cached data when it is determined that the access heat of the cached data in the cache is less than or equal to an access heat threshold; the cached data is part of the data in the second data; or, when it is determined that the time length between the last access time of the cached data and the current moment is greater than or equal to the time length threshold, delete the cached data.

在本申请的一些实施例中,所述装置还包括读取单元;In some embodiments of the present application, the apparatus further includes a reading unit;

所述获取单元15,用于在接收到第二客户端传输的数据获取指令的情况下,从所述缓存中获取所述获取指令对应的待获取数据;在未从所述缓存中获取到所述待获取数据的情况下,获取所述分布式数据库中的从节点对应的第一读取延迟参数和从节点标识;所述从节点的数量为多个;The obtaining unit 15 is configured to obtain the data to be obtained corresponding to the obtaining command from the cache in the case of receiving the data obtaining instruction transmitted by the second client; In the case of the data to be acquired, acquire the first read delay parameter and the identifier of the slave node corresponding to the slave node in the distributed database; the number of the slave nodes is multiple;

所述确定单元11,用于根据所述第一读取延迟参数和所述从节点标识,从多个从节点中确定目标从节点;The determining unit 11 is configured to determine a target slave node from a plurality of slave nodes according to the first read delay parameter and the slave node identifier;

所述读取单元,用于从所述目标从节点中读取所述待获取数据。The reading unit is configured to read the to-be-obtained data from the target slave node.

在本申请的一些实施例中,所述获取单元15,用于在未能从所述目标从节点中获取所述待获取数据的情况下,获取第一从节点标识对应的第一从节点;所述第一从节点标识为所述从节点标识中的部分标识;In some embodiments of the present application, the obtaining unit 15 is configured to obtain the first slave node corresponding to the first slave node identifier in the case that the to-be-obtained data cannot be obtained from the target slave node; The first slave node identifier is a partial identifier in the slave node identifier;

所述确定单元11,用于从所述第一从节点中确定目标节点;The determining unit 11 is configured to determine a target node from the first slave node;

所述读取单元,用于从所述目标节点中读取所述待获取数据。The reading unit is configured to read the to-be-obtained data from the target node.

在本申请的一些实施例中,所述获取单元15,用于获取所述分布式数据库中的主节点对应的第二读取延迟参数;所述主节点的数量为多个;In some embodiments of the present application, the obtaining unit 15 is configured to obtain the second read delay parameter corresponding to the master node in the distributed database; the number of the master node is multiple;

所述确定单元11,用于根据所述第二读取延迟参数从所述主节点中确定出目标主节点;The determining unit 11 is configured to determine a target master node from the master nodes according to the second read delay parameter;

所述读取单元,用于从所述目标主节点中读取所述待获取数据。The reading unit is configured to read the to-be-obtained data from the target master node.

在本申请的一些实施例中,所述装置还包括标记单元;In some embodiments of the present application, the device further comprises a marking unit;

所述标记单元,用于标记所述待获取数据的获取次数;the marking unit, configured to mark the acquisition times of the data to be acquired;

所述获取单元15,用于在所述获取次数大于或者等于获取次数阈值的情况下,从所述分布式数据库中获取所述待获取数据;The acquiring unit 15 is configured to acquire the data to be acquired from the distributed database when the number of acquisitions is greater than or equal to the threshold of the number of acquisitions;

所述同步单元16,用于将所述待获取数据同步至所述缓存中。The synchronization unit 16 is configured to synchronize the data to be acquired into the cache.

需要说明的是,在实际应用中,上述确定单元11、写入单元12、查找单元13、删除单元14、获取单元15和同步单元16可由数据存储装置1上的处理器17实现,具体为CPU(Central Processing Unit,中央处理器)、MPU(Microprocessor Unit,微处理器)、DSP(Digital Signal Processing,数字信号处理器)或现场可编程门阵列(FPGA,FieldProgrammable Gate Array)等实现;上述数据存储可由数据存储装置1上的存储器18实现。It should be noted that, in practical applications, the above determining unit 11, writing unit 12, searching unit 13, deleting unit 14, acquiring unit 15 and synchronizing unit 16 may be implemented by the processor 17 on the data storage device 1, specifically a CPU (Central Processing Unit, central processing unit), MPU (Microprocessor Unit, microprocessor), DSP (Digital Signal Processing, digital signal processor) or Field Programmable Gate Array (FPGA, Field Programmable Gate Array), etc.; the above data storage It may be implemented by the memory 18 on the data storage device 1 .

本申请实施例还提供了一种数据存储装置1,如图7所示,所述数据存储装置1包括:处理器17、存储器18和通信总线19,所述存储器18通过所述通信总线19与所述处理器17进行通信,所述存储器18存储所述处理器17可执行的程序,当所述程序被执行时,通过所述处理器17执行如上述所述的数据存储方法。An embodiment of the present application further provides a data storage device 1 , as shown in FIG. 7 , the data storage device 1 includes: a processor 17 , a memory 18 and a communication bus 19 , and the memory 18 communicates with the communication bus 19 through the communication bus 19 . The processor 17 communicates, and the memory 18 stores a program executable by the processor 17. When the program is executed, the processor 17 executes the data storage method described above.

在实际应用中,上述存储器18可以是易失性存储器(volatile memory),例如随机存取存储器(Random-Access Memory,RAM);或者非易失性存储器(non-volatile memory),例如只读存储器(Read-Only Memory,ROM),快闪存储器(flash memory),硬盘(Hard DiskDrive,HDD)或固态硬盘(Solid-State Drive,SSD);或者上述种类的存储器的组合,并向处理器17提供指令和数据。In practical applications, the above-mentioned memory 18 may be a volatile memory (volatile memory), such as a random-access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (Read-Only Memory, ROM), flash memory (flash memory), hard disk (Hard DiskDrive, HDD) or solid-state drive (Solid-State Drive, SSD); or a combination of the above types of memory, and provide the processor 17 instructions and data.

可以理解的是,数据存储装置在将待更新数据写入分布式数据库后,在利用待更新数据更新缓存中的数据之前,通过删除缓存中该第一存储键对应的历史值,使得在接收到数据获取指令的情况下,不会在缓存中读取到第一存储键对应的历史值,就可以再去分布式数据库中进行数据读取,从而得到第一存储值,即获取到准确的数据,从而提高了获取数据时的准确性。It can be understood that, after writing the data to be updated into the distributed database, the data storage device deletes the historical value corresponding to the first storage key in the cache before using the data to be updated to update the data in the cache, so that when the data is received In the case of the data acquisition instruction, the historical value corresponding to the first storage key will not be read in the cache, and the data can be read from the distributed database to obtain the first storage value, that is, to obtain accurate data. , thereby improving the accuracy of data acquisition.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the application may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including but not limited to disk storage, optical storage, and the like.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

以上所述,仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。The above descriptions are only preferred embodiments of the present application, and are not intended to limit the protection scope of the present application.

Claims (16)

1.一种数据存储方法,其特征在于,所述方法包括:1. a data storage method, is characterized in that, described method comprises: 在接收到第一客户端传输的待更新数据的情况下,确定所述待更新数据的第一存储键和第一存储值,并将所述第一存储键写入目标列表;In the case of 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; 将所述第一存储键和所述第一存储值写入分布式数据库;writing the first storage key and the first storage value into a distributed database; 在缓存中查找所述第一存储键对应的历史值,并删除所述历史值;Find the historical value corresponding to the first storage key in the cache, and delete the historical value; 在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值;所述目标存储键包括所述第一存储键;When the preset time arrives, in the distributed database, obtain the target storage value corresponding to the target storage key in the target list; the target storage key includes the first storage key; 将所述目标存储值同步至所述缓存中。Synchronizing the target stored value into the cache. 2.根据权利要求1所述的方法,其特征在于,所述确定所述待更新数据的第一存储键和第一存储值之前,所述方法还包括:2. The method according to claim 1, wherein, before the determining the first storage key and the first storage value of the data to be updated, the method further comprises: 确定接收到所述待更新数据的时间戳;determining the time stamp of receiving the data to be updated; 相应的,所述将所述第一存储键写入目标列表,包括:Correspondingly, the writing the first storage key into the target list includes: 将所述时间戳和所述第一存储键写入所述目标列表。Write the timestamp and the first storage key to the target list. 3.根据权利要求2所述的方法,其特征在于,所述在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值,包括:3. The method according to claim 2, wherein, when the preset time arrives, in the distributed database, acquiring the target storage value corresponding to the target storage key in the target list, comprising: 从所述目标列表中,确定上一次预设时间与所述预设时间段内写入的目标存储键;From the target list, determine the last preset time and the target storage key written in the preset time period; 在预设时间到达时,在所述分布式数据库中,获取所述目标存储键对应的目标存储值。When the preset time arrives, in the distributed database, the target storage value corresponding to the target storage key is acquired. 4.根据权利要求1所述的方法,其特征在于,所述将所述第一存储键和所述第一存储值写入分布式数据库,包括:4. The method according to claim 1, wherein the writing the first storage key and the first storage value into a distributed database comprises: 将所述第一存储键和所述第一存储值存储至所述分布式数据库中的主节点中;所述主节点用于读数据或者写数据;storing the first storage key and the first storage value in the master node in the distributed database; the master node is used to read data or write data; 在利用所述主节点对所述第一存储键和所述第一存储值存储成功的情况下,将所述主节点中的第一存储键和所述第一存储值同步至所述分布式数据库中的从节点中,以在从所述分布式数据库中获取存储数据的情况下,优先从所述从节点中获取所述第一存储值;所述从节点用于读数据;In the case that the first storage key and the first storage value are successfully stored by the master node, the first storage key and the first storage value in the master node are synchronized to the distributed In the slave node in the database, when the stored data is obtained from the distributed database, the first stored value is preferentially obtained from the slave node; the slave node is used for reading data; 在利用所述从节点对所述第一存储键和所述第一存储值存储成功的情况下,确定利用所述分布式数据库对所述待更新数据存储成功。In the case that the first storage key and the first stored value are successfully stored by the slave node, it is determined that the data to be updated is successfully stored by using the distributed database. 5.根据权利要求1所述的方法,其特征在于,所述将所述目标存储值同步至所述缓存中之后,所述方法还包括:5. The method according to claim 1, wherein after synchronizing the target storage value into the cache, the method further comprises: 在校验时间到达时,利用校验组件将代理网关写入所述分布式数据库中的第一数据和利用所述代理网关同步至所述缓存中的第二数据进行对比;所述第一数据包括所述待更新数据;所述第二数据为所述缓存中的全部数据;所述第一数据与所述第二数据的数据键相同;When the verification time arrives, use the verification component to compare the first data written by the proxy gateway in the distributed database with the second data synchronized to the cache by the proxy gateway; the first data Including 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 is different from the second data, the second data is modified using the first data. 6.根据权利要求5所述的方法,其特征在于,所述第一数据和所述第二数据的数量为多个;所述利用校验组件将代理网关写入所述分布式数据库中的第一数据和利用所述代理网关同步至所述缓存中的第二数据进行对比,包括:6. The method according to claim 5, wherein the number of the first data and the second data is multiple; the use of the verification component to write the proxy gateway into the distributed database The first data is compared with the second data synchronized to the cache by the proxy gateway, including: 获取多个第一数据对应的多个第一键和多个第一值,以及多个第二数据对应的多个第一键和多个第二值;所述多个第一键包括所述第一存储键;Obtain 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 the first storage key; 按照预设分组数对所述多个第一键进行分组,得到多组第一键;The multiple first keys are grouped according to the preset number of groups to obtain multiple groups of first keys; 获取多组第一键对应的多组第一值和多组第二值;Obtain multiple sets of first values and multiple sets of second values corresponding to multiple sets of first keys; 对所述多组第一值中的每一组第一值进行加密处理,得到多个第一加密值;对所述多组第二值中的每一组第二值进行加密处理,得到多个第二加密值;Perform encryption processing on each set of first values in the multiple sets of first values to obtain multiple first encrypted values; perform encryption processing on each set of second values in the multiple sets of second values to obtain multiple sets of second values. a second encrypted value; 对比所述多个第一加密值与所述多个第二加密值;comparing the plurality of first encrypted values to the plurality of second encrypted values; 相应的,所述在确定出所述第一数据与所述第二数据不同的情况下,利用所述第一数据修改所述第二数据,包括:Correspondingly, when it is determined that the first data is different from the second data, modifying the second data by using the first data includes: 在所述多个第一加密值分别与所述多个第二加密值不同的情况下,确定所述第一数据与所述第二数据不同;In the case where the plurality of first encrypted values are respectively different from the plurality of second encrypted values, determining that the first data is different from the second data; 利用所述第一数据修改所述第二数据。The second data is modified with the first data. 7.根据权利要求1所述的方法,其特征在于,所述在缓存中查找所述第一存储键对应的历史值,并删除所述历史值之后,所述方法还包括:7. The method according to claim 1, characterized in that, after searching the cache for the historical value corresponding to the first storage key and deleting the historical value, the method further comprises: 在删除所述历史值失败的情况下,从所述分布式数据库中获取所述第一存储值,从所述缓存中获取所述第一存储键对应的第二存储值;In the case of failure to delete the historical value, obtain the first stored value from the distributed database, and obtain the second stored value corresponding to the first storage key from the cache; 在所述第一存储值与所述第二存储值不同的情况下,删除所述第二存储值。If the first stored value is different from the second stored value, the second stored value is deleted. 8.根据权利要求1所述的方法,其特征在于,所述确定所述待更新数据的第一存储键和第一存储值之后,所述将所述目标存储值同步至所述缓存中之前,所述方法还包括:8 . The method according to claim 1 , wherein after the first storage key and the first storage value of the data to be updated are determined, and before the target storage value is synchronized to the cache. 9 . , the method also includes: 在所述缓存中的缓存主节点切换的情况下,从所述分布式数据库中获取所述第一存储值,从所述缓存中获取所述第一存储键对应的第二存储值;In the case of the cache master node switching in the cache, the first stored value is obtained from the distributed database, and the second stored value corresponding to the first storage key is obtained from the cache; 在所述第一存储值与所述第二存储值不同的情况下,删除所述第二存储值。If the first stored value is different from the second stored value, the second stored value is deleted. 9.根据权利要求1所述的方法,其特征在于,所述方法还包括:9. The method of claim 1, wherein the method further comprises: 在接收到热数据缓存指令的情况下,从所述缓存指令中获取所述热数据;In the case of receiving a hot data cache instruction, obtain the hot data from the cache instruction; 将所述热数据写入所述缓存中。Write the hot data into the cache. 10.根据权利要求1所述的方法,其特征在于,所述方法还包括:10. The method of claim 1, wherein the method further comprises: 在确定出所述缓存中的缓存数据的访问热度小于或者等于访问热度阈值的情况下,删除所述缓存数据;所述缓存数据为第二数据中的部分数据;If it is determined that the access heat of the cached data in the cache is less than or equal to the access heat threshold, delete the cached data; the cached data is part of the second data; 或者,在确定出所述缓存数据的最后一次访问时间与当前时刻的时间长度大于或者等于时间长度阈值的情况下,删除所述缓存数据。Alternatively, when it is determined that the time length between the last access time of the cached data and the current moment is greater than or equal to a time length threshold, the cached data is deleted. 11.根据权利要求1所述的方法,其特征在于,所述将所述目标存储值同步至所述缓存中之后,所述方法还包括:11. The method according to claim 1, wherein after synchronizing the target storage value into the cache, the method further comprises: 在接收到第二客户端传输的数据获取指令的情况下,从所述缓存中获取所述获取指令对应的待获取数据;In the case of receiving the data acquisition instruction transmitted by the second client, acquire the data to be acquired corresponding to the acquisition instruction from the cache; 在未从所述缓存中获取到所述待获取数据的情况下,获取所述分布式数据库中的从节点对应的第一读取延迟参数和从节点标识;所述从节点的数量为多个;In the case where the data to be acquired is not acquired from the cache, acquire the first read delay parameter and the identifier of the slave node corresponding to the slave node in the distributed database; the number of the slave nodes is multiple ; 根据所述第一读取延迟参数和所述从节点标识,从多个从节点中确定目标从节点;determining a target slave node from a plurality of slave nodes according to the first read delay parameter and the slave node identifier; 从所述目标从节点中读取所述待获取数据。The data to be acquired is read from the target slave node. 12.根据权利要求11所述的方法,其特征在于,所述从多个从节点中确定目标从节点之后,所述方法还包括:12. The method according to claim 11, wherein after the target slave node is determined from the plurality of slave nodes, the method further comprises: 在未能从所述目标从节点中获取所述待获取数据的情况下,获取第一从节点标识对应的第一从节点;所述第一从节点标识为所述从节点标识中的部分标识;In the case that the data to be acquired cannot be acquired from the target slave node, acquire the first slave node corresponding to the first slave node identifier; the first slave node identifier is a partial identifier in the slave node identifier ; 从所述第一从节点中确定目标节点;并从所述目标节点中读取所述待获取数据。Determine a target node from the first slave node; and read the data to be acquired from the target node. 13.根据权利要求12所述的方法,其特征在于,所述从所述第一从节点中确定目标节点之后,所述方法还包括:13. The method according to claim 12, wherein after the target node is determined from the first slave node, the method further comprises: 获取所述分布式数据库中的主节点对应的第二读取延迟参数;所述主节点的数量为多个;Acquire the second read delay parameter corresponding to the master node in the distributed database; the number of the master node is multiple; 根据所述第二读取延迟参数从所述主节点中确定出目标主节点;并从所述目标主节点中读取所述待获取数据。A target master node is determined from the master nodes according to the second read delay parameter; and the to-be-obtained data is read from the target master node. 14.根据权利要求11所述的方法,其特征在于,所述获取所述分布式数据库中的从节点对应的第一读取延迟参数和从节点标识之前,所述方法还包括:14. The method according to claim 11, wherein before acquiring the first read delay parameter and the identifier of the slave node corresponding to the slave node in the distributed database, the method further comprises: 标记所述待获取数据的获取次数;Mark the acquisition times of the data to be acquired; 在所述获取次数大于或者等于获取次数阈值的情况下,从所述分布式数据库中获取所述待获取数据;In the case that the number of acquisitions is greater than or equal to the threshold of the number of acquisitions, acquire the data to be acquired from the distributed database; 将所述待获取数据同步至所述缓存中。Synchronizing the to-be-obtained data into the cache. 15.一种数据存储装置,其特征在于,所述装置包括:15. A data storage device, wherein the device comprises: 确定单元,用于在接收到第一客户端传输的待更新数据的情况下,确定所述待更新数据的第一存储键和第一存储值;a determining unit, configured to determine a first storage key and a first storage value of the to-be-updated data when receiving the to-be-updated data transmitted by the first client; 写入单元,用于将所述第一存储键写入目标列表;将所述第一存储键和所述第一存储值写入分布式数据库;a writing unit, used for writing the first storage key into a target list; writing the first storage key and the first storage value into a distributed database; 查找单元,用于在缓存中查找所述第一存储键对应的历史值;a search unit, used to search the cache for the historical value corresponding to the first storage key; 删除单元,用于删除所述历史值;a deletion unit for deleting the historical value; 获取单元,用于在预设时间到达时,在所述分布式数据库中,获取所述目标列表中的目标存储键对应的目标存储值;所述目标存储键包括所述第一存储键;an obtaining unit, configured to obtain, in the distributed database, the target storage value corresponding to the target storage key in the target list when the preset time arrives; the target storage key includes the first storage key; 同步单元,用于将所述目标存储值同步至所述缓存中。A synchronization unit, configured to synchronize the target stored value to the cache. 16.一种数据存储装置,其特征在于,所述装置包括:16. A data storage device, characterized in that the device comprises: 存储器、处理器和通信总线,所述存储器通过所述通信总线与所述处理器进行通信,所述存储器存储所述处理器可执行的数据存储的程序,当所述数据存储的程序被执行时,通过所述处理器执行如权利要求1至14任一项所述的方法。A memory, a processor, and a communication bus through which the memory communicates with the processor, the memory storing a datastored program executable by the processor when the datastored program is executed , the method according to any one of claims 1 to 14 is performed by the processor.
CN202210677973.3A 2022-06-15 2022-06-15 Data storage method and device Pending CN115098519A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210677973.3A CN115098519A (en) 2022-06-15 2022-06-15 Data storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210677973.3A CN115098519A (en) 2022-06-15 2022-06-15 Data storage method and device

Publications (1)

Publication Number Publication Date
CN115098519A true CN115098519A (en) 2022-09-23

Family

ID=83291308

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210677973.3A Pending CN115098519A (en) 2022-06-15 2022-06-15 Data storage method and device

Country Status (1)

Country Link
CN (1) CN115098519A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116828053A (en) * 2023-08-28 2023-09-29 中信建投证券股份有限公司 Data caching method and device, electronic equipment and storage medium
CN117914867A (en) * 2024-03-19 2024-04-19 苏州元脑智能科技有限公司 Data buffering method, device, equipment and computer readable storage medium
CN118981506A (en) * 2024-10-21 2024-11-19 平凯星辰(北京)科技有限公司 Data storage method, reading method, device and electronic device
CN119784473A (en) * 2024-12-24 2025-04-08 中国工商银行股份有限公司 Data processing method, device, equipment, storage medium and product

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116828053A (en) * 2023-08-28 2023-09-29 中信建投证券股份有限公司 Data caching method and device, electronic equipment and storage medium
CN116828053B (en) * 2023-08-28 2023-11-03 中信建投证券股份有限公司 Data caching method and device, electronic equipment and storage medium
CN117914867A (en) * 2024-03-19 2024-04-19 苏州元脑智能科技有限公司 Data buffering method, device, equipment and computer readable storage medium
CN118981506A (en) * 2024-10-21 2024-11-19 平凯星辰(北京)科技有限公司 Data storage method, reading method, device and electronic device
CN119784473A (en) * 2024-12-24 2025-04-08 中国工商银行股份有限公司 Data processing method, device, equipment, storage medium and product

Similar Documents

Publication Publication Date Title
US11782649B2 (en) Restoring an archive authorized by an authenticated user
US11755415B2 (en) Variable data replication for storage implementing data backup
CN115098519A (en) Data storage method and device
US10437721B2 (en) Efficient garbage collection for a log-structured data store
US7363444B2 (en) Method for taking snapshots of data
US10534768B2 (en) Optimized log storage for asynchronous log updates
US9547706B2 (en) Using colocation hints to facilitate accessing a distributed data storage system
CN108255647B (en) High-speed data backup method under samba server cluster
JP6968876B2 (en) Expired backup processing method and backup server
US9690823B2 (en) Synchronizing copies of an extent in an append-only storage system
US11093387B1 (en) Garbage collection based on transmission object models
WO2021226905A1 (en) Data storage method and system, and storage medium
US9405643B2 (en) Multi-level lookup architecture to facilitate failure recovery
US9772783B2 (en) Constructing an index to facilitate accessing a closed extent in an append-only storage system
US8423517B2 (en) System and method for determining the age of objects in the presence of unreliable clocks
US20160092124A1 (en) Append-only storage system supporting open and closed extents
US12346294B2 (en) Time series data layered storage systems and methods
CN108021562B (en) Disk storage method and device applied to distributed file system and distributed file system
CN118550477B (en) Data deduplication methods, products, computer devices and storage media
CN113656363B (en) A data deduplication method, system, device and storage medium based on HDFS
US10073874B1 (en) Updating inverted indices
CN117131023B (en) Data table processing method, device, computer equipment and readable storage medium
CN113495807A (en) Data backup method, data recovery method and device
US11645333B1 (en) Garbage collection integrated with physical file verification
CN117632890A (en) Data processing method, device, storage node, system and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination