Specific embodiment
In order to make those skilled in the art more fully understand the technical solution in the application, below in conjunction with the attached drawing in the embodiment of the present application, the technical scheme in the embodiment of the application is clearly and completely described, obviously, described embodiments are only a part of embodiments of the present application, instead of all the embodiments.Based on the embodiment in the application, every other embodiment obtained by those of ordinary skill in the art without making creative efforts, should fall within the scope of the present invention.
In order to make the embodiment of the present application easily facilitate understanding, the possible application scenarios of the embodiment of the present application are illustrated first.For example, the embodiment of the present application can be applied in the individual query service device different from one or more cache server of memory buffers data is used for.Wherein, the keyword being made of hotel ID and date value and data cached mapping are saved in more cache servers.It can receive the inquiry request for hotel ID in specified range using the query service device of method provided by the embodiments of the present application, obtain set of keywords corresponding with inquiry request.For example, set of keywords of the hotel ID in 7 to 32 ranges can be inquired.
Based on above-mentioned analysis, the embodiment of the present application provides following distributed caching range query method and device.
It is distributed caching range query method flow schematic diagram provided by the embodiments of the present application for example, with reference to Fig. 1.As shown in Figure 1, this method may include:
S110, it will be used in the keyword of mapped cache data, can be used for the corresponding ident value of field value of range query, be stored in advance in the storage region of memory.
For example, improving search efficiency to reduce the number of nodes in node cycle, all keywords can be belonged to duplicate part in the field value of same field and rejected, only the different field value of same field is stored in advance in a storage region of memory.
Wherein, the storage organization positioned at the storage region of memory is unlimited, for example, it may be single-track link table, array, cyclic annular chained list etc..Such as, in some possible embodiments, it can will be in the keyword, the corresponding ident value of field value that can be used for range query is stored in advance in the node cycle (that is, cyclic annular chained list) of memory, wherein, the corresponding storage of one ident value establishes corresponding routing table into a node, and for each node in the node cycle, and the routing table has recorded the ident value of other the one or more nodes determined according to preset Index Algorithm.
In some possible embodiments, the preset Index Algorithm can be with are as follows: recorded with a routing table ident value spacing of node corresponding with the routing table in node cycle at 2 power side's relationship ident value.Accordingly, step S110 is specifically as follows: will be in keyword, can be used for range query, belong to the corresponding ident value of the field value of same field and be stored in the node cycle of memory by ident value size order, wherein, the routing table have recorded in the node cycle with the ident value spacing of corresponding node at 2 power side's relationship ident value.Typically, it is usually the value being not much different as can be used for ident value corresponding to the field value of range query in data cached, it is recorded in routing table with the ident value spacing of a node into the 2 corresponding node of the ident value of power side's relationship, subsequent lookup, raising search efficiency can be convenient for.
Certainly, preset Index Algorithm is not limited only to this one kind in embodiment above, specifically can need be configured according to actual queries efficiency, the application is to this and is not limited.For example, the preset Index Algorithm can be with are as follows: the ident value spacing for recording node corresponding with the routing table in node cycle with routing table is the ident value, etc. of specified constant integer times.
It is understood that key (keyword) can be made of the different field of various fields, wherein the field that can be used for range query may include such as the fields such as number, date.For example, then date value can be extracted from each keyword if necessary to do range query to the date, being by the different date value corresponding conversions extracted can be according to the ident value of preset Index Algorithm operation.In conjunction with the embodiment of upper node ring, then ident value can be stored as to end to end, per diem time value size order sequence node cycle in the form of chained list.For example, original key is " 07 day 08 month-hotelId-18873 of date-2014 ", keyword embodies date and hotel id corresponding relationship, and the date " on 08 07th, 2014 " can be converted to ident value 140807.It wherein, is specially sequentially to sort from small to large by field value by the sequence of ident value size order, or descending order sequence.
S120, the inquiry request that the keyword of specified range is directed in response to receiving, find out the corresponding ident value of endpoint value of the specified range from the storage region.
Such as, in the embodiment that ident value is stored in node cycle, the inquiry request of the keyword of specified range can be directed in response to receiving, using any node in the node cycle as present node, the nearest ident value of the endpoint value away from the specified range is searched in the routing table of the present node.If it is determined that the ident value found is the nearest ident value of the endpoint value away from the specified range in the node cycle, using the ident value found as the corresponding ident value of the endpoint value of the specified range;If it is determined that the ident value found is not the nearest ident value of the endpoint value away from the specified range in the node cycle, using the ident value found as present node, then the step of searching the nearest ident value of the endpoint value away from the specified range in the routing table of present node back to described.
It is understood that specified range may include one or more specified ranges, endpoint value can be the endpoint value for determining specified range section.For example, scheduled date range may include: on May 1,1 day to 2001 January in 2001, and, on May 1,1 day to 2002 January in 2002.Then endpoint value may include: 010101 and 010501,020101 and 020501.
It should be noted that, the corresponding ident value of the endpoint value can be the ident value equal with the endpoint value, in the case where the ident value equal with the endpoint value is not present, ident value nearest with the endpoint value in the specified range in node cycle can be.
S130, the corresponding set of keywords of the specified range is determined according to the corresponding ident value of endpoint value of the specified range.
For example, can construct the keyword in the specified range according to the corresponding ident value of endpoint value of the specified range, obtain the corresponding set of keywords of the specified range.Specifically, such as, corresponding key construction rule can be set for different type keyword in advance, the type for the keyword inquired as needed, using corresponding key construction rule, using the corresponding field value of ident value as input variable, corresponding keyword is constructed, obtains the corresponding set of keywords of inquiry request.Assuming that needing to construct the keyword for embodying date and hotel id corresponding relationship, then, the corresponding date field value of the ident value found out can be spliced respectively from different hotel id, obtain complete keyword according to the key construction preset difference hotel id of rule.It is, of course, also possible to the method for having other to determine keyword with ident value, those skilled in the art can need to be arranged according to actual implementation, and details are not described herein.
Such as, in some possible embodiments, method provided by the embodiments of the present application can be applied in the individual query service device different from one or more cache server of memory buffers data, after obtaining the corresponding set of keywords of specified range, it can also further concurrently obtain that the set of keywords is corresponding data cached from one or more described cache server by the downloading of multithreading, obtained data cached return to is issued into the client of the inquiry request.
It can be seen that, using method provided by the embodiments of the present application, after receiving for the inquiry request of the keyword of specified range, the inquiry that the corresponding ident value of endpoint value of the specified range is found out from the storage region can be completed all in memory, without accessing database, the range query with database decoupling is realized.
In the following, routing table is described in detail with the ident value spacing of corresponding node at the embodiment of the ident value of 2 power side's relationship for recording in node cycle.For example, the embodiment may include:
S210, will be in keyword, can be used for range query, belong to the corresponding ident value of the field value of same field and be stored in advance in the node cycle of memory by ident value size order, wherein, the corresponding storage of one ident value is into a node, and corresponding routing table is established for each node in the node cycle, wherein, the routing table have recorded in the node cycle with the ident value spacing of corresponding node at 2 power side's relationship ident value.
Wherein, spacing can refer at the ident value of 2 power side's relationship, and spacing is equal to 2i-1Node ident value, and, when there is no spacing be equal to 2i-1Ident value when, spacing is closest to 2i-1Node Identification.For example, in some possible embodiments, in order to pull open suitable spacing as far as possible to improve search efficiency, spacing is closest to 2i-1Ident value can take spacing be greater than 2i-1Ident value in, spacing is closest to 2i-1Ident value, wherein i is integer, and is more than or equal to 1, less than or equal to the maximum ident value total that takes 2 logarithm to round up again of the node cycle interior joint.
For example, node cycle as shown in Figure 3, wherein the numbers such as 2,8,10,16 marked beside node are the ident value for identifying node.One m routing tables of each node maintenance in node cycle as shown in Figure 3.Wherein, ident value is with binary system come if indicating, m is the digit of maximum binary identification value in node cycle.If L indicates that the maximum node of ident value in ring, m are that L takes 2 logarithms to round up.That is:As shown in figure 3, needing on all Node distributions to ring, the value of m should be 6.In the m item routing table of each node maintenance, the ident value of i-th record of routing table is equal to:
The successor ((ident value+2 of the nodei-1)mod2m),(1≤i≤m)。
Due to routing table have recorded with the ident value spacing of corresponding node at 2 power side's relationship ident value, the immediate successor node of each node is the first item of its routing table.For the ease of the corresponding ident value of endpoint value of following inquiry specified range, each node also safeguards the direct precursor node of itself simultaneously in node cycle.In the embodiment of the present application, due to routing table record ident value interval with exponential increase, the density of the density ratio distant-end node of the node closed on corresponding node recorded in routing table is big, so, below using routing table as the corresponding ident value of search index specified range during, if ident value of the endpoint value of specified range from present node is farther out, then farther node can be quickly jumped to according to the more sparse distant-end node that routing table records to be inquired, if the endpoint of specified range is closer from the ident value of present node, it then can more accurately be jumped on the node for be more nearly ident value and be inquired according to the more intensive node closed on that routing table records.Therefore, it is the routing table of node foundation by the embodiment of the present application, efficient range query can be carried out.
S220, the inquiry request that the keyword of specified range is directed in response to receiving, using any node in the node cycle as present node;
S230, the nearest ident value of the endpoint value away from the specified range is found out in the routing table of the present node.
If it is determined that S240, the ident value found are the nearest ident values of the endpoint value away from the specified range in the node cycle, using the ident value found as the corresponding ident value of the endpoint value of the specified range.
If it is determined that S250, the ident value found are not the nearest ident values of the endpoint value away from the specified range in the node cycle, present node is updated to node where the ident value found, back to the step of searching the nearest ident value of the endpoint value away from the specified range described in S230 in the routing table of present node.
In the following, the possible embodiment of the embodiment of the present application above-mentioned steps S220-S250 is described in detail in conjunction with the embodiment that the corresponding node of ident value sorts in node cycle by the sequence of ident value from small to large.For example, in this embodiment, the specified range can be first end point value to the range between the second endpoint value, wherein the first end point value may include: less than the second endpoint value, the possible query steps of S220-S250
It, can be using any node in node cycle as present node when receiving inquiry request.
Judge in the ident value of the routing table record of the present node with the presence or absence of the ident value equal with the first end point value.
If so, using and the equal ident value of the first end point value as ident value corresponding with the first end point value.
If not, judge the first end point value whether the present node ident value directly between the ident value of predecessor node or immediate successor node.It can be understood that, if endpoint value is in the ident value directly predecessor node or directly between the ident value of descendant node of the present node, then the ident value equal with endpoint value is not present in explanation in node cycle, can only present node, present node direct precursor node or immediate successor node in select the corresponding ident value of the endpoint value, can be specifically starting endpoint or the termination end points of range according to endpoint value to select.If endpoint value is not in the ident value of the present node directly predecessor node or directly between the ident value of descendant node, then illustrate that there may be the ident values equal with endpoint value for other positions in node cycle, the node that the ident value nearest away from the endpoint value recorded in the routing table of present node is identified can be then jumped to, continues to judge.
If the first end point value is in the ident value directly between the ident value of predecessor node of the present node, using the ident value of the present node as ident value corresponding with the first end point value.
If the first end point value is in the ident value directly between the ident value of descendant node of the present node, using the ident value of the immediate successor node of the present node as the corresponding ident value of the first end point value.
If the first end point value is not between the ident value of the present node directly ident value of descendant node, and not between the ident value of the present node directly ident value of predecessor node, the node that the ident value nearest away from the first end point value that then present node is updated to record in the routing table of the present node is identified, back to the step of whether there is the ident value equal with the first end point value in the ident value of the routing table record of above-mentioned judgement present node.
Judge in the ident value of the routing table record of the present node with the presence or absence of the ident value equal with second endpoint value.
If it is, using and the equal ident value of second endpoint value as ident value corresponding with second endpoint value.
If not, judge second endpoint value whether the present node ident value directly between the ident value of predecessor node or immediate successor node.
If second endpoint value is in the ident value directly between the ident value of predecessor node of the present node, using the ident value of the direct precursor node of the present node as the corresponding ident value of second endpoint value.
If second endpoint value is in the ident value directly between the ident value of descendant node of the present node, using the ident value of the present node as the corresponding ident value of second endpoint value.
If second endpoint value is not between the ident value of the present node directly ident value of descendant node, and not between the ident value of the present node directly ident value of predecessor node, the node then present node being updated to where the ident value nearest away from second endpoint value recorded in the routing table of the present node, back to the step of whether there is the ident value equal with second endpoint value in the ident value of the routing table record of the judgement present node.
It should be noted that the query steps for the corresponding ident value of first end point value and the corresponding ident value of the second endpoint value can be executed concurrently simultaneously, can also successively it execute, there is no restriction for the query steps execution sequences of different endpoint values for the embodiment of the present application.
In the following, node cycle as shown in connection with fig. 3, and above-mentioned query steps are schematically illustrated so that received inquiry request is the cache information inquired in 7 to 32 range of ident value as an example.It is understood that herein only for ease of understanding with numerical example, if the field value that can be used for range query is non-numeric type, the field value of nonnumeric type can be converted to the ident value of numeric type.For example, can determine that there is no the nodes that ident value is 7 in node cycle first from node 2s, according to endpoint value 7 between node 2 and the immediate successor node 8 of node 2.So the corresponding ident value of endpoint value 7 is 8.Then, from node 8s, according in the routing table of node 8 with the immediate node of node 32 be node 28, the routing table for jumping to node 28 is inquired, the routing table information of query node 28, according to being node 30 with 32 immediate nodes, the routing table for jumping to node 30 is inquired, according to 32 between node 30 directly descendant node 33, determine that there is no the nodes that ident value is 32 in node cycle.So 32 corresponding ident values are 30.To which according to node cycle as shown in Figure 3, finding out the ident value in specified range 7 to 32 includes: 8,10,16,21,28,30.Terminated as a result, using the ident value of the routing table lookup specified range 7 to 32 of link point.
S260, the corresponding set of keywords of the specified range is determined according to the corresponding ident value of endpoint value of specified range.
It can be seen that, using the embodiment, can the node cycle directly be read from memory, range query is carried out using the routing table of node cycle interior joint as index, it is detached from the dependence to database, reading speed is fast, and routing table record be in the node cycle with the ident value spacing of corresponding node at 2 power side's relationship ident value, therefore, during the corresponding ident value of the endpoint value according to routing table lookup specified range, it always jumps in the routing table for the node that the field value nearest away from endpoint value is identified and searches, finally find out the corresponding set of keywords of specified range, to make query process become the process of binary search, achieve the purpose that higher efficiency range is inquired.For example, by taking 100,000,000 nodes as an example, L=100,000,000, then the routing table item number that each node needs to safeguard is log2L=27, wherein any one node needs the hop count undergone to be up to logL=8 for inquiry, so, the performance of inquiry is very high.
In addition, the keyword of caching may be added or delete at any time for distributed cache system.At the same time, it in order to guarantee that node cycle and routing table are consistent with the keyword in caching, needs to update node cycle and routing table while keyword is added or deletes.Specifically, the embodiment of the present application can also include:
For the keyword being newly added in caching, judge whether the corresponding ident value of field value that can be used for range query in the keyword being newly added is present in the node cycle, if not, the ident value is stored in new node, the node N that can be used as the direct precursor node of new node is found out in the node cycle, the direct precursor node for updating the immediate successor node of the node N is the new node, the direct precursor node that the node N is the new node is updated, establishes corresponding routing table for the new node;
For the keyword deleted in caching, if the field value that can be used for range query in the field of the keyword of the deletion is not present in any other keyword, the node of the corresponding ident value of the field value will be stored as node to be deleted, the direct precursor node for updating the immediate successor node of node to be deleted is the direct precursor node of the node to be deleted, and the node to be deleted is deleted from the node cycle;
And according to preset Index Algorithm, the routing table for being influenced by the addition of the new node or being influenced by the deletion of the node to be deleted and need to update is updated.For example, can should be recorded respectively according to the routing table of each node with the field value spacing of corresponding node at 2 power side's relationship field value, the routing table for being influenced by the addition of the new node or being influenced by the deletion of node to be deleted and need to update is updated.
In the following, the update for how carrying out routing table is illustrated.Such as: it is equal to the successor ((ident value+2 of the node in conjunction with i-th field value of above-mentioned routing tablei-1)mod2m), the embodiment of (1≤i≤m) can be updated the routing table for being influenced to need to update by P addition by following steps if newly added node P in node cycle:
It is equal to the successor ((ident value+2 of the node according to i-th field valuei-1)mod2m), recurrence update is carried out to the information of the routing table record of the predecessor node of node P, until recurrence to predecessor node cannot meet two conditions of update simultaneously, recurrence terminates.Wherein described two conditions are as follows: condition one: the spacing of ident value is more than or equal to 2 between recurrence the predecessor node S arrived and node Pi-1.Because if node S is between node P less than 2 at a distance from ident valuei-1, then i-th one of node S routing table is scheduled on after node P, so routing table i-th does not need to update.Condition two: under the premise of the condition that meets one, the routing table of node S current i-th needs after node P.Because if the routing table information of node S i-th is before node P.Illustrate that P node is the node after current i-th, does not need to update routing table currentitem.
According to the judgement of above-mentioned two condition, the routing table information of the predecessor node of newly added node can be accurately updated along link point predetermined order sequence opposite direction recurrence.The update of routing table is influenced and identical to the principle of the update of routing table with above-mentioned by newly added node due to being influenced by deletion of node, details are not described herein.Because insertion or deletion of node, will not have an impact the routing table of the descendant node of present node, only will affect the predecessor node of present node.This requires each nodes other than needing to safeguard routing table information, it is also desirable to safeguard direct precursor node.In recurrence renewal process, if node S needs to update i-th of routing table, the direct precursor node of node S may also need to update routing table information, on the contrary, if node S does not need to update routing table information, the predecessor node of S does not need to update routing table information yet.Recurrence, which updates routing table information, to be terminated.
For example, along the routing table information of the link point counter clockwise direction recurrence more predecessor node of new node 30, from predecessor node 28, recurrence is updated to node 16 always as shown in figure 4, newly added node is node 30.As shown in figure 4, the 1st of 28 routing table of node, the 2nd is updated to 30 from 33.When arriving node 16 due to updating, do not meet two conditions for updating routing table simultaneously, there is no variations for the routing table information of node 16, therefore, terminate recurrence and update.
Corresponding with distributed caching range query method provided by the embodiments of the present application, the embodiment of the present application also provides a kind of distributed caching range query devices.
It is distributed caching range query apparatus structure schematic diagram provided by the embodiments of the present application for example, with reference to Fig. 5.As shown in figure 5, the apparatus may include:
Pretreatment unit 510 can be used for be used for can be used in the keyword of mapped cache data the corresponding ident value of field value of range query, be stored in advance in the storage region of memory;Inquiry response unit 520 can be used for be used for can be used in the keyword of mapped cache data the corresponding ident value of field value of range query, be stored in advance in the storage region of memory;Keyword acquiring unit 530 can be used for determining the corresponding set of keywords of the specified range according to the corresponding ident value of endpoint value of the specified range.
In some possible embodiments, the pretreatment unit 510, can be used for will be in the keyword, it can be used for the corresponding ident value of field value of range query, it is stored in advance in the node cycle of memory, wherein the corresponding storage of an ident value is into a node, and corresponding routing table is established for each node in the node cycle, the routing table has recorded the ident value of other the one or more nodes determined according to preset Index Algorithm.Correspondingly, referring to Fig. 6, the inquiry response unit 520 may include: to search subelement 521, it can be used for the inquiry request in response to receiving the keyword for being directed to specified range, using any node in the node cycle as present node, the nearest ident value of the endpoint value away from the specified range is searched in the routing table of the present node.First determines subelement 522, if it is determined that the ident value that can be used for finding is the nearest ident value of endpoint value away from the specified range in the node cycle, using the ident value found as the corresponding ident value of the endpoint value of the specified range.Second determines subelement 523, if it is determined that the ident value that can be used for finding is not the nearest ident value of the endpoint value away from the specified range in the node cycle, using the ident value found as present node, triggers the lookup subelement and search the nearest ident value of the endpoint value away from the specified range in the routing table of present node.
In conjunction with above embodiment, the pretreatment unit 510, can be used for will be in keyword, can be used for range query, belong to the corresponding ident value of the field value of same field and be stored in the node cycle of memory by ident value size order, wherein, the routing table have recorded in the node cycle with the field value spacing of corresponding node at 2 power side's relationship field value.
It is described in detail with the field value spacing of corresponding node at the embodiment of the field value of 2 power side's relationship in the following, being had recorded in the node cycle to the routing table.Assuming that sequence sequence of the node by ident value from small to large in the node cycle, the specified range is first end point value to the range between the second endpoint value, wherein the first end point value is less than second endpoint value.For the inquiry of the corresponding ident value of first end point value, subelement 521 is searched described in the embodiment of the present application, as shown in fig. 6, may include:
Set out subelement 5210, can be used for the inquiry request in response to receiving the keyword for being directed to specified range, using any node in the node cycle as present node.
First end point judgment sub-unit 5211 can be used for judging in the ident value of the routing table record of the present node with the presence or absence of the ident value equal with the first end point value.
First end point determines subelement 5212, if can be used for the first end point judgment sub-unit 5211 determines exist, using the ident value equal with the endpoint value as ident value nearest away from the first end point value in the node cycle.
First end point is continuous to sentence subelement 5213, is not present if can be used for the judgement of first end point judgment sub-unit 5211, judge the first end point value whether the present node ident value directly between the ident value of predecessor node or immediate successor node.
First end point continues stator unit 5214, if can be used for, the first end point is continuous to be sentenced subelement 5213 and determines the first end point value in the ident value directly between the ident value of predecessor node of the present node, using the ident value of the present node as ident value nearest away from the first end point value in the node cycle;Sentence subelement 5213 if the first end point is continuous and determine the first end point value in the ident value directly between the ident value of descendant node of the present node, using the ident value of the immediate successor node of the present node as ident value nearest away from the first end point value in the node cycle.
Wherein, described second determines subelement 523, if can be used for, the first end point is continuous to be sentenced subelement 5213 and determines the first end point value not between the ident value of the present node directly ident value of descendant node, and not between the ident value of the present node directly ident value of predecessor node, the node then present node being updated to where the ident value nearest away from the first end point value recorded in the routing table of the present node, first end point judgment sub-unit 5211 described in retriggered execute.
For the inquiry of the corresponding ident value of the second endpoint value, subelement 521 is searched described in the embodiment of the present application, as shown in fig. 6, can also include:
Second endpoint judgment sub-unit 5215 can be used for judging in the ident value of the routing table record of the present node with the presence or absence of the ident value equal with second endpoint value.
Second endpoint determines subelement 5216, if can be used for the second endpoint judgment sub-unit 5215 determines exist, using the ident value equal with the endpoint value as ident value nearest away from second endpoint value in the node cycle.
Second endpoint is continuous to sentence subelement 5217, is not present if can be used for the judgement of the second endpoint judgment sub-unit 5215, judge second endpoint value whether the present node ident value directly between the ident value of predecessor node or immediate successor node.
Second endpoint continues stator unit 5218, if can be used for, second endpoint is continuous to be sentenced subelement 5217 and determines second endpoint value in the ident value directly between the ident value of predecessor node of the present node, using the direct precursor node of the present node as ident value nearest away from second endpoint value in the node cycle;Sentence subelement 5217 if second endpoint is continuous and determine second endpoint value in the ident value directly between the ident value of descendant node of the present node, using the ident value of the present node as ident value nearest away from second endpoint value in the node cycle.
Wherein, described second determines subelement 523, if can be used for, second endpoint is continuous to be sentenced subelement 5217 and determines second endpoint value not between the ident value of the present node directly ident value of descendant node, and not between the ident value of the present node directly ident value of predecessor node, the node then present node being updated to where the ident value nearest away from second endpoint value recorded in the routing table of the present node, the second endpoint judgment sub-unit 5215 described in retriggered execute.
In the following, the embodiment of the present application is added in node cycle again or the specific embodiment of deletion of node is introduced.For example, with reference to Fig. 6, device provided by the embodiments of the present application can also include:
Node adding unit 540, it can be used for for the keyword being newly added in caching, judge whether the corresponding ident value of field value that can be used for range query in the keyword being newly added is present in the node cycle, if not, the ident value is stored in new node, the node N that can be used as the direct precursor node of new node is found out in the node cycle, the direct precursor node for updating the immediate successor node of the node N is the new node, the direct precursor node that the node N is the new node is updated, establishes corresponding routing table for the new node;
Knot removal unit 550, it can be used for for the keyword deleted in caching, if the field value that can be used for range query in the field of the keyword of the deletion is not present in any other keyword, the node of the corresponding ident value of the field value will be stored as node to be deleted, the direct precursor node for updating the immediate successor node of node to be deleted is the direct precursor node of the node to be deleted, and the node to be deleted is deleted from the node cycle;
And routing update unit 560, it can be used for being updated the routing table for being influenced by the addition of the new node or being influenced by the deletion of the node to be deleted and need to update according to preset Index Algorithm.
In the following, being schematically illustrated in conjunction with some possible application scenarios of the embodiment of the present invention.
For example, in some possible embodiments, according to consistent hashing rule, the kay-value information of each node can be stored in more cache servers of distributed cache system.In order to improve query performance, device provided by the embodiments of the present application can be configured in the independent query service device different from more cache servers of memory buffers data are used for.Correspondingly, the device can also include: data feedback unit 570, it can be used for after keyword acquiring unit obtains the corresponding set of keywords of specified range, it concurrently obtains that the set of keywords is corresponding data cached from the more cache servers by the downloading of multithreading, obtained data cached return to is issued into the client of the request.
It can be seen that, configure device provided by the embodiments of the present application, the node cycle directly can be read from memory by inquiry response unit 520, range query is carried out using the routing table of node cycle interior joint as index, it is detached from the dependence to database, reading speed is fast, and during the corresponding ident value of the endpoint value according to routing table lookup specified range, it always jumps in the routing table for the node that the field value nearest away from endpoint value is identified and searches, finally keyword acquiring unit 530 is allowed to find out the corresponding set of keywords of specified range, to make query process become the process of binary search, achieve the purpose that higher efficiency range is inquired.
It should be noted that, subelement 521 is searched described in the embodiment of the present application, first determines subelement 522, second determines subelement 523, set out subelement 5210, first end point judgment sub-unit 5211, first end point determines subelement 5212, first end point is continuous to sentence subelement 5213, first end point continues stator unit 5214, second endpoint judgment sub-unit 5215, second endpoint determines subelement 5216, second endpoint is continuous to sentence subelement 5217, second endpoint continues stator unit 5218, node adding unit 540, knot removal unit 550, routing update unit 560, and data feedback unit 570 is drawn with a dashed line in Fig. 6, it is the necessary unit of device provided by the embodiments of the present application to indicate these unit or sub-units not.
Corresponding with above-mentioned distributed caching range query method, the embodiment of the present application also provides a kind of distributed caching range query systems.
It is distributed caching range query system structure diagram provided by the embodiments of the present application for example, with reference to Fig. 7.As shown in fig. 7, the system may include:
Cache server 710, it can be used for storing and there is the data cached of mapping relations with keyword, receive the sending of query service device 720 is directed to the corresponding data cached inquiry request of set of keywords, and it is corresponding data cached to feed back set of keywords to query service device 720;
Query service device 720, it can be used for be used in the keyword of mapped cache data, it can be used for the corresponding ident value of field value of range query, it is stored in advance in the storage region of memory, in response to receiving the corresponding data cached inquiry request of keyword for specified range from client, the corresponding ident value of endpoint value of the specified range is found out from the storage region, the corresponding set of keywords of the specified range is determined according to the corresponding ident value of the endpoint value of the specified range, it is corresponding data cached that the set of keywords is obtained from the cache server, obtained data cached feed back to is issued into the client of the inquiry request;
Client 730 can be used for sending the corresponding data cached inquiry request of keyword for being directed to specified range to the query service device;Receive the data cached of query service device feedback.
For example, cache server 710 can have a platform or more.What the embodiment of the present application was established, which can be used for the different node cycles of range query and routing table, can be stored in the individual query service device 720.Such as, the query service device 720 can determine the node cycle for needing to read according to inquiry request, using any node in node cycle as present node, carry out subsequent query step, after obtaining the corresponding set of keywords of inquiry request, it can concurrently obtain that the set of keywords is corresponding data cached from one or more described cache server by the downloading of multithreading, obtained data cached return to is issued into the client of the request.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, the function of each unit can be realized in the same or multiple software and or hardware in carrying out the present invention.
As seen through the above description of the embodiments, those skilled in the art can be understood that the present invention can realize by means of software and necessary general hardware platform.Based on this understanding, substantially the part that contributes to existing technology can be embodied in the form of software products technical solution of the present invention in other words, the computer software product can store in storage medium, such as ROM/RAM, magnetic disk, CD, it uses including some instructions so that a computer equipment (can be personal computer, server or the network equipment etc.) execute method described in certain parts of each embodiment of the present invention or embodiment.
All the embodiments in this specification are described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments.For system embodiment, since it is substantially similar to the method embodiment, so being described relatively simple, the relevent part can refer to the partial explaination of embodiments of method.
The present invention can be used in numerous general or special purpose computing system environments or configuration.Such as: personal computer, server computer, handheld device or portable device, laptop device, multicomputer system, microprocessor-based system, set top box, programmable consumer-elcetronics devices, network PC, minicomputer, mainframe computer, the distributed computing environment including any of the above system or equipment etc..
The present invention can describe in the general context of computer-executable instructions executed by a computer, such as program module.Generally, program module includes routines performing specific tasks or implementing specific abstract data types, programs, objects, component, data structure etc..The present invention can also be practiced in a distributed computing environment, in these distributed computing environments, by executing task by the connected remote processing devices of communication network.In a distributed computing environment, program module can be located in the local and remote computer storage media including storage equipment.
It should be noted that, herein, relational terms such as first and second and the like are only used to distinguish one entity or operation from another entity or operation, and without necessarily requiring or implying between these entities or operation, there are any actual relationship or orders.And, the terms "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes those elements, it but also including other elements that are not explicitly listed, or further include for elements inherent to such a process, method, article, or device.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that there is also other identical elements in the process, method, article or apparatus that includes the element.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.Any modification, equivalent substitution, improvement and etc. done within the spirit and principles of the present invention, are included within the scope of protection of the present invention.