WO2022142616A1 - 基于redis的数据存储方法、装置、设备及存储介质 - Google Patents

基于redis的数据存储方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022142616A1
WO2022142616A1 PCT/CN2021/125268 CN2021125268W WO2022142616A1 WO 2022142616 A1 WO2022142616 A1 WO 2022142616A1 CN 2021125268 W CN2021125268 W CN 2021125268W WO 2022142616 A1 WO2022142616 A1 WO 2022142616A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
sub
index
parent
key
Prior art date
Application number
PCT/CN2021/125268
Other languages
English (en)
French (fr)
Inventor
曹春辉
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2022142616A1 publication Critical patent/WO2022142616A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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

Definitions

  • the present application relates to the field of data storage, and in particular, to a redis-based data storage method, apparatus, device, and storage medium.
  • Redis is a high-performance key-value storage system.
  • the client is linked to each node server (node) through the redis cluster (cluster).
  • Redis cluster adopts virtual slot partition: a redis cluster contains 16384 hash slots, each key in the database belongs to one of these 16384 hash slots, and the cluster calculates Determine which slot the key belongs to, each node is responsible for processing slots with different slot value ranges, and stores the value of the key to the corresponding node according to the matching of the slot value corresponding to the key and the slot value responsible for the node server server.
  • the data mapped to each slot is usually relatively uniform, so the keys can be evenly distributed to each node server, thereby realizing the distributed storage of data.
  • the inventor realized that when the data volume of the key is very large, the memory of the node server storing the key value will still be greatly consumed after the key of a single large data volume is allocated to the node server through the hash slot. The node server's memory can quickly run out and cause various problems.
  • the present application provides a data storage method, device, computer equipment and storage medium based on redis, which aims to solve the problem that when a large amount of data is stored on a server, it occupies too much memory and causes the server's memory to be quickly consumed. question.
  • the present application provides a redis-based data storage method, including:
  • the parent data is the data to be stored in the redis system, and the data volume of the parent data is greater than the preset capacity threshold;
  • the key of each sub-data is determined; the position information is used to indicate the position of each sub-data in the parent data, and the keys of the sub-data corresponding to different position information are different;
  • the plurality of sub-data are stored in the node server according to the key of each sub-data.
  • the present application provides a redis-based data storage device, including:
  • a data dividing unit used to divide parent data into multiple sub-data, where the parent data is the data to be stored in the redis system, and the data volume of the parent data is greater than a preset capacity threshold;
  • the key determination unit determines the key of each sub-data according to the position information of each sub-data; the position information is used to indicate the position of each sub-data in the parent data, and the keys of the sub-data corresponding to different position information are different;
  • an index recording unit configured to record at least index information of another sub-data in each sub-data based on a preset index rule, and the index information is used to obtain the parent data
  • the sub-data storage unit is configured to store the plurality of sub-data in the node server according to the key of each sub-data.
  • the present application provides a computer device, the computer device includes a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and execute the computer program.
  • the computer program described above realizes the above-mentioned redis-based data storage method.
  • the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein, if the computer program is executed by a processor, the above-mentioned redis-based data storage method.
  • the present application provides a redis-based data distribution storage method, device, device and storable medium.
  • dividing parent data with a large amount of data into multiple sub-data with a small amount of data, distributed and stored in the node server the data storage is realized.
  • Balanced storage to avoid the large amount of data being directly stored on one server, which will cause the server's memory to be quickly consumed; after splitting, sub-data can be obtained in parallel, and the sub-data obtained after splitting is small, reducing
  • the blocking time of the redis system is reduced, and the system performance is improved.
  • FIG. 1 is a schematic flowchart of a redis-based data storage method provided by an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a redis-based data storage method provided by another embodiment of the present application.
  • FIG. 3 is a schematic structural block diagram of a redis-based data storage device provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural block diagram of a redis-based data storage device provided by another embodiment of the present application.
  • FIG. 5 is a schematic structural block diagram of a computer device provided by an embodiment of the present application.
  • Embodiments of the present application provide a redis-based data storage method, apparatus, computer device, and computer-readable storage medium.
  • a redis cluster is built, and then the rule data is compiled and stored, but the data volume of these data is relatively large, and some data volumes are as high as hundreds of megabytes.
  • the data with a large amount of data in the above-mentioned compiled rule data can be divided into a plurality of sub-data with a small amount of data, which can be distributed and stored in the node server, so as to realize the balanced storage of data and avoid A large amount of data is directly stored on a server, resulting in a large amount of memory on the node server and avoiding subsequent problems.
  • This redis-based data storage method can be applied to the storage of all large amounts of data, and is not limited to the above-mentioned compiled rule data, such as image data, video data, text data and the like with large amounts of data.
  • the redis-based data storage method can be used for a server, and of course, a terminal, where the terminal can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server can be, for example, a separate server or a server cluster.
  • the terminal can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, etc.
  • the server can be, for example, a separate server or a server cluster.
  • the following embodiments will be described in detail with a redis-based data storage method applied to a server.
  • FIG. 1 is a schematic flowchart of steps of a redis-based data storage method provided by an embodiment of the present application, which specifically includes steps S110 to S140.
  • the dividing the parent data into a plurality of sub-data includes sub-steps S110a-S110c.
  • the child data can be divided as little as possible while ensuring that the data volume of the child data does not exceed the standard; In the case that the amount of data is too large, dividing the parent data in step S110c can ensure that the data amount of the divided sub-data is evenly distributed.
  • the capacity threshold is 100k
  • the number of node servers is 6
  • the data volume of the parent data is 550k
  • the product of the capacity threshold and the number of node servers is calculated to obtain a total threshold of 600k
  • the data volume of the parent data does not exceed all Therefore, the parent data is divided into multiple sub-data in units of the capacity threshold of 100K, namely, five sub-data of 100k data volume and one sub-data of 50k data volume are obtained.
  • the capacity threshold is 100k
  • the data volume of the parent data is 2000k
  • the data volume of the parent data exceeds the stated value. Therefore, the parent data is divided into 5 sub-data with equal capacity, that is, 5 sub-data with a capacity of 400k are obtained.
  • the location information may be obtained according to the location of each child data in the parent data when the parent data is divided into multiple child data in step S110. For example, if a parent data is abcde, which is divided into three sub-data of ab, cd, and e, the position information of the ab sub-data is at the starting position in the parent data and ranks first; the position information of the cd sub-data is the cd sub-data The position information of e is the second in the parent data, and the position information of the e child data is at the end of the parent data and ranks third.
  • the index rule includes: recording index information of all sub-data in each sub-data, and all sub-data can be acquired by acquiring index information in any sub-data.
  • the index rule includes: in each sub-data, the index information of all sub-data adjacent to its position information is recorded, the sub-data adjacent to its position can be obtained by acquiring one of the sub-data, and then the sub-data adjacent to its position can be obtained by obtaining one of the sub-data.
  • the index information of adjacent sub-data obtains more sub-data.
  • S140 Store the multiple sub-data in the node server according to the key of each sub-data.
  • the keys of the sub-data corresponding to different location information are different, and redis realizes distributed storage by calculating the slot according to the key, so the sub-data can be distributed and stored in the node server through different keys of the sub-data.
  • steps S130 and S140 are not fixed, and can be flexibly adjusted as required.
  • the index information is determined before the corresponding sub-data is stored, and the execution order of step S130 can be arranged before step S140; in another embodiment, the index information is in the corresponding sub-data. It is determined after being stored.
  • the index information includes the corresponding slot when the sub-data is stored, and the execution order of step S130 is arranged after step S140.
  • the position information of each sub-data it is determined that one of the plurality of sub-data is index sub-data, and the index sub-data at least records the index information of the remaining sub-data except the index sub-data.
  • the sub-data corresponding to the start position or the end position of the parent data is determined as the index sub-data.
  • the starting position or the ending position refers to the first or last position where the child data is stored in the parent data, and whether the child data is at the starting position or the ending position can be determined according to the position information of the child data.
  • step S120 specifically includes: determining the key of the parent data as the key of the index child data, adding the key of the parent data to the identifier of the location information corresponding to the child data other than the index child data. , to get the keys of sub-data other than the index sub-data.
  • the identifier of the location information may be the sequence number corresponding to the location of the sub-data other than the index sub-data in the parent data.
  • the key of the parent data is example, and there are 6 child data in total; the child data at the starting position of the parent data is determined as the index child data, and the key of the index child data is the key example of the parent data.
  • the keys of the 5 sub-data are obtained by adding the key of the parent data and the identification of the corresponding position information, and the identification of the position information is that the sub-data other than the index sub-data are listed in the order of their positions in the parent data.
  • Corresponding serial numbers 1-5 that is, the keys of the other five sub-data are example1, example2, example3, example4, example5 according to their positions in the parent data from front to back.
  • the total number of the multiple sub-data is increased in at least one sub-data. Specifically, the total number of the plurality of sub-data is recorded in the index sub-data.
  • the total number of the plurality of sub-data can also be increased in all sub-data; at the same time, each of the remaining sub-data outside the index sub-data refers to the index sub-data. , at least increase the index information of the rest of the sub-data except itself.
  • the key of the child data and the index information can also be stored in one area. in the nodes of the blockchain.
  • the blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the redis-based data storage method further includes steps S210-S230. Steps S210 to S230 are used to read the parent data stored in the redis-based data storage method described in steps S110 to S140.
  • Step S210 Acquire sub-data from the corresponding node server according to the key of the sub-data.
  • step S210 specifically includes: acquiring the index sub-data from the corresponding node server according to the key of the index sub-data. Since the key of the index child data is the same as the key of the parent data, the index child data can be obtained through the key of the parent data, and then other child data can be obtained, which greatly facilitates the use and management of the data.
  • Step S220 Acquire at least another sub-data from the corresponding node server according to the index information of the at least another sub-data.
  • step S220 specifically includes: obtaining from the corresponding node server at least the remaining sub-data except the index sub-data according to the index information of the index sub-data; more specifically, according to the index information of the index sub-data.
  • the slot in the index information at least the remaining sub-data except the index sub-data is acquired from the corresponding node server by connecting the corresponding node server in parallel.
  • the slot corresponds to the node server, therefore, the slot can be connected to the corresponding node server, and the data acquisition efficiency can be improved by connecting the node server in parallel.
  • Step S230 Determine whether to acquire all the sub-data of the parent data according to whether the acquired keys of each sub-data include the keys of all the sub-data of the parent data.
  • step S240 is performed; otherwise, step S210 or step 220 is performed to continue acquiring sub-data.
  • Step S240 When it is determined to acquire all sub-data of the parent data, the sub-data is spliced and processed according to the key of each sub-data to obtain the parent data.
  • the corresponding position information can be obtained according to the key of each sub-data, thereby obtaining the splicing sequence of each sub-data.
  • the redis-based data storage device includes: a data division unit 110 , a key determination unit 120 , an index recording unit 130 , and a sub-data storage unit 140 .
  • the data dividing unit 110 is used to divide the parent data into a plurality of sub-data, the parent data is the data to be stored in the redis system, and the data volume of the parent data is greater than the preset capacity threshold; divide the parent data into into multiple sub-data;
  • the key determination unit 120 is used to determine the key of each sub-data according to the position information of each sub-data; the position information is used to indicate the position of each sub-data in the parent data, and the keys of the sub-data corresponding to different position information are different;
  • an index recording unit 130 configured to record at least index information of another sub-data in each sub-data based on a preset index rule, and the index information is used to obtain the parent data;
  • the sub-data storage unit 140 is configured to store the plurality of sub-data in the node server according to the key of each sub-data.
  • the data division unit 110 includes a total threshold value calculation unit, a capacity threshold value division unit and an average division unit.
  • the total threshold calculation unit is configured to calculate the product of the capacity threshold and the number of node servers (nodes) to obtain the total threshold.
  • the capacity threshold dividing unit is configured to: if the data amount of the parent data does not exceed the total threshold, divide the parent data into a plurality of sub-data in units of the capacity threshold.
  • the average dividing unit is configured to: if the data volume of the parent data exceeds the total threshold, divide the parent data into a plurality of sub-data with equal data volume and size, and the number of the sub-data is equal to the number of nodes.
  • the number of servers is the same.
  • the redis-based data storage device further includes an index sub-data determination unit, and the index sub-data determination unit is used to determine, according to the position information of each sub-data, that one of the plurality of sub-data is the index sub-data, so The index sub-data at least records the index information of the remaining sub-data except the index sub-data; specifically, the sub-data corresponding to the start position or the end position of the parent data is determined as the index sub-data.
  • the key determination unit 120 includes an index key determination unit and a common key determination unit.
  • the index key determination unit is used to: determine the key of the parent data as the key of the index child data; the common key The key determining unit is configured to: add the key of the parent data to the identifier of the position information corresponding to the sub-data other than the index sub-data to obtain the key of the sub-data other than the index sub-data.
  • the redis-based data storage device further includes a sub-data reading unit 210 , an index reading unit 220 , an acquisition judging unit 230 , and a splicing unit 240 .
  • a sub-data reading unit 210 configured to obtain sub-data from the corresponding node server according to the key of the sub-data, and at least one of the sub-data records the index information of at least another sub-data;
  • an index reading unit 220 configured to acquire at least another sub-data from a corresponding node server according to the index information of the at least another sub-data
  • the acquisition judgment unit 230 judges whether to acquire all the child data of the parent data according to whether the keys of the obtained child data include the keys of all child data in the parent data;
  • the splicing unit 240 is configured to splicing and processing the child data according to the key of each child data to obtain the parent data when it is determined to acquire all the child data of the parent data.
  • the methods and apparatus of the present application may be used in numerous general purpose or special purpose computing system environments or configurations.
  • the above-mentioned method and apparatus can be implemented in the form of a computer program, and the computer program can be executed on a computer device as shown in FIG. 5 .
  • FIG. 5 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • the computer device can be a server or a terminal.
  • the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
  • the nonvolatile storage medium can store operating systems and computer programs.
  • the computer program includes program instructions that, when executed, can cause the processor to execute any redis-based data storage method.
  • the processor is used to provide computing and control capabilities to support the operation of the entire computer equipment.
  • the internal memory provides an environment for running the computer program in the non-volatile storage medium.
  • the processor can execute any redis-based data storage method.
  • the network interface is used for network communication, such as sending assigned tasks.
  • the structure of the computer device is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. More or fewer components are shown in the figures, either in combination or with different arrangements of components.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSP), application specific integrated circuits (Application Specific Integrated circuits) Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor can be a microprocessor or the processor can also be any conventional processor or the like.
  • the processor is used to run a computer program stored in the memory to realize the steps of: dividing the parent data into a plurality of child data, the parent data is the data to be stored in the redis system, and The data volume of the parent data is greater than the preset capacity threshold; the key of each child data is determined according to the location information of each child data, and the location information is used to indicate the location of each child data in the parent data, and different location information corresponds to The keys of the sub-data are different; based on the preset index rule, at least record the index information of another sub-data in each sub-data, and the index information is used to obtain the parent data; according to the key of the sub-data, from the corresponding node The server gets child data.
  • the processor is configured to run a computer program stored in a memory, so that the steps further include: storing the plurality of sub-data in the node server according to the key of each sub-data; according to the at least another For index information of a child data, obtain at least another child data from the corresponding node server; according to whether the key of the obtained child data includes the keys of all child data in the parent data, it is judged whether to obtain all child data of the parent data. ; When judging to obtain all sub-data of the parent data, the sub-data is spliced and processed according to the key of each sub-data to obtain the parent data.
  • the processor when configured to implement the redis-based data storage method, it is implemented that: the index information includes the slot corresponding to the sub-data storage.
  • the processor when used to implement the data storage method based on redis, it is implemented: according to the position information of each sub-data, it is determined that one of the multiple sub-data is index sub-data, and the index sub-data records at least the Index information of other sub-data except index sub-data. Specifically, the sub-data corresponding to the start position or the end position of the parent data is determined as the index sub-data.
  • the processor is configured to determine the key of each sub-data according to the position information of each sub-data, the position information is used to indicate the position of each sub-data in the parent data, and the keys of the sub-data corresponding to different position information are different.
  • the key of the parent data is determined as the key of the index child data
  • the key of the parent data is added to the identifier of the position information corresponding to the child data other than the index child data, and the index is obtained.
  • the identifier of the position information may be a sequence number corresponding to the sub-data other than the index sub-data sorted by their positions in the parent data from front to back.
  • the processor when configured to implement the redis-based data storage method, it is implemented: to facilitate the management and acquisition of data, the total number of the plurality of sub-data is increased in at least one sub-data. Specifically, the total number of the plurality of sub-data is recorded in the index sub-data. In order to further facilitate the management and unification of data, the total number of the plurality of sub-data can also be increased in all sub-data; at the same time, each of the remaining sub-data outside the index sub-data refers to the index sub-data. , at least increase the index information of the rest of the sub-data except itself.
  • the processor when the processor is configured to obtain sub-data from the corresponding node server according to the key of the sub-data, and when at least one of the sub-data records the index information of at least another sub-data, realize: according to the The key of the index sub-data obtains the index sub-data from the corresponding node server.
  • the processor when configured to obtain at least another sub-data from the corresponding node server according to the index information of the at least another sub-data, realize: according to the index information of the index sub-data, from the corresponding node
  • the server obtains at least the remaining sub-data except the index sub-data; more specifically, according to the slot in the index information of the index sub-data, the corresponding node server can be connected in parallel to obtain at least all the sub-data from the corresponding node server.
  • a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
  • the parent data is the data to be stored in the redis system, and the data volume of the parent data is greater than the preset capacity threshold;
  • the key of each sub-data is determined; the position information is used to indicate the position of each sub-data in the parent data, and the keys of the sub-data corresponding to different position information are different;
  • the plurality of sub-data are stored in the node server according to the key of each sub-data.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium may also be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or a memory of the computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) ) card, Flash Card, etc.

Abstract

本申请涉及区块链技术,提供了一种基于redis的数据存储方法、装置、设备及可存储介质,通过将大数据量的母数据分割成多个小数据量的子数据分布存储到节点服务器中,实现数据的平衡存储,避免大数据量的数据直接存储在一台服务器上而导致该服务器内存很快被消耗光;拆分后,可通过并行方式获取子数据,拆分后得到的子数据较小,降低了redis系统的阻塞时间,提高了系统性能。其中,子数据中记录的索引信息可存储于区块链中。

Description

基于redis的数据存储方法、装置、设备及存储介质
本申请要求于2020年12月28日提交中国专利局、申请号为202011584745.9、发明名称为“基于redis的数据存储方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据存储领域,尤其涉及一种基于redis的数据存储方法、装置、设备及存储介质。
背景技术
redis是一个高性能key-value存储系统,该系统中,客户端(client)通过redis集群(cluster)链接到每一个节点服务器(node)。Redis集群采用虚拟槽位(slot)分区:一个redis集群包含16384个哈希槽(hash slot),数据库中的每个键(key)都属于这16384个哈希槽的其中一个,集群通过计算来确定键属于哪个槽位(slot),各个节点分别负责处理不同槽值范围的槽,根据键对应的槽值与节点服务器所负责的槽值匹配将该键(key)的value存储至相应的节点服务器。由于采用高质量的哈希算法,每个槽所映射的数据通常比较均匀,因此可以把键均匀的分散到各个节点服务器上,从而实现数据的分布存储。但是,发明人意识到当出现键的数据量很大的情况时,单个大数据量的数据的键通过哈希槽分配到节点服务器后依然会导致存储此key值的节点服务器内存被大量消耗,该台节点服务器的内存会很快消耗光从而导致出现各种问题。
发明内容
本申请提供了一种基于redis的数据存储方法、装置、计算机设备及存储介质,旨在解决大数据量的数据存储在至服务器上时占用内存过大而导致该服务器内存很快被消耗光的问题。
第一方面,本申请提供了一种基于redis的数据存储方法,包括:
将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据, 且所述母数据的数据量大于预设的容量阈值;
根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
根据各个子数据的键将所述多个子数据存储到节点服务器中。
第二方面,本申请提供了一种基于redis的数据存储装置,包括:
数据分割单元,用于将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
键确定单元,根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
索引记录单元,用于基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
子数据存储单元,用于根据各个子数据的键将所述多个子数据存储到节点服务器中。
第三方面,本申请提供了一种计算机设备,所述计算机设备包括存储器和处理器;所述存储器,用于存储计算机程序;所述处理器,用于执行所述的计算机程序并在执行所述的计算机程序时实现如上所述的基于redis的数据存储方法。
第四方面,本申请提供了一种计算机可读存储介质,所述计算机的可读存储介质存储有计算机程序,其特征在于,若所述计算机程序被处理器执行,实现如上所述的基于redis的数据存储方法。
本申请提供了一种基于redis的数据分布存储方法、装置、设备及可存储介质,通过将大数据量的母数据分割成多个小数据量的子数据分布存储到节点服务器中,实现数据的平衡存储,避免大数据量的数据直接存储在一台服务器上而导致该服务器内存很快被消耗光;拆分后,可通过并行方式获取子数据,拆分后得到的子数据较小,降低了redis系统的阻塞时间,提高了系统性能。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要 使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例提供的一种基于redis的数据存储方法的示意流程图;
图2是本申请另一实施例提供的一种基于redis的数据存储方法的示意流程图;
图3是本申请一实施例提供的一种基于redis的数据存储装置的结构示意框图;
图4是本申请另一实施例提供的一种基于redis的数据存储装置的结构示意框图;
图5是本申请一实施例提供的一种计算机设备的结构示意框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。另外,虽然在装置示意图中进行了功能模块的划分,但是在某些情况下,可以以不同于装置示意图中的模块划分。
本申请的实施例提供了一种基于redis的数据存储方法、装置、计算机设备及计算机可读存储介质。例如,在实际应用中搭建了一个redis集群,然后对规则数据进行编译后存储,但是这些数据的数据量比较大,有的数据量高达数百兆。通过本申请提供的基于redis的数据存储方法,可将上述编译后的规则数据中数据量大的数据分割成多个小数据量的子数据分布存储到节点服务器中,实现数据的平衡存储,避免大数据量的数据直接存储在一台服务器上而导致该节点服务器内存被大量占用从而避免产生后续问题。该基于redis的数据 存储方法,可适用于所有大数据量的数据的存储,不限于上述所提到的编译后的规则数据,例如大数据量的图像数据、视频数据、文本数据等等。
其中,该基于redis的数据存储方法可以用于服务器,当然也可以用于终端,其中,终端可以是手机、平板电脑、笔记本电脑、台式电脑等电子设备;服务器例如可以为单独的服务器或服务器集群。但为了便于理解,以下实施例将以应用于服务器的基于redis的数据存储方法进行详细介绍。下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
请参阅图1,图1是本申请实施例提供的一种基于redis的数据存储方法的步骤示意流程图,具体包括步骤S110至步骤S140。
S110、将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值。
通过将大数据量的母数据分割成小数据量的子数据进行存储,可避免单个大数据量的数据全部存储在一台服务器上而导致该台服务器内存占用过大。
在一实施例中,所述将母数据分割成多个子数据包括子步骤S110a-S110c。
S110a、计算所述容量阈值与节点服务器(node)个数的乘积得到总阈值;
S110b、若所述母数据的数据量不超过所述总阈值,将所述母数据以所述容量阈值为单位分割成多个子数据;
S110c、若所述母数据的数据量超过所述总阈值,将母数据分割成数据量大小均等的多个子数据,所述子数据的个数与节点服务器的个数相同。
在子数据的数据量不太大的情况下,通过步骤S110b以所述容量阈值为单位分割母数据,可在保证子数据的数据量不超标的情况下尽量少的分割子数据;在子数据的数据量过大的情况下,通过步骤S110c分割母数据,可保证所分割的子数据的数据量分布均匀。
例如,一应用场景中,容量阈值为100k,节点服务器为6个,母数据的数据量为550k,计算容量阈值与节点服务器个数的乘积得到总阈值为600k,母数据的数据量不超过所述总阈值,因此,将母数据以容量阈值100K为单位分割成多个子数据,即得到五个100k数据量的子数据及一个50k数据量的子数据。另一应用场景中,容量阈值为100k,母数据的数据量为2000k,共有5个节点服务器,计算容量阈值与节点服务器个数的乘积得到总阈值为500k,母数据的数 据量超过了所述总阈值,因此,将母数据分割成容量大小均等的5个子数据,即得到5个容量大小为400k的子数据。
S120、根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同。
示例性的,所述位置信息可以在步骤S110中将母数据分割成多个子数据时,根据各个子数据在母数据中的位置得到。例如,一个母数据为abcde,分割成ab、cd、e三个子数据,则ab子数据的位置信息是在母数据中处于起始位置,排第一;cd子数据的位置信息是cd子数据的位置信息是在母数据中排第二,e子数据的位置信息是在母数据中处于末尾位置,排第三。
S130、基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据。
一实施例中,索引规则包括:在每个子数据中记录所有子数据的索引信息,可通过获取任意子数据中的索引信息来获取所有子数据。
另一实施例中,索引规则包括:在每个子数据中均记录与其位置信息相邻的所有子数据的索引信息,可通过获取其中一个子数据来获取与其位置相邻的子数据,再通过与其位置相邻的子数据的索引信息获取更多的子数据。
S140、根据各个子数据的键将所述多个子数据存储到节点服务器中。
由于不同位置信息对应的子数据的键不同,而redis是通过根据键计算槽位(slot)来实现分布存储,因此可通过子数据的不同键将子数据分布存储到节点服务器中。
步骤S130及步骤S140执行顺序的先后不是固定的,可以根据需要灵活调整。例如,一实施例中,所述索引信息在对应子数据被存储前就已确定,则步骤S130的执行顺序可以排在步骤S140的前面;另一实施利中,所述索引信息在对应子数据被存储后才确定,比如所述索引信息包括子数据存储时所对应的槽位,则步骤S130的执行顺序排在步骤S140的后面。
示例性的,根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息。具体的,将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据。起始位置或末尾位置指的是子数据在母数据中存储的位置为最前或最后,可以根据子数据的位置信息判断子数据是否处于起始位置或末尾位置。
示例性的,步骤S120具体包括:将所述母数据的键确定为所述索引子数据的键,将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。示例性的,所述位置信息的标识可以为所述索引子数据以外的子数据按在母数据中的位置所对应的序号。例如,母数据的键(key)为example,共有6个子数据;将母数据起始位置的子数据确定为索引子数据,索引子数据的键为母数据的键example,所述索引子数据以外的5个子数据的键由母数据的键加上对应的所述位置信息的标识得到,所述位置信息的标识为所述索引子数据以外的子数据按在母数据中的位置的前后依次所对应序号1-5,即另外5个子数据的键按照在母数据中的位置由前至后依次为example1、example2、example3、example4、example5。
示例性的,为方便数据的管理和获取,其中至少一个子数据中增加所述多个子数据的总个数。具体的,在所述索引子数据中记录所述多个子数据的总个数。为进一步方便数据的管理、统一,还可以在所有子数据中均增加所述多个子数据的总个数;同时,所述索引子数据外的其余子数据,每一个均参照所述索引子数据,至少增加自身外的其余子数据的索引信息。
需要强调的是,为进一步保证上述母数据的键、子数据的键以及所述索引信息的私密和安全性,上述母数据的键、子数据的键以及所述索引信息还可以存储于一区块链的节点中。
本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。
在一些实施方式中,如图2所示,所述基于redis的数据存储方法还包括步骤S210-步骤S230。步骤S210-步骤S230用于读取如步骤S110至步骤S140所述的基于redis的数据存储方法所存储的母数据。
步骤S210、根据所述子数据的键从对应的节点服务器获取子数据。
示例性的,步骤S210具体包括:根据所述索引子数据的键从对应节点服务器获取索引子数据。由于所述索引子数据的键与母数据的键相同,因此可以通过所述母数据的键获取所述索引子数据,进而获取其他子数据,这极大方便了 数据的使用和管理。
步骤S220、根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据。
示例性的,步骤S220具体包括:根据所述索引子数据的索引信息中,从对应的节点服务器至少获取所述索引子数据外的其余子数据;更具体的,可以根据所述索引子数据的索引信息中的所述槽位,通过并行连接对应的节点服务器从对应的节点服务器至少获取所述索引子数据外的其余子数据。由于在redis系统中,槽位是与节点服务器对应的,因此,通过所述槽位可连接到所述对应的节点服务器,通过并行连接的方式连接所述节点服务器可提高数据的获取效率。
步骤S230、根据获取的各个子数据的键是否包括所述母数据的所有子数据的键,判断是否获取所述母数据的所有子数据。
示例性的,若判断为获取了所述母数据的所有子数据则执行步骤S240,否则执行步骤S210或步骤220继续获取子数据。
步骤S240、在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
由于各个子数据的键是根据各个子数据的位置信息得到的,因此,可以根据各个子数据的键可获得对应的位置信息,从而得到各个子数据的拼接顺序。
如图3所示,该基于redis的数据存储装置,包括:数据分割单元110、键确定单元120、索引记录单元130、子数据存储单元140。
数据分割单元110,用于将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;将所述母数据分割成多个子数据;
键确定单元120,用于根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
索引记录单元130,用于基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
子数据存储单元140,用于根据各个子数据的键将所述多个子数据存储到节点服务器中。
示例性的,所述数据分割单元110包括总阈值计算单元、容量阈值分割单元及平均分割单元。
示例性的,所述总阈值计算单元,用于计算所述容量阈值与节点服务器(node)个数的乘积得到总阈值。
示例性的,所述容量阈值分割单元,用于:若所述母数据的数据量不超过所述总阈值,将所述母数据以所述容量阈值为单位分割成多个子数据。
示例性的,所述平均分割单元,用于:若所述母数据的数据量超过所述总阈值,将母数据分割成数据量大小均等的多个子数据,所述子数据的个数与节点服务器的个数相同。
示例性的,基于redis的数据存储装置还包括索引子数据确定单元,所述索引子数据确定单元用于根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息;具体的,将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据。
示例性的,所述键确定单元120包索引键确定单元及普通键确定单元.所述索引键确定单元用于:将所述母数据的键确定为所述索引子数据的键;所述普通键确定单元用于:将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。
在一些实施方式中,如图4所示,基于redis的数据存储装置还包括子数据读取单元210、索引读取单元220、获取判断单元230及拼接单元240。
子数据读取单元210,用于根据所述子数据的键从对应的节点服务器获取子数据,且所述子数据中至少有一个记录有至少另一子数据的索引信息;
索引读取单元220,用于根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据;
获取判断单元230,根据获取的子数据的键是否包括所述母数据中所有子数据的键,判断是否获取所述母数据的所有子数据;
拼接单元240,用于在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块、单元的具体工作过程,可以参考前述方法 实施例中的对应过程,在此不再赘述。
本申请的方法、装置可用于众多通用或专用的计算系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、多处理器系统、基于微处理器的系统、机顶盒、可编程的消费电子设备、网络PC、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。
示例性地,上述的方法、装置可以实现为一种计算机程序的形式,该计算机程序可以在如图5所示的计算机设备上运行。
请参阅图5,图5是本申请实施例提供的一种计算机设备的示意图。该计算机设备可以是服务器或终端。
如图5所示,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,其中,存储器可以包括非易失性存储介质和内存储器。
非易失性存储介质可存储操作系统和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种基于redis的数据存储方法。
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种基于redis的数据存储方法。
该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,该计算机设备的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
其中,在一些实施方式中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:将母数据分割成多个子数据,所述母数据是redis系 统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;根据各个子数据的位置信息,确定各个子数据的键,所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;根据所述子数据的键从对应的节点服务器获取子数据。
在一些实施方式中,所述处理器用于运行存储在存储器中的计算机程序,以实现的步骤还包括:根据各个子数据的键将所述多个子数据存储到节点服务器中;根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据;根据获取的子数据的键是否包括所述母数据中所有子数据的键,判断是否获取所述母数据的所有子数据;在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
示例性的,处理器用于实现所基于redis的数据存储方法时,实现:所述索引信息包括子数据存储时所对应的槽位。
示例性的,处理器用于实现所基于redis的数据存储方法时,实现:根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息。具体的,将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据。
示例性的,处理器用于实现根据各个子数据的位置信息,确定各个子数据的键,所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同时,实现:将所述母数据的键确定为所述索引子数据的键,将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。所述位置信息的标识可以为所述索引子数据以外的子数据按在母数据中的位置由前至后顺序排序所对应的序号。
示例性的,处理器用于实现基于redis的数据存储方法时,实现:为方便数据的管理和获取,其中至少一个子数据中增加所述多个子数据的总个数。具体的,在所述索引子数据中记录所述多个子数据的总个数。为进一步方便数据的管理、统一,还可以在所有子数据中均增加所述多个子数据的总个数;同时,所述索引子数据外的其余子数据,每一个均参照所述索引子数据,至少增加自身外的其余子数据的索引信息。
示例性的,处理器用于实现根据所述子数据的键从对应的节点服务器获取 子数据,且所述子数据中至少有一个记录有至少另一子数据的索引信息时,实现:根据所述索引子数据的键从对应节点服务器获取索引子数据。
示例性的,处理器用于实现根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据时,实现:根据所述索引子数据的索引信息中,从对应的节点服务器至少获取所述索引子数据外的其余子数据;更具体的,可以根据所述索引子数据的索引信息中的所述槽位,通过并行连接对应的节点服务器从对应的节点服务器至少获取所述索引子数据外的其余子数据。
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例或者实施例的某些部分所述的方法,如:
一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时,实现以下步骤:
将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
根据各个子数据的键将所述多个子数据存储到节点服务器中。
需要说明的是,所述领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的计算机可读存储介质的具体工作过程,可以参考前述基于redis的数据存储方法的各个实施例。
其中,所述计算机可读存储介质可以是非易失性,也可以是易失性。所述计算机可读存储介质还可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存 卡(Flash Card)等。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种基于redis的数据存储方法,其中,包括:
    将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
    根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
    基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
    根据各个子数据的键将所述多个子数据存储到节点服务器中。
  2. 根据权利要求1所述的基于redis的数据存储方法,其中,还包括:根据所述子数据的键从对应的节点服务器获取子数据;
    根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据;
    根据获取的子数据的键是否包括所述母数据中所有子数据的键,判断是否获取所述母数据的所有子数据;
    在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
  3. 根据权利要求1所述的基于redis的数据存储方法,其中,包括:
    所述将所述母数据分割成多个子数据,包括:
    计算所述容量阈值与节点服务器个数的乘积得到总阈值;
    若所述母数据的数据量不超过所述总阈值,将所述母数据以所述容量阈值为单位分割成多个子数据;
    若所述母数据的数据量超过所述总阈值,将母数据分割成数据量大小均等的多个子数据,所述子数据的个数与节点服务器的个数相同。
  4. 根据权利要求1-3中任一项所述的基于redis的数据存储方法,其中,所述方法还包括:
    根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息。
  5. 根据权利要求4所述的基于redis的数据存储方法,其中,所述根据各 个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,包括:
    将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据;
    所述根据各个子数据的位置信息,确定各个子数据的键,包括:
    将所述母数据的键确定为所述索引子数据的键;
    将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。
  6. 根据权利要求1-3中任一项所述的基于redis的数据存储方法,其中,所述方法还包括:
    在其中至少一个子数据中增加所述多个子数据的总个数。
  7. 根据权利要求4所述的基于redis的数据存储方法,其中,所述索引信息包括子数据存储时所对应的槽位;
    所述根据所述子数据的键从对应的节点服务器获取子数据,根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据,包括:根据所述索引子数据的键从对应节点服务器获取索引子数据;根据所述索引子数据的索引信息中的所述槽位,通过并行连接对应的节点服务器从对应的节点服务器至少获取所述索引子数据外的其余子数据。
  8. 一种基于redis的数据存储装置,其中,包括:
    数据分割单元,用于将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
    键确定单元,根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
    索引记录单元,用于基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
    子数据存储单元,用于根据各个子数据的键将所述多个子数据存储到节点服务器中。
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器;
    所述存储器,用于存储计算机程序;
    所述处理器,用于执行所述的计算机程序并在执行所述的计算机程序时实现如下步骤:
    将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
    根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
    基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
    根据各个子数据的键将所述多个子数据存储到节点服务器中。
  10. 根据权利要求9所述的计算机设备,其中,所述处理器还用于实现:
    根据所述子数据的键从对应的节点服务器获取子数据;
    根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据;
    根据获取的子数据的键是否包括所述母数据中所有子数据的键,判断是否获取所述母数据的所有子数据;
    在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
  11. 根据权利要求9所述的计算机设备,其中,所述处理器在实现将所述母数据分割成多个子数据时,用于实现:
    计算所述容量阈值与节点服务器个数的乘积得到总阈值;
    若所述母数据的数据量不超过所述总阈值,将所述母数据以所述容量阈值为单位分割成多个子数据;
    若所述母数据的数据量超过所述总阈值,将母数据分割成数据量大小均等的多个子数据,所述子数据的个数与节点服务器的个数相同。
  12. 根据权利要求9-11任一项所述的计算机设备,其中,所述处理器还用于实现:
    根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息。
  13. 根据权利要求12所述的计算机设备,其中,所述处理器在实现根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据时,用于实现:
    将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据;
    所述根据各个子数据的位置信息,确定各个子数据的键,包括:
    将所述母数据的键确定为所述索引子数据的键;
    将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。
  14. 根据权利要求9-11任一项所述的计算机设备,其中,所述处理器还用于实现:
    在其中至少一个子数据中增加所述多个子数据的总个数。
  15. 根据权利要求12所述的计算机设备,其中,所述索引信息包括子数据存储时所对应的槽位,所述处理器在实现根据所述子数据的键从对应的节点服务器获取子数据,根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据时,用于实现:
    根据所述索引子数据的键从对应节点服务器获取索引子数据;根据所述索引子数据的索引信息中的所述槽位,通过并行连接对应的节点服务器从对应的节点服务器至少获取所述索引子数据外的其余子数据。
  16. 一种计算机可读存储介质,所述计算机的可读存储介质存储有计算机程序,其中,若所述计算机程序被处理器执行,实现如下步骤:
    将母数据分割成多个子数据,所述母数据是redis系统中待存储的数据,且所述母数据的数据量大于预设的容量阈值;
    根据各个子数据的位置信息,确定各个子数据的键;所述位置信息用于指示各个子数据在母数据中的位置,不同位置信息对应的子数据的键不同;
    基于预设的索引规则,在每个子数据中至少记录另一子数据的索引信息,所述索引信息用于获取母数据;
    根据各个子数据的键将所述多个子数据存储到节点服务器中。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述处理器还用于实现:
    根据所述子数据的键从对应的节点服务器获取子数据;
    根据所述至少另一子数据的索引信息,从对应的节点服务器获取至少另一子数据;
    根据获取的子数据的键是否包括所述母数据中所有子数据的键,判断是否获取所述母数据的所有子数据;
    在判定获取所述母数据的所有子数据时,根据各个子数据的键将子数据拼接处理,得到所述母数据。
  18. 根据权利要求16所述的计算机可读存储介质,其中,所述处理器在实现将所述母数据分割成多个子数据时,用于实现:
    计算所述容量阈值与节点服务器个数的乘积得到总阈值;
    若所述母数据的数据量不超过所述总阈值,将所述母数据以所述容量阈值为单位分割成多个子数据;
    若所述母数据的数据量超过所述总阈值,将母数据分割成数据量大小均等的多个子数据,所述子数据的个数与节点服务器的个数相同。
  19. 根据权利要求16-18所述的计算机可读存储介质,其中,所述处理器还用于实现:
    根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据,所述索引子数据至少记录所述索引子数据外的其余子数据的索引信息。
  20. 根据权利要求19所述的计算机可读存储介质,其中,所述处理器在实现根据各个子数据的位置信息,确定所述多个子数据中的一个为索引子数据时,用于实现:
    将所述母数据起始位置或末尾位置对应的子数据确定为索引子数据;
    所述根据各个子数据的位置信息,确定各个子数据的键,包括:
    将所述母数据的键确定为所述索引子数据的键;
    将所述母数据的键加上所述索引子数据以外的子数据对应的位置信息的标识,得到所述索引子数据以外的子数据的键。
PCT/CN2021/125268 2020-12-28 2021-10-21 基于redis的数据存储方法、装置、设备及存储介质 WO2022142616A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011584745.9 2020-12-28
CN202011584745.9A CN112632077A (zh) 2020-12-28 2020-12-28 基于redis的数据存储方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2022142616A1 true WO2022142616A1 (zh) 2022-07-07

Family

ID=75285747

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/125268 WO2022142616A1 (zh) 2020-12-28 2021-10-21 基于redis的数据存储方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN112632077A (zh)
WO (1) WO2022142616A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112632077A (zh) * 2020-12-28 2021-04-09 深圳壹账通智能科技有限公司 基于redis的数据存储方法、装置、设备及存储介质
CN112988909B (zh) * 2021-05-07 2021-09-28 支付宝(杭州)信息技术有限公司 区块链数据存储方法及装置、电子设备
CN112988912B (zh) * 2021-05-07 2021-11-02 支付宝(杭州)信息技术有限公司 区块链数据存储方法及装置、电子设备
CN112988761B (zh) * 2021-05-07 2022-04-08 支付宝(杭州)信息技术有限公司 区块链数据存储方法及装置、电子设备
CN112988908B (zh) * 2021-05-07 2021-10-15 支付宝(杭州)信息技术有限公司 区块链数据存储方法及装置、电子设备
CN112988910B (zh) * 2021-05-07 2021-09-24 支付宝(杭州)信息技术有限公司 区块链数据存储方法及装置、电子设备
CN114877943B (zh) * 2022-05-19 2024-04-09 生态环境部华南环境科学研究所(生态环境部生态环境应急研究所) 一种基于区块链的生态环境监测装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682042A (zh) * 2015-11-11 2017-05-17 杭州海康威视数字技术股份有限公司 一种关系数据缓存及查询方法及装置
US20170212680A1 (en) * 2016-01-22 2017-07-27 Suraj Prabhakar WAGHULDE Adaptive prefix tree based order partitioned data storage system
CN109656474A (zh) * 2018-11-15 2019-04-19 金蝶软件(中国)有限公司 数据存储方法、装置、计算机设备和存储介质
CN110737658A (zh) * 2019-09-06 2020-01-31 平安国际智慧城市科技股份有限公司 数据分片存储方法、装置、终端及可读存储介质
CN112632077A (zh) * 2020-12-28 2021-04-09 深圳壹账通智能科技有限公司 基于redis的数据存储方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682042A (zh) * 2015-11-11 2017-05-17 杭州海康威视数字技术股份有限公司 一种关系数据缓存及查询方法及装置
US20170212680A1 (en) * 2016-01-22 2017-07-27 Suraj Prabhakar WAGHULDE Adaptive prefix tree based order partitioned data storage system
CN109656474A (zh) * 2018-11-15 2019-04-19 金蝶软件(中国)有限公司 数据存储方法、装置、计算机设备和存储介质
CN110737658A (zh) * 2019-09-06 2020-01-31 平安国际智慧城市科技股份有限公司 数据分片存储方法、装置、终端及可读存储介质
CN112632077A (zh) * 2020-12-28 2021-04-09 深圳壹账通智能科技有限公司 基于redis的数据存储方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN112632077A (zh) 2021-04-09

Similar Documents

Publication Publication Date Title
WO2022142616A1 (zh) 基于redis的数据存储方法、装置、设备及存储介质
US10296764B1 (en) Verifiable cryptographically secured ledgers for human resource systems
CN112153085B (zh) 一种数据处理方法、节点及区块链系统
US11657171B2 (en) Large network attached storage encryption
WO2020220536A1 (zh) 一种数据备份的方法、装置及计算机可读存储介质
US11797490B2 (en) Multi-cloud bi-directional storage replication system and techniques
US9372879B1 (en) Balanced append tree data structure
JP7358396B2 (ja) 安全なデータセット管理
CN103942292A (zh) 虚拟机镜像文件处理方法、装置及系统
US20130262370A1 (en) Fast Predicate Table Scans Using Single Instruction, Multiple Data Architecture
WO2017054540A1 (zh) 一种数据处理方法、装置、服务器及控制器
US20230030856A1 (en) Distributed table storage processing method, device and system
CN111611249A (zh) 数据管理方法、装置、设备及存储介质
EP4016276A1 (en) Data deduplication method and apparatus
US10824739B2 (en) Secure data aggregation in databases using static shifting and shifted bucketization
US10839087B2 (en) Secure data aggregation in databases using dynamic bucketization and grouping bucketization
CN111159100A (zh) 区块链文件存取方法、装置、计算机设备及存储介质
WO2021174882A1 (zh) 数据分片校验方法、装置、计算机设备及可读存储介质
US9578120B1 (en) Messaging with key-value persistence
Zheng et al. A method to improve the performance for storing massive small files in Hadoop
EP4321981A1 (en) Data processing method and apparatus
US10348705B1 (en) Autonomous communication protocol for large network attached storage
CN116192395A (zh) 用于分散式数据存储的可信系统
US11546171B2 (en) Systems and methods for synchronizing anonymized linked data across multiple queues for secure multiparty computation
CN110297842B (zh) 一种数据比对方法、装置、终端和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21913361

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 021023)

122 Ep: pct application non-entry in european phase

Ref document number: 21913361

Country of ref document: EP

Kind code of ref document: A1