Specific embodiment
In order to make those skilled in the art better understand the technical solutions in the application, below in conjunction with the application reality
The attached drawing in example is applied, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described implementation
Example is merely a part but not all of the embodiments of the present application.Based on the embodiment in the application, this field is common
Technical staff's every other embodiment obtained without creative efforts, all should belong to protection of the present invention
Range.
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 lifted first
Example explanation.For example, the embodiment of the present application can be applied to one or more cache server for memory buffers data not
In same individual query service device.Wherein, the key being made of hotel ID and date value is saved in more cache servers
Word and data cached mapping.It can receive using the query service device of method provided by the embodiments of the present application and exist for hotel ID
The inquiry request of specified range obtains set of keywords corresponding with inquiry request.It is arrived for example, hotel ID can be inquired 7
Set of keywords in 32 ranges.
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.Such as
Shown in Fig. 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,
It is stored in advance in the storage region of memory.
For example, improving search efficiency in order to reduce the number of nodes in node cycle, all keywords being belonged to same
Duplicate part is rejected in the field value of field, and the different field value of same field is only stored in advance in a storage of memory
In region.
Wherein, the storage organization positioned at the storage region of memory is unlimited, for example, it may be single-track link table, array, closed chain
Table etc..For example, in some possible embodiments, it can be corresponding by the field value that in the keyword, can be used for range query
Ident value, be stored in advance in the node cycle (that is, cyclic annular chained list) of memory, wherein the corresponding storage of an ident value is arrived
In one node, and corresponding routing table is established for each node in the node cycle, the routing table has recorded according to pre-
Set the ident value for other one or more nodes that Index Algorithm determines.
In some possible embodiments, the preset Index Algorithm can be with are as follows: records node cycle with a routing table
In node corresponding with the routing table ident value spacing at 2 power side's relationship ident value.Correspondingly, step S110 is specific
Can be with are as follows: by keyword, can be used for range query, to belong to the corresponding ident value of the field value of same field big by ident value
It is small to be stored sequentially in the node cycle of memory, wherein the routing table have recorded in the node cycle with corresponding node
Ident value spacing at 2 power side's relationship ident value.Typically, due to can be used for the field of range query in data cached
The corresponding ident value of value is usually the value being not much different, in routing table the ident value spacing of record and a node at 2 power
The corresponding node of the ident value of square relationship can be convenient for subsequent lookup, improve search efficiency.
Certainly, preset Index Algorithm is not limited only to this one kind in embodiment above, can specifically be imitated according to actual queries
Rate needs are configured, and the application is to this and is not limited.For example, the preset Index Algorithm can be with are as follows: use routing table
To record the ident value, etc. that the ident value spacing of node corresponding with the routing table in node cycle is specified constant integer times.
It is understood that key (keyword) can be made of the different field of various fields, wherein can be used for range
The field of inquiry may include such as the fields such as number, date.It, then can be from each for example, if necessary to doing range query to the date
Date value is extracted in a keyword, being by the different date value corresponding conversions extracted can be according to preset Index Algorithm operation
Ident value.In conjunction with the embodiment of upper node ring, then ident value can be stored as in the form of chained list it is end to end,
The per diem node cycle of time value size order sequence.For example, original key is " 07 day 08 month-hotelId- of date-2014
18873 ", keyword embodies date and hotel id corresponding relationship, and the date " on 08 07th, 2014 " can be converted to ident value
140807.Wherein, be specially sequentially to sort from small to large by field value by the sequence of ident value size order, or from greatly to
Small sequence sequence.
S120, the inquiry request that the keyword of specified range is directed in response to receiving, are searched from the storage region
The corresponding ident value of the endpoint value of the specified range out.
For example, the pass of specified range can be directed in response to receiving in the embodiment that ident value is stored in node cycle
The inquiry request of key word, using any node in the node cycle as present node, in the routing table of the present node
Search the nearest ident value of the endpoint value away from the specified range.If it is determined that the ident value found be in the node cycle away from
The nearest ident value of the endpoint value of the specified range, it is corresponding using the ident value found as the endpoint value of the specified range
Ident value;If it is determined that the ident value found is not the nearest mark of the endpoint value away from the specified range in the node cycle
Knowledge value is then searched in the routing table of present node away from described back to described using the ident value found as present node
The step of endpoint value of specified range nearest ident value.
It is understood that specified range may include one or more specified ranges, endpoint value can be for for determining
The endpoint value in specified range section.For example, scheduled date range may include: on May 1,1 day to 2001 January in 2001, with
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,
There is no in the case where the ident value equal with the endpoint value, can be in node cycle in the specified range with the end
The nearest ident value of point value.
S130, the corresponding keyword of the specified range is determined according to the corresponding ident value of endpoint value of the specified range
Set.
For example, can be constructed in the specified range according to the corresponding ident value of endpoint value of the specified range
Keyword, obtain the corresponding set of keywords of the specified range.It specifically, for example, can be crucial for different type in advance
Corresponding key construction rule is arranged in word, and the type for the keyword inquired as needed is advised using corresponding key construction
Then, using the corresponding field value of ident value as input variable, corresponding keyword is constructed, obtains the corresponding key of inquiry request
Word set.Assuming that need to construct the keyword for embodying date and hotel id corresponding relationship, then it, can be according to key construction rule
The corresponding date field value of the ident value found out is spliced respectively from different hotel id, is obtained by preset difference hotel id
To complete keyword.It is, of course, also possible to the method for having other to determine keyword with ident value, those skilled in the art can root
It needs to be arranged according to actual implementation, details are not described herein.
For example, method provided by the embodiments of the present application can be applied to and memory buffers in some possible embodiments
In the different individual query service device of one or more cache server of data, the corresponding keyword of specified range is being obtained
After set, institute concurrently further can also be obtained from one or more described cache server by a multithreading downloading
It states that set of keywords is corresponding data cached, obtained data cached return to is issued into the client of the inquiry request.
As it can be seen that being asked using method provided by the embodiments of the present application receiving the inquiry for the keyword of specified range
After asking, from the inquiry of the corresponding ident value of endpoint value that the specified range is found out in the storage region can all including
Middle completion is deposited, without accessing database, realizes the range query with database decoupling.
In the following, to routing table be used to record in node cycle with the ident value spacing of corresponding node at 2 power side's relationship
The embodiment of ident value is described in detail.For example, the embodiment may include:
S210, by keyword, can be used for range query, belong to the corresponding ident value of the field value of same field by mark
Knowledge value size order is stored in advance in the node cycle of memory, wherein and an ident value is corresponding to be stored into a node,
And corresponding routing table is established for each node in the node cycle, wherein the routing table has 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, with
And when there is no spacing to be equal to 2i-1Ident value when, spacing is closest to 2i-1Node Identification.For example, some possible
In embodiment, in order to pull open suitable spacing as far as possible to improve search efficiency, spacing is closest to 2i-1Ident value can take between
Away from greater than 2i-1Ident value in, spacing is closest to 2i-1Ident value, wherein i is integer, and be more than or equal to 1, be less than or equal to institute
State the total that the maximum ident value of node cycle interior joint takes 2 logarithm to round up again.
For example, node cycle as shown in Figure 3, wherein the numbers such as 2,8,10,16 marked beside node are to save for identifying
The ident value of point.One m routing tables of each node maintenance in node cycle as shown in Figure 3.Wherein, ident value is with two
System is come if indicating, m is the digit of maximum binary identification value in node cycle.If L indicates the maximum section of ident value in ring
Point, then m is that L takes 2 logarithms to round up.That is:As shown in figure 3, need 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, often
The immediate successor node of a node is the first item of its routing table.Endpoint value for the ease of following inquiry specified range is corresponding
Ident value, each node also safeguards the direct precursor node of itself simultaneously in node cycle.In the embodiment of the present application, due to routing
The interval of the ident value of table record is with exponential increase, the density ratio distal end of the node closed on corresponding node recorded in routing table
The density of node is big, so, below using routing table as the corresponding ident value of search index specified range during, if specified
Farther out, then the more sparse distant-end node that can be recorded according to routing table is fast for ident value of the endpoint value of range from present node
Speed jumps to farther node and is inquired, can basis if the endpoint of specified range is closer from the ident value of present node
The more intensive node closed on of routing table record, which more accurately jumps on the node for be more nearly ident value, to be inquired.
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, with any in the node cycle
Node is as present node;
S230, the nearest mark of the endpoint value away from the specified range is found out in the routing table of the present node
Value.
If it is determined that S240, the ident value found are that the endpoint value away from the specified range in the node cycle is nearest
Ident value, 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 that the endpoint value away from the specified range in the node cycle is nearest
Ident value, present node is updated to node where the ident value found, back to the road described in S230 in present node
The step of by the nearest ident value of endpoint value of the lookup away from the specified range in table.
In the following, the embodiment party to sort in node cycle by the sequence of ident value from small to large in conjunction with the corresponding node of ident value
The possible embodiment of the embodiment of the present application above-mentioned steps S220-S250 is described in detail in formula.For example, in the embodiment party
In formula, the specified range can be first end point value to the range between the second endpoint value, wherein the first end point value is small
In the second endpoint value, the possible query steps of S220-S250 may include:
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 equal with the first end point value
Ident value.
If so, using and the equal ident value of the first end point value as mark corresponding with the first end point value
Value.
If not, judge the first end point value whether the present node ident value directly predecessor node or
Between the ident value of immediate successor node.It is understood that if endpoint value is straight with it in the ident value of the present node
It connects between predecessor node or the directly ident value of descendant node, then there is no equal with endpoint value in node cycle for explanation
Ident value, can only present node, present node direct precursor node or immediate successor node in select the endpoint value
Corresponding ident value can be specifically starting endpoint or the termination end points of range according to endpoint value to select.If endpoint value
Not in the ident value of the present node directly predecessor node or directly between the ident value of descendant node, then illustrate
There may be the ident values equal with endpoint value for other positions in node cycle, then can jump in the routing table of present node and record
The node that is identified of the ident value nearest away from the endpoint value, continue to judge.
If the first end point value in the ident value directly between the ident value of predecessor node of the present node,
Then using the ident value of the present node as ident value corresponding with the first end point value.
If 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 the corresponding ident value of the first end point value.
If the first end point value not the ident value of the present node directly descendant node ident value it
Between, and not between the ident value of the present node directly ident value of predecessor node, then more by the present node
The node newly identified by the ident value nearest away from the first end point value recorded in the routing table of the present node returns
It whether there is the ident value equal with the first end point value in the ident value recorded to the routing table of above-mentioned judgement present node
The step of.
Judge in the ident value of the routing table record of the present node with the presence or absence of equal with second endpoint value
Ident value.
If it is, using and the equal ident value of second endpoint value as mark corresponding with second endpoint value
Value.
If not, judge second endpoint value whether the present node ident value directly predecessor node or
Between the ident value of immediate successor node.
If second endpoint value in the ident value directly between the ident value of predecessor node of the present node,
Then 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 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 not the ident value of the present node directly descendant node ident value it
Between, and not between the ident value of the present node directly ident value of predecessor node, then more by the present node
It is newly the node where the ident value nearest away from second endpoint value that records in the routing table of the present node, returns to
With the presence or absence of the ident value equal with second endpoint value in the ident value of the routing table record of the judgement present node
Step.
It should be noted that looking into for the corresponding ident value of first end point value and the corresponding ident value of the second endpoint value
Asking step can concurrently execute simultaneously, can also successively execute, the embodiment of the present application is held for the query steps of different endpoint values
There is no restriction for row sequence.
It in the following, node cycle as shown in connection with fig. 3, and with received inquiry request is inquiry 7 to 32 range of ident value
Above-mentioned query steps are schematically illustrated for interior cache information.It is understood that being only with numerical example herein
It is easy to understand, if the field value that can be used for range query is non-numeric type, the field value of nonnumeric type can be turned
It is changed to the ident value of numeric type.For example, can be first from node 2s, according to endpoint value 7 in the direct of node 2 and node 2
Between descendant node 8, determine that there is no the nodes that ident value is 7 in node cycle.So the corresponding ident value of endpoint value 7 is 8.So
Afterwards, from node 8s, according to the immediate node of node 32 being node 28 in the routing table of node 8, the road of node 28 is jumped to
It is inquired by table, the routing table information of query node 28, according to being node 30 with 32 immediate nodes, jumps to node 30
Routing table is inquired, and according to 32 between node 30 directly descendant node 33, determines that there is no marks in node cycle
The node that value is 32.So 32 corresponding ident values are 30.To find out specified range according to node cycle as shown in Figure 3
Ident value in 7 to 32 includes: 8,10,16,21,28,30.The routing table lookup specified range 7 to 32 of link point is utilized as a result,
Ident value terminate.
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 closes.
As it can be seen that directly the node cycle can be read from memory using the embodiment, made with the routing table of node cycle interior joint
Range query is carried out for index, disengaging is fast to the dependence of database, reading speed, and routing table record is in the node cycle
With the ident value spacing of corresponding node at 2 power side's relationship ident value, therefore, according to routing table lookup specified range
During the corresponding ident value of endpoint value, always jump in the routing table for the node that the field value nearest away from endpoint value is identified
It searches, finally finds out the corresponding set of keywords of specified range, so that query process be made to become the process of binary search, reach
The purpose inquired to higher efficiency range.For example, by taking 100,000,000 nodes as an example, L=100,000,000, then each node needs to tie up
The routing table item number of shield is log2L=27, wherein any one node needs the hop count undergone to be up to logL=8 for inquiry, institute
With 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.With
This in order to guarantee that node cycle and routing table are consistent with the keyword in caching, needs to be added or delete in keyword simultaneously
Meanwhile updating node cycle and routing table.Specifically, the embodiment of the present application can also include:
For the keyword being newly added in caching, the field value pair that can be used for range query in the keyword being newly added is judged
Whether the ident value answered is present in the node cycle, if not, the ident value is stored in new node, in the node
The node N that can be used as the direct precursor node of new node is found out in ring, updates the direct of the immediate successor node of the node N
Predecessor node is the new node, updates the direct precursor node that the node N is the new node, establishes for the new node
Corresponding routing table;
For the keyword deleted in caching, if can be used for the word of range query in the field of the keyword of the deletion
Segment value is not present in any other keyword, will store the node of the corresponding ident value of the field value as section to be deleted
Point, 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,
The node to be deleted is deleted from the node cycle;
And according to preset Index Algorithm, on being influenced by the addition of the new node or deleted by the node to be deleted
The routing table for needing to update except influence is updated.For example, can should be recorded respectively according to the routing table of each node with it is right
Answer the field value spacing of node at 2 power side's relationship field value, on being influenced by the addition of the new node or by be deleted
The deletion of node influences and the routing table updated is needed to be updated.
In the following, the update for how carrying out routing table is illustrated.Such as: in conjunction with i-th of above-mentioned routing table
Field value is equal to the successor ((ident value+2 of the nodei-1)mod2m), the embodiment of (1≤i≤m), if node cycle
Middle newly added node P can then be updated the routing table for being influenced to need to update by P addition by following steps:
According to i-th field value be equal to successor ((ident value of the node+2i-1)mod2m), before node P
Drive node routing table record information carry out recurrence update, until recurrence to predecessor node cannot meet the two of update simultaneously
A condition, recurrence terminate.Wherein described two conditions are as follows: condition one: ident value between recurrence the predecessor node S arrived and node P
Spacing be more than or equal to 2i-1.Because if node S is between node P less than 2 at a distance from ident valuei-1, then node S routing table
I-th one 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, section
The routing table of point S current i-th needs after node P.Because if the routing table information of node S i-th node P it
Before.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, can accurately be updated along link point predetermined order sequence opposite direction recurrence
The routing table information of the predecessor node of newly added node.Due to being influenced by deletion of node to the update of routing table with above-mentioned by new
The influence of node is added and identical to the principle of the update of routing table, details are not described herein.Because of insertion or deletion of node, no
The routing table of the descendant node of present node can be had an impact, only will affect the predecessor node of present node.This requires every
A node is other than needing to safeguard routing table information, it is also desirable to safeguard direct precursor node.In recurrence renewal process, if section
Point S needs to update i-th of routing table, then the direct precursor node of node S may also need to update routing table information, instead
It, 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 updates
Routing table information terminates.
For example, as shown in figure 4, newly added node is node 30, along link point counter clockwise direction recurrence more new node 30
The routing table information of predecessor node, from predecessor node 28, recurrence is updated to node 16 always.As shown in figure 4,28 routing table of node
The 1st, 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.
It is 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 device.
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.Such as
Shown in Fig. 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 word of range query
The corresponding ident value of segment value, is stored in advance in the storage region of memory;Inquiry response unit 520 can be used for be used for reflecting
It penetrates in data cached keyword, can be used for the corresponding ident value of field value of range query, be stored in advance in the storage of memory
In region;Keyword acquiring unit 530 can be used for according to the corresponding ident value determination of the endpoint value of the specified range
The corresponding set of keywords of specified range.
In some possible embodiments, the pretreatment unit 510 can be used for can be used in the keyword
The corresponding ident value of the field value of range query, is stored in advance in the node cycle of memory, wherein an ident value is corresponding
It stores into a node, and establishes corresponding routing table for each node in the node cycle, the routing table has recorded
According to the ident value for other one or more nodes that preset Index Algorithm determines.Correspondingly, referring to Fig. 6, the inquiry response
Unit 520 may include: to search subelement 521, can be used for the inquiry in response to receiving the keyword for being directed to specified range
Request is searched in the routing table of the present node away from described using any node in the node cycle as present node
The nearest ident value of the endpoint value of specified range.First determines subelement 522, if it is determined that the ident value that can be used for finding
It is the nearest ident value of endpoint value away from the specified range in the node cycle, using the ident value found as described specified
The corresponding ident value of the endpoint value of 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 endpoint value away from the specified range in the node cycle, using the ident value found as present node,
It triggers the lookup subelement and searches 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, which in keyword, will can be used for range, is looked into
Ask, the corresponding ident value of field value that belong to same field is stored in the node cycle positioned at memory by ident value size order
In, wherein the routing table have recorded in the node cycle with the field value spacing of corresponding node at 2 power side's relationship word
Segment value.
In the following, to the routing table have recorded in the node cycle with the field value spacing of corresponding node at 2 power side
The embodiment of the field value of relationship is described in detail.Assuming that node in the node cycle is by ident value from small to large suitable
Sequence sequence, the specified range are 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 is searched described in the embodiment of the present application
521, 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, with
Any node in the node cycle is as present node.
First end point judgment sub-unit 5211 can be used for judging in the ident value of 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, deposits if can be used for the judgement of first end point judgment sub-unit 5211
Then 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, does not deposit 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 predecessor node or immediate successor node
Ident value between.
First end point continues stator unit 5214, if can be used for the first end point it is continuous sentence subelement 5213 determine it is described
First end point value the present node ident value directly between the ident value of predecessor node, then by the present node
Ident value as ident value nearest away from the first end point value in the node cycle;If the first end point is continuous to sentence sub- list
Member 5213 determine the first end point value in the ident value directly between the ident value of descendant node of the present node, then
Using the ident value of the immediate successor node of the present node as mark nearest away from the first end point value in the node cycle
Knowledge value.
Wherein, described second determines subelement 523, if can be used for, the first end point is continuous to sentence the judgement of subelement 5213
The first end point value is not between the ident value of the present node directly ident value of descendant node, and not described
The ident value of present node is directly between the ident value of predecessor node, then is updated to the present node described work as prosthomere
Node in the routing table of point where the ident value nearest away from the first end point value that records, first end point described in retriggered
Judgment sub-unit 5211 executes.
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, such as Fig. 6
It is shown, can also include:
Second endpoint judgment sub-unit 5215 can be used for judging in the ident value of 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, deposits if can be used for the judgement of the second endpoint judgment sub-unit 5215
Then 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, does not deposit 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 predecessor node or immediate successor node
Ident value between.
Second endpoint continues stator unit 5218, if can be used for second endpoint it is continuous sentence subelement 5217 determine it is described
Second endpoint value the present node ident value directly between the ident value of predecessor node, then by the present node
Direct precursor node as ident value nearest away from second endpoint value in the node cycle;If second endpoint is continuous
Sentencing subelement 5217 determines second endpoint value in the ident value of the ident value directly descendant node of the present node
Between, then 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 sentence the judgement of subelement 5217
Second endpoint value is not between the ident value of the present node directly ident value of descendant node, and not described
The ident value of present node is directly between the ident value of predecessor node, then is updated to the present node described work as prosthomere
Node in the routing table of point where the ident value nearest away from second endpoint value that records, the second endpoint described in retriggered
Judgment sub-unit 5215 executes.
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 can be used for judging in the keyword being newly added for the keyword being newly added in caching
Whether the corresponding ident value of field value that can be used for range query is present in the node cycle, if not, by the ident value
It is stored in new node, finds out the node N that can be used as the direct precursor node of new node in the node cycle, described in update
The direct precursor node of the immediate successor node of node N is the new node, and updating the node N is the direct of the new node
Predecessor node establishes corresponding routing table for the new node;
Knot removal unit 550 can be used for for the keyword deleted in caching, if the keyword of the deletion
The field value that can be used for range query in field is not present in any other keyword, will store the corresponding mark of the field value
For the node of knowledge value as node to be deleted, updating the direct precursor node of the immediate successor node of node to be deleted is described wait delete
Except the direct precursor node of node, the node to be deleted is deleted from the node cycle;
And routing update unit 560, it can be used for according to preset Index Algorithm, to the addition shadow by the new node
The routing table rung or influenced by the deletion of the node to be deleted and need to update is updated.
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, it, can be in the more of distributed cache system according to consistent hashing rule
Platform cache server is stored with the kay-value information of each node.It is provided by the embodiments of the present application in order to improve query performance
Device can be configured in the independent query service device different from more cache servers of memory buffers data are used for.Accordingly
Ground, the device can also include: data feedback unit 570, can be used for obtaining specified range in keyword acquiring unit corresponding
Set of keywords after, the set of keywords is concurrently obtained from the more cache servers by the downloading of multithreading
It closes corresponding data cached, obtained data cached return to is issued into the client of the request.
As it can be seen that configuring device provided by the embodiments of the present application, can directly be read from memory by inquiry response unit 520 should
Node cycle carries out range query using the routing table of node cycle interior joint as index, is detached from dependence to database, reading speed
Fastly, it and during the corresponding ident value of the endpoint value according to routing table lookup specified range, always jumps to away from endpoint value most
It is searched in the routing table for the node that close field value is identified, keyword acquiring unit 530 is finally allowed to find out finger
Determine the corresponding set of keywords of range, so that query process be made to become the process of binary search, reaches the mesh of higher efficiency range inquiry
's.
It should be noted that lookup subelement 521 described in the embodiment of the present application, first determines that subelement 522, second determines
Subelement 523, the subelement 5210 that sets out, first end point judgment sub-unit 5211, first end point determine subelement 5212, first end
Point is continuous to sentence the continuous stator unit 5214 of subelement 5213, first end point, the second endpoint judgment sub-unit 5215, the determining son of the second endpoint
Unit 5216, the second endpoint be continuous to sentence subelement 5217, the second endpoint continues stator unit 5218, node adding unit 540, node and deletes
Except unit 550, routing update unit 560 and data feedback unit 570 are drawn with a dashed line in Fig. 6, to indicate these units
Or subelement is not the necessary unit of device provided by the embodiments of the present application.
Corresponding with above-mentioned distributed caching range query method, the embodiment of the present application also provides a kind of distributed slow
Deposit range query system.
It is distributed caching range query system structure diagram provided by the embodiments of the present application for example, with reference to Fig. 7.Such as
Shown in Fig. 7, which may include:
Cache server 710, can be used for storing has the data cached of mapping relations with keyword, receives query service
What device 720 issued is directed to the corresponding data cached inquiry request of set of keywords, feeds back set of keywords to query service device 720
It closes corresponding data cached;
Query service device 720 can be used for be used for can be used in the keyword of mapped cache data the word of range query
The corresponding ident value of segment value, is stored in advance in the storage region of memory, in response to receiving from client for specified range
The corresponding data cached inquiry request of keyword, the endpoint value pair of the specified range is found out from the storage region
The ident value answered determines the corresponding set of keywords of the specified range according to the corresponding ident value of the endpoint value of the specified range
It closes, obtains that the set of keywords is corresponding data cached from the cache server, data cached fed back to what is obtained
Issue the client of the inquiry request;
Client 730 can be used for sending the corresponding caching of keyword for being directed to specified range to the query service device
The inquiry request of data;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 range, looks into
The different node cycles and routing table of inquiry can be stored in the individual query service device 720.For example, 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, after progress
Continuous query steps can be by a multithreading downloading concurrently from institute after obtaining the corresponding set of keywords of inquiry request
State the data cached return for obtaining that the set of keywords is corresponding data cached, will obtain in one or more cache server
To the client for issuing the request.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit can be realized in the same or multiple software and or hardware when invention.
As seen through the above description of the embodiments, those skilled in the art can be understood that the present invention can
It realizes by means of software and necessary general hardware platform.Based on this understanding, technical solution of the present invention essence
On in other words the part that contributes to existing technology can be embodied in the form of software products, the computer software product
It can store in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are used so that a computer equipment
(can be personal computer, server or the network equipment etc.) executes the certain of each embodiment or embodiment of the invention
Method described in part.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so being described relatively simple, related place is referring to embodiment of the method
Part explanation.
The present invention can be used in numerous general or special purpose computing system environments or configuration.Such as: personal computer, service
Device computer, handheld device or portable device, laptop device, multicomputer system, microprocessor-based system, top set
Box, programmable consumer-elcetronics devices, network PC, minicomputer, mainframe computer, including any of the above system or equipment
Distributed computing environment 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, group
Part, data structure etc..The present invention can also be practiced in a distributed computing environment, in these distributed computing environments, by
Task is executed by the connected remote processing devices of communication network.In a distributed computing environment, program module can be with
In the local and remote computer storage media including storage equipment.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to
Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.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 process, method, article or equipment including 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.It is all
Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention
It is interior.