Cache processing method, data addressing method, equipment and storage medium

By dividing the hash ring structure into multiple logical intervals and physical sub-intervals, the physical sub-intervals are directly accessed and processed to achieve scaling, the problem of classically consistent hashing is solved, and the scaling efficiency of caches is improved.

CN120179148APending Publication Date: 2025-06-20DAWNING INFORMATION IND (BEIJING) CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311757327.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-20
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

Classic consistent hashing is inefficient when scaling, requires additional node additions and access to the next available node when addressing.

Method used

By dividing the hash ring structure into multiple logical intervals, each logical interval is divided into multiple physical sub-intervals, and the corresponding physical sub-interval is directly accessed and processed during expansion and expansion.

Benefits of technology

It improves the cache expansion and scaling efficiency, reduces large-scale search and node addition and deletion operations in the hash ring structure, and realizes the scaling speed of 100 nanoseconds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179148A_ABST
    Figure CN120179148A_ABST
Patent Text Reader

Abstract

The invention relates to a cache processing method, a data addressing method, equipment and a storage medium. The method comprises the steps that a target logic interval in a cache is determined firstly, the cache comprises a plurality of logic intervals, the plurality of logic intervals form a hash ring structure, each logic interval comprises a plurality of physical sub-intervals, a target physical sub-interval in the target logic interval is determined, capacity expansion or capacity shrinkage is conducted on the target physical sub-interval, and the processed cache is obtained. Compared with a classical method that nodes need to be additionally increased or decreased during capacity expansion and contraction of consistent Hash, the method has the advantages that the corresponding physical subintervals are directly accessed during capacity expansion and contraction, then capacity expansion and contraction processing is carried out on the physical subintervals, the positions of the nodes needing to be added or deleted do not need to be searched for in a large range in a Hash ring structure, and the method is simple and convenient. And the capacity expansion and shrinkage efficiency of the cache is improved to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer storage technologies, and particularly to a method for processing a cache, a method for addressing data, a device, and a storage medium. Background Art

[0002] Consistent hashing refers to a data storage method in which storage nodes and data are both mapped to a hash ring that is connected end to end for storage. Since it can distribute data on different nodes according to hash values, ensuring the uniform distribution of data and improving the reliability and scalability of the system, it has been increasingly widely used in distributed storage systems.

[0003] However, with the development of NVMe solid-state drives (SSDs), the storage performance requirements for data in a cache system based on all-flash memory are getting higher and higher. Since classic consistent hashing requires additional nodes to be added or removed during scaling, and also needs to access the next available node during addressing.

[0004] Therefore, the classic consistent hashing structure has the problem of low efficiency during scaling. Summary of the Invention

[0005] Based on this, in view of the above technical problems, it is necessary to provide a method for processing a cache, a method for addressing data, a device, and a storage medium that can improve the efficiency of scaling.

[0006] In a first aspect, the present application provides a method for processing a cache, including:

[0007] Determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges;

[0008] Determine a target physical sub-range in the target logical range;

[0009] Expand or contract the target physical sub-range to obtain a processed cache.

[0010] In the above method, the hash ring structure is divided into multiple logical ranges, and each logical range is divided into multiple physical sub-ranges. When performing scaling processing on the cache, it is only necessary to first locate the logical range where the physical sub-range to be processed is located, then determine the physical sub-range from the logical range, and then perform scaling processing on the physical sub-range. Compared with the method of classic consistent hashing that requires additional nodes to be added or removed during scaling, the above method directly accesses the corresponding physical sub-range during scaling and then performs scaling processing on the physical sub-range, without the need to search for the positions of nodes to be added or deleted in a large range in the hash ring structure, which improves the efficiency of scaling the cache to a certain extent.

[0011] In one embodiment, the above-mentioned expansion of the target physical sub-interval to obtain the processed cache includes:

[0012] Splitting the target physical sub-interval according to the storage range of the target physical sub-interval to obtain an expanded sub-interval;

[0013] Increasing the space occupied by the expanded sub-interval between the target physical sub-interval and the adjacent physical sub-interval to obtain the processed cache.

[0014] In the embodiment of the present application, the method for expanding the target physical sub-interval is based on the expanded sub-interval obtained after splitting the target physical sub-interval to realize the expansion of the cache. The expansion method is simple and easy to implement, without complex expansion steps. Under the computing power of mainstream CPUs, the expansion of the cache can be at the nanosecond level, greatly improving the expansion efficiency of the cache.

[0015] In one embodiment, the above method further includes:

[0016] Determining whether the storage ranges of other physical sub-intervals in the target logical interval are the same;

[0017] If they are not the same, select one physical sub-interval from the other physical sub-intervals as the new target physical sub-interval, and return to execute the step of expanding the target physical sub-interval to obtain the processed cache.

[0018] In the embodiment of the present application, the method for selecting a new target physical sub-interval, when the storage ranges of the physical sub-intervals in the target logical interval are not the same, selects a new target physical sub-interval from the physical sub-intervals and expands the new target physical sub-interval. The selection method is simple and easy to implement, greatly improving the expansion efficiency of the cache.

[0019] In one embodiment, if they are the same, the above method further includes:

[0020] Stop expanding to obtain the processed cache;

[0021] Alternatively, according to the arrangement order of the other physical sub-intervals, expand each of the other physical sub-intervals in turn until there is no free space in the target logical interval, to obtain the processed cache.

[0022] In the embodiment of the present application, the method for expanding the other physical sub-intervals in turn, when the storage ranges of the physical sub-intervals in the target logical interval are the same, expands each physical sub-interval in turn until there is no free space in the target logical interval. The expansion method is simple and easy to implement, greatly improving the expansion efficiency of the cache.

[0023] In one embodiment, the reduction of the target physical sub-interval to obtain the processed cache includes:

[0024] According to the storage range of the target physical sub-interval, merge the target physical sub-interval with the candidate physical sub-interval to obtain a reduced-capacity sub-interval; the storage range of the candidate physical sub-interval is the same as that of the target physical sub-interval;

[0025] Release the space occupied by the reduced-capacity sub-interval to obtain the processed cache.

[0026] In the method for reducing the capacity of the target physical sub-interval provided in the embodiments of the present application, based on merging the target physical sub-interval and the candidate physical sub-interval to obtain a reduced-capacity sub-interval, the reduction of the cache is realized. The reduction method is simple and easy to implement, without complex reduction steps. Under the computing power of mainstream CPUs, the reduction of the cache can be at the nanosecond level, greatly improving the reduction efficiency of the cache.

[0027] In one embodiment, the above method further includes:

[0028] Determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent;

[0029] If not, select a physical sub-interval from other physical sub-intervals as the new target physical sub-interval, and return to execute the step of reducing the capacity of the target physical sub-interval to obtain the processed cache.

[0030] In the method for selecting a new target physical sub-interval provided in the embodiments of the present application, when the storage ranges of the physical sub-intervals in the target logical interval are inconsistent, a new target physical sub-interval is selected from the physical sub-intervals, and the new target physical sub-interval is reduced in capacity. The selection method is simple and easy to implement, greatly improving the reduction efficiency of the cache.

[0031] In one embodiment, if they are consistent, the above method further includes:

[0032] Stop reducing the capacity to obtain the processed cache;

[0033] Alternatively, according to the arrangement order of other physical sub-intervals, sequentially reduce the capacity of each other physical sub-interval until there is only one physical sub-interval left in the target logical interval, to obtain the processed cache.

[0034] In the method for sequentially reducing the capacity of other physical sub-intervals provided in the embodiments of the present application, when the storage ranges of the physical sub-intervals in the target logical interval are consistent, sequentially reduce the capacity of each physical sub-interval until there is only one physical sub-interval left in the target logical interval. The selection method is simple and easy to implement, greatly improving the reduction efficiency of the cache.

[0035] In a second aspect, the present application further provides a method for addressing data, which is applied to the hash ring structure as described in the above embodiments, and includes:

[0036] Determine a target logical interval where the data to be queried is located according to the storage range of the logical intervals in the hash ring structure and the address of the data to be queried;

[0037] Determine a physical sub-interval where the data to be queried is located according to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried.

[0038] The above method realizes the addressing of the data to be queried through calculation. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, saving the time of accessing node memory. Under the computing power of mainstream CPUs, the addressing effect is at the level of dozens of nanoseconds, greatly improving the data addressing efficiency.

[0039] In one embodiment, the above determining the target logical interval where the data to be queried is located according to the storage range of each logical interval in the hash ring structure and the address of the data to be queried includes:

[0040] Determine the ratio of the address of the data to be queried to the storage range of the logical interval as the first address;

[0041] Search for the logical interval corresponding to the first address in the cache and determine it as the target logical interval.

[0042] The method for determining the target logical interval provided by the embodiments of the present application performs numerical operations on the address of the data to be queried and the storage range of the logical interval, and the target logical interval where the data to be queried is located can be obtained, providing a basis for subsequently determining the physical sub-interval according to the target logical interval where the data to be queried is located.

[0043] In one embodiment, the above determining the physical sub-interval where the data to be queried is located according to the storage range of each logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried includes:

[0044] Determine a demarcation line and a first threshold according to the number of physical sub-intervals included in the target logical interval;

[0045] Determine the physical sub-interval where the data to be queried is located according to the position of the demarcation line, the first threshold, the storage range of the logical interval, and the address of the data to be queried.

[0046] The method for determining a physical sub - interval provided by the embodiment of the present application performs numerical operations on the position of the demarcation line, the first threshold, the storage range of the logical interval, and the address of the data to be queried, and then the physical sub - interval where the data to be queried is located can be obtained. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above - mentioned method does not need to traverse nodes or search for nearby nodes, saving the time of accessing node memory. Under the computing power of mainstream CPUs, the addressing effect is at the level of dozens of nanoseconds, greatly improving the data addressing efficiency.

[0047] In one embodiment, the above - mentioned determining the physical sub - interval where the data to be queried is located according to the position of the demarcation line, the first threshold, the storage range of the logical interval, and the address of the data to be queried includes:

[0048] Determine a first conditional value according to the position of the demarcation line, the first threshold, and the storage range of the logical interval;

[0049] Determine a second conditional value according to the storage range of the logical interval and the address of the data to be queried;

[0050] Determine the physical sub - interval where the data to be queried is located according to the first conditional value and the second conditional value.

[0051] The method for determining a physical sub - interval provided by the embodiment of the present application determines the physical sub - interval where the data to be queried is located based on the magnitude relationship between the position of the demarcation line, the first conditional value, and the second conditional value. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above - mentioned method does not need to traverse nodes or search for nearby nodes, and only simple numerical operations are required to determine the physical sub - interval of the data to be queried, which improves the data addressing efficiency to a certain extent.

[0052] In one embodiment, the above - mentioned determining the physical sub - interval where the data to be queried is located according to the first conditional value and the second conditional value includes:

[0053] When the first conditional value is greater than the second conditional value, use the first addressing method to determine the physical sub - interval where the data to be queried is located;

[0054] When the first conditional value is not greater than the second conditional value, use the second addressing method to determine the physical sub - interval where the data to be queried is located.

[0055] The method for determining a physical sub - space provided by the embodiment of the present application uses different addressing methods to determine the physical sub - interval where the data to be queried is located under different conditions, and can complete the addressing of the data to be queried in a refined manner on the premise of narrowing the query range, which improves the query accuracy to a certain extent.

[0056] In one embodiment, the above - mentioned using the first addressing method to determine the physical sub - interval where the data to be queried is located includes:

[0057] Determine the second address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, and the first threshold;

[0058] Search for the physical sub-interval corresponding to the second address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0059] The method for determining the physical sub-interval provided by the embodiment of the present application can obtain the position of the physical sub-interval where the data to be queried is located based on a calculation method. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, and only needs simple numerical operations to determine the physical sub-interval of the data to be queried, which improves the data addressing efficiency to a certain extent.

[0060] In one embodiment, the above method for determining the physical sub-interval where the data to be queried is located by using the second addressing method includes:

[0061] Determine the third address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, the first threshold, and the position of the demarcation line;

[0062] Search for the physical sub-interval corresponding to the third address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0063] The method for determining the physical sub-interval provided by the embodiment of the present application can obtain the position of the physical sub-interval where the data to be queried is located based on a calculation method. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, and only needs simple numerical operations to determine the physical sub-interval of the data to be queried, which improves the data addressing efficiency to a certain extent.

[0064] In one embodiment, the above method for determining the demarcation line according to the number of physical sub-intervals included in the target logical interval includes:

[0065] Determine the second threshold according to the number of physical sub-intervals;

[0066] Determine the demarcation line according to the second threshold and the number of physical sub-intervals.

[0067] The method for obtaining the demarcation line provided by the embodiment of the present application can obtain the position of the demarcation line based on a calculation method, providing a data basis for determining the physical sub-interval of the data to be queried according to the position of the demarcation line later.

[0068] In a third aspect, the present application further provides a cache processing device. The device includes:

[0069] The first determination module is configured to determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges;

[0070] The second determination module is configured to determine a target physical sub-range in the target logical area;

[0071] The processing module is configured to expand or contract the target physical sub-range to obtain a processed cache.

[0072] Fourthly, the present application further provides an addressing device for data, which is applied to the hash ring structure as described in the above embodiments, and includes:

[0073] The first determination module is configured to determine a target logical range where the data to be queried is located according to the storage range of the logical ranges in the hash ring structure and the address of the data to be queried;

[0074] The second determination module is configured to determine the physical sub-range where the data to be queried is located according to the storage range of the logical ranges, the number of physical sub-ranges included in the target logical range, and the address of the data to be queried.

[0075] Fifthly, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0076] Determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges;

[0077] Determine the target physical sub-range in the target logical range;

[0078] Expand or contract the target physical sub-range to obtain a processed cache.

[0079] Sixthly, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0080] Determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges;

[0081] Determine the target physical sub-range in the target logical range;

[0082] Expand or contract the target physical sub-range to obtain a processed cache.

[0083] In a seventh aspect, the present application also provides a computer program product, including a computer program which, when executed by a processor, implements the following steps:

[0084] Determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges;

[0085] Determine a target physical sub-range in the target logical range;

[0086] Expand or contract the target physical sub-range to obtain a processed cache.

[0087] In the above cache processing method, data addressing method, device, and storage medium, in the above method, the hash ring structure is divided into multiple logical ranges, and each logical range is divided into multiple physical sub-ranges. When expanding or contracting the cache, it is only necessary to first locate the logical range where the physical sub-range to be processed is located, then determine the physical sub-range from the logical range, and then perform the expansion or contraction processing on the physical sub-range. Compared with the classical consistent hashing method that requires additional addition or deletion of nodes during expansion or contraction, the above method directly accesses the corresponding physical sub-range during expansion or contraction and then performs the expansion or contraction processing on the physical sub-range, without the need to search for the positions of nodes to be added or deleted in a large range in the hash ring structure, which improves the cache expansion and contraction efficiency to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0089] Figure 1 It is the state value before consistent hashing expansion in an embodiment;

[0090] Figure 2 It is the state value after consistent hashing expansion in an embodiment;

[0091] Figure 3 It is an application environment diagram of the cache processing method in an embodiment;

[0092] Figure 4 It is an application environment diagram of the cache processing method in an embodiment;

[0093] Figure 5 It is a flowchart of the cache processing method in an embodiment;

[0094] Figure 6 Flow diagram of the cache processing method in another embodiment;

[0095] Figure 7 Expansion diagram in the target logic interval in another embodiment;

[0096] Figure 8 Flow diagram of the cache processing method in another embodiment;

[0097] Figure 9 Flow diagram of the cache processing method in another embodiment;

[0098] Figure 10 Flow diagram of the cache processing method in another embodiment;

[0099] Figure 11 Flow diagram of the cache processing method in another embodiment;

[0100] Figure 12 Flow diagram of the data addressing method in one embodiment;

[0101] Figure 13 Flow diagram of the data addressing method in another embodiment;

[0102] Figure 14 Flow diagram of the data addressing method in another embodiment;

[0103] Figure 15 Flow diagram of the data addressing method in another embodiment;

[0104] Figure 16 Flow diagram of the data addressing method in another embodiment;

[0105] Figure 17 Flow diagram of the data addressing method in another embodiment;

[0106] Figure 18 Flow diagram of the data addressing method in another embodiment;

[0107] Figure 19 Flow diagram of the data addressing method in another embodiment;

[0108] Figure 20 Flow diagram of the data addressing method in another embodiment;

[0109] Figure 21 Flow diagram of the cache processing method in one embodiment;

[0110] Figure 22Schematic flowchart of a data addressing method in an embodiment;

[0111] Figure 23 Block diagram of the structure of a cache processing device in an embodiment;

[0112] Figure 24 Block diagram of the structure of a data addressing device in an embodiment. Detailed implementation manners

[0113] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0114] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion.

[0115] In the description of the embodiments of this application, technical terms such as "first" and "second" are only used to distinguish different objects and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity, specific order or primary-secondary relationship of the indicated technical features. In the description of the embodiments of this application, "a plurality of" means more than two unless otherwise specifically defined.

[0116] Referring to "embodiment" herein means that a specific feature, structure or characteristic described in connection with the embodiment may be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0117] Consistent hashing refers to a data storage method in which storage nodes and data are both mapped to a hash ring that is connected end to end for storage. Since it can distribute data on different nodes according to the hash value, it ensures the uniform distribution of data and improves the reliability and scalability of the system. It has been increasingly widely used in distributed storage systems. Classical consistent hashing proposes the concept of virtual nodes, regards all virtual nodes as a ring, and introduces the concept of physical nodes, binding all virtual nodes to their corresponding physical nodes. When expanding or shrinking the capacity of consistent hashing, only the virtual nodes of its adjacent physical nodes need to be modified to bind them to the new physical nodes. For exampleFigure 1 As shown, the hash structure before consistent hashing expansion is given. In the figure, A, B, and C respectively represent three different nodes, and key represents the data to be processed that needs to be inserted. As Figure 2 shown, the hash structure after consistent hashing expansion is given. In the figure, A, B, C, and D respectively represent four different nodes, D is the newly added node, and key represents the data to be processed that needs to be inserted.

[0118] However, with the development of NVMe solid-state drives (SSDs), the storage performance requirements for data of the all-flash-based cache system are getting higher and higher. Since the classic consistent hashing needs to add or subtract nodes additionally during scaling, and also needs to access the next available node during addressing. This results in the problem of low efficiency in the classic consistent hashing structure during scaling. This application aims to solve this problem.

[0119] After introducing the background technology of the cache processing method provided by the embodiments of this application above, below, the implementation environment involved in the cache processing method provided by the embodiments of this application will be briefly described. The cache processing method provided by the embodiments of this application can be applied to a Figure 3 hash ring structure as shown. The hash ring structure is applied to the storage subsystem of the cache. The hash ring structure uses fixed-length memory as the carrier for hashing (such as 8kb), and these fixed-length memories are called physical sub-intervals (that is, Figure 1 the physical hash intervals in Figure 1 ). As shown in Figure 1 , the hash ring structure is composed of indexes serialized by a processable key (key) in a certain arrangement order. For example, arranged in ascending order of index in the clockwise direction (that is, Figure 1 the insertion and elimination order in

[0120] Since the cache stores data in a hash ring structure in this solution, when it is necessary to expand or contract the cache according to the requirements of the Central Processing Unit (CPU), it is only necessary to expand or contract the physical sub-intervals in the hash ring structure. Which physical sub-interval to process and how to expand and contract the physical sub-intervals require the participation of a computer device. The cache processing method provided in the embodiments of the present application is applied to a computer device such as Figure 4 shown. The computer device includes a processor, a memory, an Input / Output (I / O) interface, and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cache data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a cache processing method.

[0121] Those skilled in the art can understand that Figure 4 the structure shown in is only a block diagram of some structures 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. A specific computer device may include more or fewer components than Figure 4 shown, or combine some components, or have a different component layout.

[0122] After introducing the application scenario of the cache processing method provided in the embodiments of the present application above, the cache processing method described in the present application will be introduced in detail below.

[0123] In one embodiment, as Figure 5 shown, a cache processing method is provided. Taking the method applied to the computer device in Figure 4 as an example, it includes the following steps:

[0124] S201. Determine the target logical interval in the cache.

[0125] Among them, the cache is a buffer for data exchange. In the embodiments of the present application, the storage system uses a hash ring structure as the data structure of the cache subsystem. That is to say, the data structure of the cache includes multiple hash ring structures. The hash ring structure provided by the present application is as above Figure 1 As shown, a hash ring structure includes multiple logical intervals, and each logical interval includes multiple physical sub-intervals.

[0126] Among them, the size of the index range after serialization of the key responsible for each logical interval is the same. For example, the index range of the first logical interval is 500 - 599, the index range of the second logical interval is 600 - 699, and the index range of the third logical interval is 200 - 299, etc. When a physical sub-interval is expanded, only the index range of the logical interval where the physical sub-interval is located is evenly divided.

[0127] In the embodiments of the present application, when it is necessary to perform scaling processing on the data structure in the cache, the data structure used in the cache subsystem (i.e., the hash ring structure) can be processed, that is, the number of physical sub-intervals in the hash ring structure is expanded and contracted. Since the physical sub-intervals are located in different logical intervals, it is first necessary to determine the target logical interval where the physical sub-interval is located. Optionally, the method for determining the target logical interval in the cache can be: based on a preset addressing method, determine the next target logical interval to be processed. For example, when it is necessary to scale down the cache, based on the preset addressing method, the next target logical interval (curHead) to be scaled down is obtained; when it is necessary to scale up the cache, based on the preset addressing method, the next target logical interval (curRear) to be scaled up is obtained.

[0128] S202. Determine the target physical sub-interval in the target logical interval.

[0129] In the embodiments of the present application, after determining the target logical range in the cache, one or more target physical sub-ranges can be further selected from the target logical range. Optionally, when the cache needs to be expanded, the physical sub-range with the largest index range can be selected from the target logical range as the target physical sub-range; optionally, when the cache needs to be expanded, if the index ranges of all physical sub-ranges in the target logical range are equal, then the first physical sub-range in the target logical range can be used as the target physical sub-range; optionally, when the cache needs to be shrunk, the physical sub-range with the smallest index range can be selected from the target logical range as the target physical sub-range; optionally, when the cache needs to be shrunk, if the index ranges of all physical sub-ranges in the target logical range are equal, then the last physical sub-range in the target logical range can be used as the target physical sub-range.

[0130] S203. Expand or shrink the target physical sub-range to obtain the processed cache.

[0131] Among them, expansion means splitting the target physical sub-range, that is, the target physical sub-range can be split into at least two sub-ranges with the same or different range sizes; shrinking means merging the target physical sub-range with a physical sub-range adjacent to the target physical sub-range, that is, merging the index range of the target physical sub-range with the index range of the previous target physical sub-range.

[0132] In the embodiments of the present application, after determining the target physical sub-range, the target physical sub-range can be expanded or shrunk according to actual needs to obtain the processed cache. Optionally, when the cache needs to be expanded, the target physical sub-range can be expanded to obtain the cache after the expansion process; optionally, when the cache needs to be shrunk, the target physical sub-range can be shrunk to obtain the cache after the shrinking process.

[0133] The cache processing method provided by the embodiment of the present application first determines the target logical range in the cache. The cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure. Each logical range includes multiple physical sub-ranges. Then, it determines the target physical sub-range in the target logical range, and expands or shrinks the target physical sub-range to obtain the processed cache. In the above method, the hash ring structure is divided into multiple logical ranges, and each logical range is divided into multiple physical sub-ranges. When expanding or shrinking the cache, it only needs to first locate the logical range where the physical sub-range to be processed is located, then determine the physical sub-range from the logical range, and then perform the expansion or shrinkage processing on the physical sub-range. Compared with the method of the classic consistent hashing that needs to additionally add or delete nodes during expansion or shrinkage, the above method directly accesses the corresponding physical sub-range during expansion or shrinkage, and then performs the expansion or shrinkage processing on the physical sub-range, without the need to search for the positions of the nodes to be added or deleted in a large range in the hash ring structure, which improves the expansion and shrinkage efficiency of the cache to a certain extent.

[0134] In one embodiment, based on the Figure 5 embodiment shown, the process of expanding the target physical sub-range can be described. As Figure 6 shown, the above S203 "Expand the target physical sub-range to obtain the processed cache" includes:

[0135] S301. Split the target physical sub-range according to the storage range of the target physical sub-range to obtain an expanded sub-range.

[0136] Among them, the storage range can be an index range, and the target physical sub-range can be the physical sub-range with the largest storage range in the target logical range. As Figure 7 shown, the first row - the second row in the figure shows the method of splitting the physical sub-range with the largest storage range in the target logical range, that is, splitting the index range index = [20, 39] into the index range index = [20, 29] and the index range index = [30, 39].

[0137] In the embodiment of the present application, after the target physical sub-interval is determined as above, according to the storage range of the target physical sub-interval, the target physical sub-interval can be split into two adjacent physical sub-intervals, and one of the physical sub-intervals is determined as the expansion sub-interval. For example, if the storage range of the target physical sub-interval is index = [20, 39], then splitting the target physical sub-interval results in two adjacent physical sub-intervals index = [20, 29] and index = [30, 39], and either the physical sub-interval index = [20, 29] or the physical sub-interval index = [30, 39] is determined as the expansion sub-interval. Another example, if the storage range of the target physical sub-interval is index = [20, 39], then splitting the target physical sub-interval results in two adjacent physical sub-intervals index = [20, 25] and index = [26, 39], and either the physical sub-interval index = [20, 25] or the physical sub-interval index = [26, 39] is determined as the expansion sub-interval.

[0138] S302. Add the space occupied by the expansion sub-interval between the target physical sub-interval and the adjacent physical sub-interval to obtain the processed cache.

[0139] Here, the adjacent physical sub-interval refers to the physical sub-interval adjacent to the target physical sub-interval.

[0140] In the embodiment of the present application, after the target physical sub-interval and the expansion sub-interval are determined as above, the space occupied by the expansion sub-interval can be added between the target physical sub-interval and the adjacent physical sub-interval, and the expansion sub-interval is placed between the target physical sub-interval and the adjacent physical sub-interval. At the same time, the number of physical sub-intervals in the target logical interval is increased by 1, thereby obtaining the processed cache.

[0141] Optionally, the space occupied by the expansion sub-interval can be added between the target physical sub-interval and the left adjacent physical sub-interval, and the expansion sub-interval is placed between the target physical sub-interval and the left adjacent physical sub-interval. At the same time, the number of physical sub-intervals in the target logical interval is increased by 1, thereby obtaining the processed cache. Optionally, the space occupied by the expansion sub-interval can be added between the target physical sub-interval and the right adjacent physical sub-interval, and the expansion sub-interval is placed between the target physical sub-interval and the right adjacent physical sub-interval. At the same time, the number of physical sub-intervals in the target logical interval is increased by 1, thereby obtaining the processed cache.

[0142] The method for expanding the target physical sub-interval provided in the embodiment of the present application realizes the expansion of the cache based on the expansion sub-interval obtained after splitting the target physical sub-interval. The expansion method is simple and easy to implement, without complex expansion steps. Under the computing power of mainstream CPUs, the expansion of the cache can be at the nanosecond level, greatly improving the expansion efficiency of the cache.

[0143] In one embodiment, based on the embodiment shown in Figure 6 , as shown in Figure 8 , the above method further includes:

[0144] S303. Determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent.

[0145] Among them, the other physical sub-intervals can be each physical sub-interval in the target logical interval after the expansion in step S302 above.

[0146] In the embodiment of the present application, after splitting the target physical sub-interval to obtain the processed target logical interval, it is possible to continue to determine whether the storage ranges of each physical sub-interval in the target logical interval are consistent.

[0147] S304. If they are inconsistent, select a physical sub-interval from the other physical sub-intervals as the new target physical sub-interval, and expand the new target physical sub-interval to obtain the processed cache.

[0148] In the embodiment of the present application, if the storage ranges of each physical sub-interval in the target logical interval are not completely consistent, determine a physical sub-interval with the largest storage range from each physical sub-interval as the new target physical sub-interval, and according to the storage range of the new target physical sub-interval, split the new target physical sub-interval into two sub-intervals, and determine one of the sub-intervals as the expansion sub-interval, and increase the space occupied by the expansion sub-interval between the new target physical sub-interval and the physical sub-interval adjacent to the new physical sub-interval, and place the expansion sub-interval at the increased space occupied by the expansion sub-interval, and increase the number of physical sub-intervals in the target logical interval by 1 to obtain the processed cache; then further determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent, and in the case where the storage ranges of other physical sub-intervals in the target logical interval are not completely consistent, again determine a physical sub-interval with the largest storage range from each physical sub-interval as the new target physical sub-interval, and according to the storage range of the new target physical sub-interval, split the new target physical sub-interval into two sub-intervals, and determine one of the sub-intervals as the expansion sub-interval, and increase the space occupied by the expansion sub-interval between the new target physical sub-interval and the physical sub-interval adjacent to the new physical sub-interval, and place the expansion sub-interval at the increased space occupied by the expansion sub-interval, and increase the number of physical sub-intervals in the target logical interval by 1 to obtain the processed cache,......, until the storage ranges of all physical sub-intervals in the target logical interval are consistent, or until there is no free interval in the target logical interval, to obtain the processed cache. As shown in Figure 7As shown, the second to third rows in the figure give a method for splitting physical sub-intervals with consistent storage ranges in the target logical interval, that is, splitting the physical sub-interval index range index = [0, 9] of the first bit in each physical sub-interval into an index range index = [0, 4] and an index range index = [5, 9]; and splitting the physical sub-interval index range index = [10, 19] of the second bit in each physical sub-interval into an index range index = [10, 14] and an index range index = [15, 19].

[0149] In the embodiment of the present application, the method for selecting a new target physical sub-interval, when the storage ranges of the physical sub-intervals in the target logical interval are inconsistent, selects a new target physical sub-interval from each physical sub-interval and expands the new target physical sub-interval. The selection method is simple and easy to implement, greatly improving the expansion efficiency of the cache.

[0150] In one embodiment, on the basis of the Figure 8 embodiment shown, if the storage ranges of other physical sub-intervals in the target logical interval are consistent, as Figure 9 shown, the above method further includes:

[0151] S305. Stop expanding to obtain the processed cache.

[0152] In the embodiment of the present application, when the storage ranges of the physical sub-intervals in the target logical interval are all consistent, stop expanding to obtain a processed cache in which the storage ranges of the physical sub-intervals in the target logical interval are all consistent.

[0153] S305. Or, according to the arrangement order of the other physical sub-intervals, expand each of the other physical sub-intervals in turn until there is no free space in the target logical interval, and obtain the processed cache.

[0154] In the embodiment of the present application, there is also provided an expansion method when the storage ranges of the physical sub-intervals in the target logical interval are all consistent. According to the arrangement order of the other physical sub-intervals in the target logical interval, expand each physical sub-interval in turn according to the above expansion method until there is no free interval in the target logical interval, or until all the physical sub-intervals in the target logical interval are split, and obtain the processed cache.

[0155] In the embodiment of the present application, for the method of sequentially expanding other physical sub-intervals, when the storage ranges of all physical sub-intervals in the target logical interval are the same, each physical sub-interval is sequentially expanded until there is no free space in the target logical interval. The expansion method is simple and easy to implement, greatly improving the expansion efficiency of the cache.

[0156] In one embodiment, based on the embodiment shown in Figure 5 , the process of shrinking the target physical sub-interval can be described. As Figure 10 shown, the above S203 "shrink the target physical sub-interval to obtain the processed cache" includes:

[0157] S401. According to the storage range of the target physical sub-interval, merge the target physical sub-interval with the candidate physical sub-interval to obtain a shrunk sub-interval.

[0158] Wherein, the candidate physical sub-interval refers to a physical sub-interval adjacent to the target physical sub-interval, and the storage range of the candidate physical sub-interval is the same as that of the target physical sub-interval. The target physical sub-interval is the physical sub-interval with the smallest storage range among the physical sub-intervals in the target logical interval, or when there are multiple physical sub-intervals with the smallest storage range in the target logical interval, the target physical sub-interval is any one of the multiple physical sub-intervals with the smallest storage range.

[0159] In the embodiment of the present application, after the target physical sub-interval is determined, two physical sub-intervals adjacent to the target physical sub-interval can be obtained, and a physical sub-interval with the same storage range as the target physical sub-interval is determined from the two adjacent physical sub-intervals as the candidate physical sub-interval. If the storage ranges of the two adjacent physical sub-intervals are both the same as that of the target physical sub-interval, then a physical sub-interval is randomly selected from the two adjacent physical sub-intervals as the candidate physical sub-interval. Then, the storage range of the target physical sub-interval is merged with the storage range of the candidate physical sub-interval to obtain the merged target physical sub-interval, and the original candidate physical sub-interval is determined as the shrunk sub-interval.

[0160] For example, if the storage range of the target physical sub-interval is index = [20, 29], and the storage ranges of the two physical sub-intervals adjacent to the target physical sub-interval are index = [30, 39] and index = [0, 19] respectively, then the physical sub-interval with the storage range of index = [30, 39] is determined as the candidate physical sub-interval. Then, the storage range of the target physical sub-interval index = [20, 29] is merged with the storage range of the candidate physical sub-interval index = [30, 39] to obtain the merged storage range of the target physical sub-interval index = [20, 39], and the original candidate physical sub-interval is determined as the reduced-capacity sub-interval.

[0161] For another example, if the storage range of the target physical sub-interval is index = [20, 29], and the storage ranges of the two physical sub-intervals adjacent to the target physical sub-interval are index = [30, 39] and index = [10, 19] respectively, then a physical sub-interval is randomly selected from the two adjacent physical sub-intervals as the candidate physical sub-interval. For example, the physical sub-interval with the storage range of index = [10, 19] is selected as the candidate physical sub-interval. Then, the storage range of the target physical sub-interval index = [20, 29] is merged with the storage range of the candidate physical sub-interval index = [10, 19] to obtain the merged storage range of the target physical sub-interval index = [10, 29], and the original candidate physical sub-interval is determined as the reduced-capacity sub-interval.

[0162] S402. Release the space occupied by the reduced-capacity sub-interval to obtain the processed cache.

[0163] In the embodiments of the present application, after the reduced-capacity sub-space is determined as above, the space occupied by the reduced-capacity sub-space can be released to obtain the cache after releasing the reduced-capacity sub-space. Optionally, the space occupied by the original candidate sub-space can be released, and the number of idle intervals in the target logical interval is incremented by one, thereby obtaining the processed cache.

[0164] The method for reducing the capacity of the target physical sub-interval provided in the embodiments of the present application realizes the reduction of the cache capacity by merging the target physical sub-interval and the candidate physical sub-interval to obtain the reduced-capacity sub-interval. The reduction method is simple and easy to implement, without complex reduction steps. Under the computing power of the mainstream CPU, the reduction of the cache can be at the nanosecond level, greatly improving the reduction efficiency of the cache.

[0165] In one embodiment, on the basis of Figure 10 the embodiment shown, as Figure 11 shown, the above method further includes:

[0166] S403. Determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent.

[0167] Among them, the other physical sub-intervals can be each physical sub-interval in the target logical interval after the expansion in step S402 above.

[0168] In the embodiment of the present application, after the above-mentioned merging of the target physical sub-interval and the candidate physical sub-interval to obtain the processed target logical interval, it is possible to continue to determine whether the storage ranges of each physical sub-interval in the target logical interval are consistent.

[0169] S404. If they are inconsistent, select a physical sub-interval from the other physical sub-intervals as the new target physical sub-interval, and perform shrinking on the new target physical sub-interval to obtain the processed cache.

[0170] In the embodiment of the present application, if the storage ranges of each physical sub-interval in the target logical interval are not completely consistent, determine a physical sub-interval with the smallest storage range from each physical sub-interval as the new target physical sub-interval, and according to the storage range of the new target physical sub-interval, merge the new target physical sub-interval with the candidate physical sub-interval to obtain the merged target physical sub-interval, and determine the original candidate physical sub-interval as the expansion sub-interval, and release the space occupied by the shrinking sub-space to obtain the cache after releasing the shrinking sub-space, and add one to the number of idle intervals in the target logical interval, thereby obtaining the processed cache; further, determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent, and in the case where the storage ranges of other physical sub-intervals in the target logical interval are not completely consistent, again determine a physical sub-interval with the smallest storage range from each physical sub-interval as the new target physical sub-interval, and according to the storage range of the new target physical sub-interval, merge the new target physical sub-interval with the candidate physical sub-interval to obtain the merged target physical sub-interval, and determine the original candidate physical sub-interval as the expansion sub-interval, and release the space occupied by the shrinking sub-space to obtain the cache after releasing the shrinking sub-space, and add one to the number of idle intervals in the target logical interval, thereby obtaining the processed cache,... until the storage ranges of all physical sub-intervals in the target logical interval are consistent, or until the number of physical sub-intervals in the target logical interval is one, to obtain the processed cache.

[0171] In the method for selecting a new target physical sub-interval provided in the embodiment of the present application, when the storage ranges of each physical sub-interval in the target logical interval are inconsistent, the method of selecting a new target physical sub-interval from each physical sub-interval and performing shrinking on the new target physical sub-interval is simple and easy to implement, and greatly improves the shrinking efficiency of the cache.

[0172] In one embodiment, based on the embodiment shown in Figure 11 , if the storage ranges of other physical sub-intervals in the target logical interval are the same, as shown in Figure 12 , the above method further includes:

[0173] S405. Stop downsizing to obtain the processed cache.

[0174] In the embodiment of the present application, when the storage ranges of other physical sub-intervals in the target logical interval are all the same, stop downsizing, so as to obtain a cache in which the storage ranges of all physical sub-intervals in the target logical interval are the same.

[0175] S406. Or, according to the arrangement order of other physical sub-intervals, perform sequential downsizing on each of the other physical sub-intervals until there is only one physical sub-interval left in the target logical interval, to obtain the processed cache.

[0176] In the embodiment of the present application, a downsizing method is further provided when the storage ranges of other physical sub-intervals in the target logical interval are all the same. According to the arrangement order of other physical sub-intervals in the target logical interval, sequential downsizing can be performed on each physical sub-interval in turn according to the above downsizing method until there is only one physical sub-interval left in the target logical interval, to obtain the processed cache.

[0177] In the method for sequentially downsizing other physical sub-intervals provided in the embodiment of the present application, when the storage ranges of each physical sub-interval in the target logical interval are the same, sequentially downsize each physical sub-interval until there is only one physical sub-interval left in the target logical interval. The selection method is simple and easy to implement, greatly improving the downsizing efficiency of the cache.

[0178] In one embodiment, as shown in Figure 13 , a data addressing method is provided. When this method is applied to the hash ring structure in the above Figure 5 -shown embodiment, it includes the following steps:

[0179] S501. Determine the target logical interval where the data to be queried is located according to the storage range of the logical interval in the hash ring structure and the address of the data to be queried.

[0180] Among them, the storage range of the logical interval can be determined by the ratio between the total index range after serialization of the key responsible for the hash ring structure and the number of logical intervals in the hash ring structure; the address of the data to be queried can be obtained by serializing the data to be queried (for example, key), and the address of the data to be queried can be the index corresponding to the data to be queried (for example, key).

[0181] In the embodiments of the present application, when addressing the data to be queried on the hash ring structure, the total index range after serialization of the key (key) responsible for the hash ring structure, the number of logical intervals in the hash ring structure, and the address of the data to be queried can be obtained first, and then operations are performed on the total index range after serialization of the key (key) responsible for the hash ring structure, the number of logical intervals in the hash ring structure, and the address of the data to be queried to obtain the target logical interval where the data to be queried is located.

[0182] S502. Determine the physical sub-interval where the data to be queried is located according to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried.

[0183] In the embodiments of the present application, after obtaining the target logical interval where the data to be queried is located, the number of physical sub-intervals included in the target logical interval can be further determined, and then numerical operations are performed on the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried to obtain the serial number of the physical sub-interval where the data to be queried is located.

[0184] The data addressing method provided in the embodiments of the present application is applied to the hash ring structure in the above embodiments. According to the storage range of the logical intervals in the hash ring structure and the address of the data to be queried, the target logical interval where the data to be queried is located is determined. According to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried, the physical sub-interval where the data to be queried is located is determined. The above method realizes the addressing of the data to be queried through calculation. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, saving the time of accessing node memory. Under the computing power of mainstream CPUs, the addressing effect is at the level of dozens of nanoseconds, greatly improving the data addressing efficiency.

[0185] In one embodiment, on the basis of Figure 13 the embodiment shown, the process of obtaining the target logical interval where the data to be queried is located can be described. As Figure 14 shown, the above S501 "Determine the target logical interval where the data to be queried is located according to the storage ranges of the logical intervals in the hash ring structure and the address of the data to be queried" includes:

[0186] S601. Determine the first address as the ratio of the address of the data to be queried to the storage range of the logical interval.

[0187] In the embodiment of the present application, after obtaining the address of the data to be queried and the storage range of the logical interval, the ratio operation can be performed on the address of the data to be queried and the storage range of the logical interval to obtain the ratio between the address of the data to be queried and the storage range of the logical interval, and the ratio between the address of the data to be queried and the storage range of the logical interval is determined as the first address. Optionally, the process of obtaining the first address can be represented by the following formula (1):

[0188]

[0189] Where slice represents the serial number of the target logical interval where the data to be queried is located, that is, the first address, index represents the address of the data to be queried, maxHashIndex represents the total index range after serialization of the key (key) responsible for the hash ring structure, and bucketGroupBaseNr represents the number of logical intervals in the hash ring structure, represents the storage range of the logical interval in the hash ring structure.

[0190] S602. Search for the logical interval corresponding to the first address in the cache and determine it as the target logical interval.

[0191] In the embodiment of the present application, after determining the first address, the logical interval corresponding to the first address can be searched in the hash ring structure of the cache, and the logical interval corresponding to the first address is determined as the target logical interval. For example, if the first address is 3, then the third logical interval can be determined from the hash ring structure in the ascending order of the index, and the third logical interval is determined as the target logical interval.

[0192] The method for determining the target logical interval provided by the embodiment of the present application performs a numerical operation on the address of the data to be queried and the storage range of the logical interval, and then the target logical interval where the data to be queried is located can be obtained, which provides a basis for determining the physical sub-interval according to the target logical interval where the data to be queried is located.

[0193] In one embodiment, on the basis of Figure 13 or Figure 14 the embodiment shown, the process of obtaining the physical sub-interval where the data to be queried is located can be described. As Figure 15 shown, the above S502 "determine the physical sub-interval where the data to be queried is located according to the storage range of each logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried" includes:[[]]

[0194] S701. Determine the demarcation line and the first threshold according to the number of physical sub-intervals included in the target logical interval.

[0195] In the embodiment of the present application, after determining the target logical range of the data to be queried, the number of physical sub-ranges in the target logical range can be determined based on the hash ring structure, and a first threshold can be determined according to the number of physical sub-ranges. Then, numerical operations are performed on the first threshold and the number of physical sub-ranges to determine the position of the boundary line adjacent to the target physical sub-range.

[0196] S702. Determine the physical sub-range where the data to be queried is located according to the position of the boundary line, the first threshold, the storage range of the logical range, and the address of the data to be queried.

[0197] In the embodiment of the present application, after obtaining the position of the boundary line, the first threshold, the storage range of the logical range, and the address of the data to be queried, numerical operations can be performed on the position of the boundary line, the first threshold, the storage range of the logical range, and the address of the data to be queried to obtain the physical sub-range where the data to be queried is located.

[0198] The method for determining the physical sub-range provided in the embodiment of the present application performs numerical operations on the position of the boundary line, the first threshold, the storage range of the logical range, and the address of the data to be queried, and the physical sub-range where the data to be queried is located can be obtained. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, saving the time of accessing node memory. Under the computing power of mainstream CPUs, the addressing effect is at the level of dozens of nanoseconds, greatly improving the data addressing efficiency.

[0199] In one embodiment, on the basis of Figure 15 the embodiment shown, the process of obtaining the physical sub-range where the data to be queried is located can be further described. For example, Figure 16 as shown, the above S702 "Determine the physical sub-range where the data to be queried is located according to the position of the boundary line, the first threshold, the storage range of the logical range, and the address of the data to be queried" includes:

[0200] S801. Determine a first condition value according to the position of the boundary line, the first threshold, and the storage range of the logical range.

[0201] In the embodiment of the present application, after determining the position of the boundary line, the first threshold, and the storage range of the logical range, numerical operations can be performed on the position of the boundary line, the first threshold, and the storage range of the logical range to obtain a first condition. Optionally, the following formula (2) gives the process of determining the first condition:

[0202]

[0203] where Con1 represents the first condition, split represents the position of the boundary line, Indicates the storage range of the logical interval, ceil represents the second threshold. For example, the number of physical sub-intervals in the target logical interval is 3. Since 2 1 <3 < 2 2 , so the second threshold floor is 2 1 , 2 2 is the first threshold ceil.

[0204] S802. Determine the second conditional value according to the storage range of the logical interval and the address of the data to be queried.

[0205] In the embodiments of the present application, after determining the storage range of the logical interval and the address of the data to be queried, numerical operations can be performed on the storage range of the logical interval and the address of the data to be queried to obtain the second condition. Optionally, the following formula (3) gives the process of determining the second condition:

[0206]

[0207] where Con2 represents the second condition, index represents the address of the data to be queried, represents the storage range of the logical interval.

[0208] S803. Determine the physical sub-interval where the data to be queried is located according to the first conditional value and the second conditional value.

[0209] In the embodiments of the present application, after determining the first conditional value and the second conditional value, the physical sub-interval where the data to be queried is located can be determined according to the relationship between the first conditional value and the second conditional value. Optionally, if the first conditional value is greater than the second conditional value, it means that the physical sub-interval where the data to be queried is located is at the left position of the boundary line; if the first conditional value is less than the second conditional value, it means that the physical sub-interval where the data to be queried is located is at the right position of the boundary line.

[0210] The method for determining the physical sub-interval provided by the embodiments of the present application determines the physical sub-interval where the data to be queried is located based on the position of the boundary line and the magnitude relationship between the first conditional value and the second conditional value. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, and only simple numerical operations are required to determine the physical sub-interval of the data to be queried, which improves the addressing efficiency of the data to a certain extent.

[0211] In one embodiment, on the basis of the embodiment shown in Figure 16 , the process of obtaining the physical sub-interval where the data to be queried is located can be further described. As shown in Figure 17 , the above S803 "Determine the physical sub-interval where the data to be queried is located according to the first conditional value and the second conditional value" includes:

[0212] S901. Determine whether the first conditional value is greater than the second conditional value. If so, go to S902; if not, go to S903.

[0213] S902. Determine the physical sub - interval where the data to be queried is located by using the first addressing method.

[0214] Among them, the first addressing method may be that when the first conditional value is greater than the second conditional value, the physical sub - space where the data to be queried is located is at the physical sub - space adjacent to the left of the position of the demarcation line.

[0215] In the embodiment of the present application, when it is determined that the first conditional value is greater than the second conditional value as described above, the physical sub - space where the data to be queried is located is in multiple physical sub - intervals on the left side of the demarcation line position. Then, use the first addressing method to screen out a physical sub - interval from multiple physical sub - intervals on the left side of the demarcation line position as the physical sub - interval where the data to be queried is located.

[0216] S903. Determine the physical sub - interval where the data to be queried is located by using the second addressing method.

[0217] Among them, the second addressing method may be that when the first conditional value is not greater than the second conditional value, the physical sub - space where the data to be queried is located is at the physical sub - space adjacent to the right of the position of the demarcation line.

[0218] In the embodiment of the present application, when it is determined that the first conditional value is not greater than the second conditional value as described above, the physical sub - space where the data to be queried is located is in multiple physical sub - intervals on the right side of the demarcation line position. Then, use the second addressing method to screen out a physical sub - interval from multiple physical sub - intervals on the right side of the demarcation line position as the physical sub - interval where the data to be queried is located.

[0219] The method for determining the physical sub - space provided by the embodiment of the present application uses different addressing methods to determine the physical sub - interval where the data to be queried is located under different conditions, and can complete the addressing of the data to be queried in a refined manner on the premise of narrowing the query range, which improves the query accuracy to a certain extent.

[0220] In one embodiment, on the basis of Figure 17 the embodiment shown, the process of determining the physical sub - interval where the data to be queried is located by using the first addressing method can be further described. For example, Figure 18 as shown, the above - mentioned S901 “Determine the physical sub - interval where the data to be queried is located by using the first addressing method” includes:

[0221] S1001. Determine the second address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, and the first threshold.

[0222] In the embodiment of the present application, after obtaining the storage range of the logical interval, the address of the data to be queried, and the first threshold, numerical operations can be performed on the storage range of the logical interval, the address of the data to be queried, and the first threshold to obtain the second address of the data to be queried. Optionally, the following formula (4) gives the process of determining the second address of the data to be queried:

[0223]

[0224] Among them, bucketGroupIdx1 represents the second address of the data to be queried, index represents the address of the data to be queried, represents the storage range of the logical interval, ceil represents the first threshold, maxHashIndex represents the total index range after serialization of the key (key) responsible for the hash ring structure, and bucketGroupBaseNr represents the number of logical intervals in the hash ring structure.

[0225] S1002. Search for the physical sub-interval corresponding to the second address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0226] In the embodiment of the present application, after determining the second address, the physical sub-interval corresponding to the second address can be searched in the target logical interval, and the physical sub-interval corresponding to the second address is determined as the physical sub-interval where the data to be queried is located. For example, if the second address is 3, then the third physical sub-interval can be determined from the target logical interval in the ascending order of indexes, and the third physical sub-interval is determined as the physical sub-interval where the data to be queried is located.

[0227] The method for determining the physical sub-interval provided by the embodiment of the present application can obtain the position of the physical sub-interval where the data to be queried is located based on the calculation method. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, and only simple numerical operations are required to determine the physical sub-interval of the data to be queried, which improves the addressing efficiency of the data to a certain extent.

[0228] In one embodiment, based on Figure 18 the embodiment shown, the process of determining the physical sub-interval where the data to be queried is located by using the second addressing method can be further described. As Figure 19 shown, the above S902 "determine the physical sub-interval where the data to be queried is located by using the second addressing method" includes:

[0229] S1101. Determine the third address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, the first threshold, and the position of the dividing line.

[0230] In the embodiment of the present application, after obtaining the storage range of the logical interval, the address of the data to be queried, the first threshold, and the position of the demarcation line, numerical operations can be performed on the storage range of the logical interval, the address of the data to be queried, the first threshold, and the position of the demarcation line to obtain the third address of the data to be queried. Optionally, the following formula (5) gives the process of determining the third address of the data to be queried:

[0231]

[0232] where bucketGroupIdx2 represents the third address of the data to be queried, index represents the address of the data to be queried, represents the storage range of the logical interval, ceil represents the first threshold, maxHashIndex represents the total index range after serialization of the key (key) responsible for the hash ring structure, bucketGroupBaseNr represents the number of logical intervals in the hash ring structure, and split represents the position of the demarcation line.

[0233] S1102. Search for the physical sub-interval corresponding to the third address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0234] In the embodiment of the present application, after determining the third address, the physical sub-interval corresponding to the third address can be searched in the target logical interval, and the physical sub-interval corresponding to the third address can be determined as the physical sub-interval where the data to be queried is located. For example, if the third address is 3, then the third physical sub-interval can be determined starting from the right side of the position of the demarcation line in the target logical interval in the ascending order of indexes, and the third physical sub-interval on the right side of the demarcation line can be determined as the physical sub-interval where the data to be queried is located.

[0235] The method for determining the physical sub-interval provided by the embodiment of the present application can obtain the position of the physical sub-interval where the data to be queried is located based on calculation. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not require traversing nodes or searching for nearby nodes, and only simple numerical operations are required to determine the physical sub-interval of the data to be queried, which improves the addressing efficiency of data to a certain extent.

[0236] In one embodiment, on the basis of the embodiment shown in Figure 15 the process of obtaining the demarcation line can be further described. As shown in Figure 20 above, S701 "Determine the demarcation line according to the number of physical sub-intervals included in the target logical interval" includes:

[0237] S1201. Determine the second threshold according to the number of physical sub-intervals.

[0238] In the embodiments of the present application, after obtaining the number of physical sub-intervals as described above, numerical operations can be performed on the number of physical sub-intervals to obtain a second threshold. For example, the number of physical sub-intervals in the target logical interval is 3. Since 2 1 <3<2 2 , the first threshold is 2 1 , 2 2 is the second threshold.

[0239] S1202. Determine the dividing line according to the second threshold and the number of physical sub-intervals.

[0240] In the embodiments of the present application, after determining the second threshold and the number of physical sub-intervals as described above, numerical operations can be performed on the second threshold and the number of physical sub-intervals to obtain the dividing line. Optionally, the second threshold and the number of physical sub-intervals in the target logical interval are simultaneously input into the following formula (6) to obtain the position of the dividing line:

[0241] splitIdx = (layer - floor) * 2 (6);

[0242] where splitIdx represents the position of the dividing line, layer represents the number of physical sub-intervals in the target logical interval, and floor represents the second threshold.

[0243] The method for obtaining the dividing line provided by the embodiments of the present application can obtain the position of the dividing line based on a calculation method, providing a data basis for determining the physical sub-interval of the data to be queried according to the position of the dividing line.

[0244] In one embodiment, as Figure 21 shown, a complete method for processing the cache is also provided, including:

[0245] S10. Determine the target logical interval in the cache;

[0246] S11. Determine the target physical sub-interval in the target logical interval;

[0247] S12. Split the target physical sub-interval according to the storage range of the target physical sub-interval to obtain an expanded sub-interval;

[0248] S13. Increase the space occupied by the expanded sub-interval between the target physical sub-interval and the adjacent physical sub-interval to obtain the processed cache;

[0249] S14. Determine whether the storage ranges of other physical sub-intervals in the target logical interval are the same. If not, go to S15; if so, go to S16;

[0250] S15. Select a physical sub-interval from other physical sub-intervals as the new target physical sub-interval, and perform capacity expansion according to the new target physical sub-interval to obtain the processed cache;

[0251] S16. Stop capacity expansion to obtain the processed cache; or, perform sequential capacity expansion on each of the other physical sub-intervals according to the arrangement order of the other physical sub-intervals until there is no free space in the target logical interval, and obtain the processed cache;

[0252] S17. Merge the target physical sub-interval and the candidate physical sub-interval according to the storage range of the target physical sub-interval to obtain a capacity reduction sub-interval;

[0253] S18. Release the space occupied by the capacity reduction sub-interval to obtain the processed cache;

[0254] S19. Determine whether the storage ranges of the other physical sub-intervals in the target logical interval are consistent. If not, go to S20; if so, go to S21;

[0255] S20. Select a physical sub-interval from other physical sub-intervals as the new target physical sub-interval, and perform capacity reduction according to the new target physical sub-interval to obtain the processed cache;

[0256] S21. Stop capacity reduction to obtain the processed cache; or, perform sequential capacity reduction on each of the other physical sub-intervals according to the arrangement order of the other physical sub-intervals until there is only one physical sub-interval left in the target logical interval, and obtain the processed cache.

[0257] The above method is based on a pre-determined hash ring structure, so that when performing capacity expansion and reduction processing on the cache, it is only necessary to first locate the logical interval where the physical sub-interval to be processed is located, then determine the physical sub-interval from the logical interval, and then perform capacity expansion and reduction processing on the physical sub-interval. Compared with the classical consistent hashing method that needs to add and delete nodes additionally during capacity expansion and reduction, the above method directly accesses the corresponding physical sub-interval during capacity expansion and reduction, and then performs capacity expansion and reduction processing on the physical sub-interval, without the need to search for the positions of nodes to be added and deleted in a large range in the hash ring structure, which improves the efficiency of cache capacity expansion and reduction to a certain extent.

[0258] In one embodiment, as Figure 22 shown, a complete data addressing method is also provided, including:

[0259] S100. Determine the ratio of the address of the data to be queried and the storage range of the logical interval as the first address;

[0260] S101. Search for the logical interval corresponding to the first address in the cache and determine it as the target logical interval;

[0261] S102. Determine a demarcation line and a first threshold according to the number of physical sub-intervals included in the target logical interval;

[0262] S103. Determine a first conditional value according to the position of the demarcation line, the first threshold, and the storage range of the logical interval;

[0263] S104. Determine a second conditional value according to the storage range of the logical interval and the address of the data to be queried;

[0264] S105. Determine whether the first conditional value is greater than the second conditional value. If it is greater, go to S106 - S107; if it is not greater, go to S108 - S109;

[0265] S106. Determine a second address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, and the first threshold;

[0266] S107. Search for the physical sub-interval corresponding to the second address in the target logical interval to obtain the physical sub-interval where the data to be queried is located;

[0267] S108. Determine a third address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, the first threshold, and the position of the demarcation line;

[0268] S109. Search for the physical sub-interval corresponding to the third address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0269] The above method realizes the addressing of the data to be queried through calculation. Compared with the existing addressing methods of traversing nodes or searching for nearby nodes, the above method does not need to traverse nodes or search for nearby nodes, saving the time of accessing node memory. Under the computing power of mainstream CPUs, the addressing effect is at the level of dozens of nanoseconds, greatly improving the data addressing efficiency.

[0270] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0271] Based on the same inventive concept, an embodiment of the present application further provides a cache processing device for implementing the cache processing method involved above. The solution provided by this device for solving problems is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the cache processing device provided below can refer to the limitations on the cache processing method in the above text, and will not be repeated here.

[0272] In an exemplary embodiment, as Figure 23 shown, a cache processing device is provided, including: a first determination module 10, a second determination module 11, and a processing module 12, where:

[0273] The first determination module 10 is configured to determine a target logical range in the cache; the cache includes multiple logical ranges, and the multiple logical ranges form a hash ring structure; each logical range includes multiple physical sub-ranges.

[0274] The second determination module 11 is configured to determine a target physical sub-range in the target logical range.

[0275] The processing module 12 is configured to expand or contract the target physical sub-range to obtain a processed cache.

[0276] In an exemplary embodiment, the above processing module 12 includes: a splitting unit and an obtaining unit, where:

[0277] The splitting unit is specifically configured to split the target physical sub-range according to the storage range of the target physical sub-range to obtain an expanded sub-range;

[0278] The obtaining unit is specifically configured to increase the space occupied by the expanded sub-range between the target physical sub-range and the adjacent physical sub-range to obtain a processed cache.

[0279] In an exemplary embodiment, the above processing module 12 further includes: a determination unit and a selection unit, where:

[0280] The determination unit is specifically configured to determine whether the storage ranges of other physical sub-ranges in the target logical range are the same;

[0281] The selection unit is specifically configured to, if not the same, select a physical sub-range from other physical sub-ranges as a new target physical sub-range, and return to execute the step of expanding the target physical sub-range to obtain a processed cache.

[0282] In an exemplary embodiment, if the same, the above processing module 12 further includes: a stop unit or an expansion unit, where:

[0283] The stop unit is specifically configured to stop the expansion to obtain a processed cache;

[0284] Alternatively, an expansion unit is specifically configured to expand other physical sub-intervals in sequence according to the arrangement order of other physical sub-intervals until there is no free space in the target logical interval, so as to obtain a processed cache.

[0285] In an exemplary embodiment, the above processing module 12 includes: a merging unit and a releasing unit, where:

[0286] The merging unit is specifically configured to merge the target physical sub-interval with a candidate physical sub-interval according to the storage range of the target physical sub-interval to obtain a reduced-capacity sub-interval; the storage range of the candidate physical sub-interval is the same as that of the target physical sub-interval;

[0287] The releasing unit is specifically configured to release the space occupied by the reduced-capacity sub-interval to obtain a processed cache.

[0288] In an exemplary embodiment, the above processing module 12 further includes: a determining unit and a selecting unit, where:

[0289] The determining unit is specifically configured to determine whether the storage ranges of other physical sub-intervals in the target logical interval are consistent;

[0290] The selecting unit is specifically configured to, if inconsistent, select a physical sub-interval from other physical sub-intervals as a new target physical sub-interval, and return to execute the step of reducing the capacity of the target physical sub-interval to obtain a processed cache.

[0291] In an exemplary embodiment, if consistent, the above processing module 12 further includes: a stopping unit and a reducing-capacity unit, where:

[0292] The stopping unit is specifically configured to stop reducing the capacity to obtain a processed cache;

[0293] Alternatively, the reducing-capacity unit is specifically configured to reduce the capacity of each other physical sub-interval in sequence according to the arrangement order of other physical sub-intervals until there is one physical sub-interval remaining in the target logical interval, so as to obtain a processed cache.

[0294] In an exemplary embodiment, as Figure 24 shown, there is provided an addressing device for data, including: a first determining module 20 and a second determining module 21, where:

[0295] The first determining module 20 is configured to determine a target logical interval where the data to be queried is located according to the storage range of the logical interval in the hash ring structure and the address of the data to be queried;

[0296] The second determination module 21 is configured to determine the physical sub-interval where the data to be queried is located according to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried.

[0297] In an exemplary embodiment, the first determination module 20 includes: a first determination unit and a second determination unit, where:

[0298] The first determination unit is specifically configured to determine the ratio of the address of the data to be queried to the storage range of the logical interval as the first address;

[0299] The second determination unit is specifically configured to find, in the cache, the logical interval corresponding to the first address and determine it as the target logical interval.

[0300] In an exemplary embodiment, the first determination module 21 includes: a third determination unit and a fourth determination unit, where:

[0301] The third determination unit is specifically configured to determine the demarcation line and the first threshold according to the number of physical sub-intervals included in the target logical interval;

[0302] The fourth determination unit is specifically configured to determine the physical sub-interval where the data to be queried is located according to the position of the demarcation line, the first threshold, the storage range of the logical interval, and the address of the data to be queried.

[0303] In an exemplary embodiment, the fourth determination unit is specifically configured to determine the first condition value according to the position of the demarcation line, the first threshold, and the storage range of the logical interval; determine the second condition value according to the storage range of the logical interval and the address of the data to be queried; and determine the physical sub-interval where the data to be queried is located according to the first condition value and the second condition value.

[0304] In an exemplary embodiment, the fourth determination unit is specifically configured to, when the first condition value is greater than the second condition value, determine the physical sub-interval where the data to be queried is located by using the first addressing method; and when the first condition value is not greater than the second condition value, determine the physical sub-interval where the data to be queried is located by using the second addressing method.

[0305] In an exemplary embodiment, the fourth determination unit is specifically configured to determine the second address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, and the first threshold; and find, in the target logical interval, the physical sub-interval corresponding to the second address to obtain the physical sub-interval where the data to be queried is located.

[0306] In an exemplary embodiment, the above-mentioned fourth determination unit is specifically configured to determine a third address of the data to be queried according to the storage range of the logical interval, the address of the data to be queried, a first threshold, and the position of the demarcation line; and search for a physical sub-interval corresponding to the third address in the target logical interval to obtain the physical sub-interval where the data to be queried is located.

[0307] In an exemplary embodiment, the above-mentioned third determination unit is specifically configured to determine a second threshold according to the number of physical sub-intervals; and determine the demarcation line according to the second threshold and the number of physical sub-intervals.

[0308] Each module in the above-mentioned cache processing device and data addressing device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or stored in a memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0309] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 4 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cache data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a cache processing method and a data addressing method.

[0310] Those skilled in the art can understand that Figure 4 the structure shown in

[0311] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.

[0312] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0313] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0314] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, database, or other medium in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0315] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.

[0316] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation to the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A method for processing a cache, characterized in that, The method includes: Determine a target logical interval in the cache; the cache includes a plurality of logical intervals, and the plurality of logical intervals form a hash ring structure; each of the logical intervals includes a plurality of physical sub-intervals; Determine a target physical sub-interval in the target logical interval; Expand or contract the target physical sub-interval to obtain a processed cache.

2. The method according to claim 1, characterized in that, Expanding the target physical sub-interval to obtain a processed cache includes: According to the storage range of the target physical sub-interval, split the target physical sub-interval to obtain an expanded sub-interval; Add the space occupied by the expanded sub-interval between the target physical sub-interval and an adjacent physical sub-interval to obtain a processed cache.

3. The method according to claim 2, characterized in that, The method further includes: Determine whether the storage ranges of other physical sub-intervals in the target logical interval are the same; If not, select a physical sub-interval from the other physical sub-intervals as a new target physical sub-interval, and return to execute the step of expanding the target physical sub-interval to obtain a processed cache.

4. The method according to claim 3, characterized in that, If they are the same, the method further includes: Stop expanding to obtain the processed cache; Alternatively, according to the arrangement order of the other physical sub-intervals, expand each of the other physical sub-intervals in sequence until there is no free space in the target logical interval, to obtain the processed cache.

5. The method according to claim 1, characterized in that, Contracting the target physical sub-interval to obtain a processed cache includes: According to the storage range of the target physical sub-interval, merge the target physical sub-interval with a candidate physical sub-interval to obtain a contracted sub-interval; the storage range of the candidate physical sub-interval is the same as that of the target physical sub-interval; Release the space occupied by the contracted sub-interval to obtain the processed cache.

6. The method according to claim 5, characterized in that, The method further includes: Determine whether the storage ranges of other physical sub-intervals in the target logical interval are the same; If not, select a physical sub-interval from the other physical sub-intervals as a new target physical sub-interval, and return to execute the step of contracting the target physical sub-interval to obtain a processed cache.

7. The method according to claim 6, characterized in that, If they are the same, the method further includes: Stop contracting to obtain the processed cache; Alternatively, according to the arrangement order of the other physical sub-intervals, contract each of the other physical sub-intervals in sequence until there is only one physical sub-interval left in the target logical interval, to obtain the processed cache.

8. A method for addressing data, characterized in that, The method is applied to the hash ring structure as claimed in claim 1, and the method includes: According to the storage range of the logical intervals in the hash ring structure and the address of the data to be queried, determine the target logical interval where the data to be queried is located; According to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried, determine the physical sub-interval where the data to be queried is located.

9. The method according to claim 8, characterized in that, The determining the target logical interval where the data to be queried is located according to the storage ranges of the logical intervals in the hash ring structure and the address of the data to be queried includes: Determine the ratio of the address of the data to be queried to the storage range of the logical range as the first address; Search in the cache for the logical range corresponding to the first address and determine it as the target logical range.

10. The method according to claim 8 or 9, characterized in that, The determining of the physical sub-range where the data to be queried is located according to the storage ranges of the logical ranges, the number of physical sub-ranges included in the target logical range, and the address of the data to be queried includes: Determine a demarcation line and a first threshold according to the number of physical sub-ranges included in the target logical range; Determine the physical sub-range where the data to be queried is located according to the position of the demarcation line, the first threshold, the storage range of the logical range, and the address of the data to be queried.

11. The method according to claim 10, wherein The determining of the physical sub-range where the data to be queried is located according to the position of the demarcation line, the first threshold, the storage range of the logical range, and the address of the data to be queried includes: Determine a first condition value according to the position of the demarcation line, the first threshold, and the storage range of the logical range; Determine a second condition value according to the storage range of the logical range and the address of the data to be queried; Determine the physical sub-range where the data to be queried is located according to the first condition value and the second condition value.

12. The method according to claim 11, wherein The determining of the physical sub-range where the data to be queried is located according to the first condition value and the second condition value includes: In the case where the first condition value is greater than the second condition value, use a first addressing method to determine the physical sub-range where the data to be queried is located; In the case where the first condition value is not greater than the second condition value, use a second addressing method to determine the physical sub-range where the data to be queried is located.

13. The method according to claim 12, wherein The using of the first addressing method to determine the physical sub-range where the data to be queried is located includes: Determine a second address of the data to be queried according to the storage range of the logical range, the address of the data to be queried, and the first threshold; Search in the target logical range for the physical sub-range corresponding to the second address to obtain the physical sub-range where the data to be queried is located.

14. The method according to claim 12, wherein The using of the second addressing method to determine the physical sub-range where the data to be queried is located includes: Determine a third address of the data to be queried according to the storage range of the logical range, the address of the data to be queried, the first threshold, and the position of the demarcation line; Search in the target logical range for the physical sub-range corresponding to the third address to obtain the physical sub-range where the data to be queried is located.

15. The method according to claim 10, wherein The determining of the demarcation line according to the number of physical sub-ranges included in the target logical range includes: Determine a second threshold according to the number of physical sub-ranges; Determine the demarcation line according to the second threshold and the number of physical sub-ranges.

16. A processing device for a cache, wherein The device includes: A first determination module for determining the target logical range in the cache; the cache includes a plurality of logical ranges, and the plurality of logical ranges form a hash ring structure; each of the logical ranges includes a plurality of physical sub-ranges; A second determination module for determining the target physical sub-range in the target logical region; A processing module, configured to expand or contract the target physical sub-interval to obtain a processed cache.

17. An addressing device for data, wherein The device includes: A first determination module, configured to determine a target logical interval where the data to be queried is located according to the storage range of the logical intervals in the hash ring structure and the address of the data to be queried; A second determination module, configured to determine a physical sub-interval where the data to be queried is located according to the storage range of the logical interval, the number of physical sub-intervals included in the target logical interval, and the address of the data to be queried.

18. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and wherein When the processor executes the computer program, the steps of the method according to any one of claims 1 to 15 are implemented.

19. A computer-readable storage medium, on which a computer program is stored, and wherein When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 15 are implemented.

Citation Information

Patent Citations

  • Data writing and expansion method and device of distributed caching system

    CN108810041A

  • Data cluster storage method and device and computer equipment

    CN110489059A

  • Storage cluster management method and device, electronic equipment and storage medium

    CN114816225A

  • Data operation method and device, equipment and storage medium

    CN117112546A

  • Data cluster storage method and apparatus, and computer device

    WO2021003935A1