CN106407347A - Data caching method and apparatus - Google Patents
Data caching method and apparatus Download PDFInfo
- Publication number
- CN106407347A CN106407347A CN201610804195.4A CN201610804195A CN106407347A CN 106407347 A CN106407347 A CN 106407347A CN 201610804195 A CN201610804195 A CN 201610804195A CN 106407347 A CN106407347 A CN 106407347A
- Authority
- CN
- China
- Prior art keywords
- data
- value
- key
- caching
- preset time
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a data caching method and apparatus. The method comprises the steps of setting two key-value pairs corresponding to data in a cache for a piece of data; storing the data by the first key-value pair, and setting effective time of the data in the cache to be a first preset time; marking pre-failure time of the data by the second key-value pair, and setting the effective time of the data in the cache to be a second preset time, wherein the second preset time is shorter than the first preset time; when a data request is received, performing a search in the cache according to the data request; and if only the first key-value pair is found in the cache, returning a value in the first key-value pair to a requester, reading data of the request from a database again to update the value in the corresponding first key-value pair in the cache, and resetting the corresponding second key-value pair and the corresponding first preset time and second preset time. According to the scheme, the data in the cache can be ensured not to lose efficiency, and the data access speed can be ensured.
Description
Technical field
The present invention relates to field of computer technology is and in particular to a kind of data cached method and apparatus.
Background technology
Flourishing with the Internet, is required for storing the data of magnanimity in a lot of application scenarios.Reading from data base
When fetching data, because data base and visit capacity are all excessively huge, can lead to access the time delay of data, data is read in impact
Speed.Under normal circumstances, dsc data higher for access frequency can be put in caching, when receiving the request accessing dsc data
Directly it is read out from caching, considerably increase reading speed.
But, all there is an out-of-service time in the data in caching, once exceeding the out-of-service time, this data will automatically from
Delete in caching, need when the data after deletion is accessed again to re-read data from data base, therefore for some heat
For data, its access speed can decline, and this just has a strong impact on the speed accessing data, reduces Consumer's Experience.
Content of the invention
In view of the above problems it is proposed that the present invention so as to provide one kind overcome the problems referred to above or at least in part solve on
State the data cached method and apparatus of problem.
According to one aspect of the present invention, there is provided a kind of data cached method, including:
For a data, two key-value pair corresponding with this data are set in the buffer;Wherein, with the first key-value pair
Deposit this data itself, arranging its effective time in the buffer is the first Preset Time;With the second key-value to this data of labelling
The pre- out-of-service time, arrange its effective time in the buffer be the second Preset Time;Second Preset Time is less than first and presets
Time;
When receiving a request of data, the data corresponding two with request is searched in described caching according to this request of data
Individual key-value pair;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair, then by the first key-value centering
Value return to requesting party, the data re-reading this request from data base to update corresponding first key-value centering caching
Value, and reset corresponding second key-value to and corresponding first Preset Time and the second Preset Time.
Alternatively, the data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base
Rate is higher than the data of preset value.
Alternatively, the method further includes:
If finding the first key-value pair from caching, also find the second key-value pair, then by the first key-value centering
Value returns to requesting party, does not make other process.
Alternatively, the method further includes:
If not finding the first key-value pair from caching, obtain the data that this request of data is asked from data base
Return to requesting party.
Alternatively, described use the first key-value to depositing this data itself, with the pre- mistake to this data of labelling for second key-value
The effect time includes:
The value of the first key-value centering is set to this data itself;
The value of the second key-value centering is set to fixed value or arbitrary value.
Alternatively, corresponding for described first Preset Time time value and the corresponding time value of the second Preset Time are saved in
Specified location;
Arrange or reset the first Preset Time and second Preset Time of a data every time, read from described specified location
Corresponding time value is simultaneously configured or resets.
Alternatively, the method further includes:
Access frequency according to data and the size of caching, the adjustment corresponding time value of the first Preset Time and second pre-
If time corresponding time value.
According to a further aspect in the invention, there is provided a kind of data cached device, wherein, this device includes:
Caching process unit, is suitable to, for a data, arrange two key-value pair corresponding with this data in the buffer;
Wherein, with the first key-value to depositing this data itself, arranging its effective time in the buffer is the first Preset Time;With
The pre- out-of-service time to this data of labelling for two key-value, arranging its effective time in the buffer is the second Preset Time;Second is pre-
If the time is less than the first Preset Time;
Requesting processing, is suitable to when receiving a request of data, according to this request of data search in described caching with
Corresponding two key-value pair of data of request;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair
When, corresponding for first key value is returned to requesting party, and sends the first notice to caching process unit;
Described caching process unit, when being further adapted for receiving the first notice, re-reads the number of this request from data base
According to updating the value of corresponding first key-value centering in caching, and reset corresponding second key-value to and corresponding
One Preset Time and the second Preset Time.
Alternatively, the data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base
Rate is higher than the data of preset value.
Alternatively, described requesting processing, is further adapted for, when finding the first key-value pair from caching, also searching
During to the second key-value pair, the value of the first key-value centering is returned to requesting party, do not make other process.
Alternatively, described requesting processing, is further adapted for when not finding the first key-value pair from caching, then from number
Return to requesting party according to obtaining the data that this request of data asked in storehouse.
Alternatively, described caching process unit, is suitable to for the value of the first key-value centering to be set to this data itself, will
The value of the second key-value centering is set to fixed value or arbitrary value.
Alternatively, the corresponding time value of described first Preset Time and the corresponding time value of the second Preset Time are saved in finger
Positioning is put;
Described caching process unit, is suitable to preset in each the first Preset Time and second arranging or resetting a data
Time, read corresponding time value from described specified location and be configured or reset.
Alternatively, this device further includes:
Parameter adjustment unit, is suitable to access frequency according to data and the size of caching, adjusts the first Preset Time pair
The time value answered and the corresponding time value of the second Preset Time.
Technology according to the present invention scheme, arranges two key-value pair corresponding with this data when carrying out data buffer storage, the
One key-value is to depositing this data itself, and to arrange its effective time in the buffer be the first Preset Time, the second key-value pair
The pre- out-of-service time of this data of labelling, and its effective time in the buffer is the second Preset Time, the first Preset Time is big
In the second Preset Time, represent that the second key-value contrasts the first key-value pair and first lost efficacy.When accessing data, if two key-value pair
All it is searched, illustrate that this data temporarily will not lose efficacy, do not process;If looking only for a key-value pair, this data is described
Will lose efficacy, then, while this data being returned to requesting party, re-read this data from data base and reset inefficacy
Time.It can be seen that, the technical scheme is that while access with user, the out-of-service time of data in caching is examined
Look into, once check dsc data will lose efficacy, then again read from data base and arrange, thus ensureing that dsc data exists always
In caching, solve the problems, such as that in caching, dsc data lost efficacy, it is to avoid requestor accesses dsc data from data base, affect access speed
Situation.In sum, the present invention can guarantee that the data in caching did not lost efficacy, and ensures the access speed of data, strengthens user
Experience.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention,
And can be practiced according to the content of description, and in order to allow the above and other objects of the present invention, feature and advantage can
Become apparent, below especially exemplified by the specific embodiment of the present invention.
Brief description
By reading the detailed description of hereafter preferred implementation, various other advantages and benefit are common for this area
Technical staff will be clear from understanding.Accompanying drawing is only used for illustrating the purpose of preferred implementation, and is not considered as to the present invention
Restriction.And in whole accompanying drawing, it is denoted by the same reference numerals identical part.In the accompanying drawings:
Fig. 1 shows a kind of data cached method flow schematic diagram providing according to one embodiment of the invention;
Fig. 2 shows a kind of data cached schematic device providing according to one embodiment of the invention;
Fig. 3 shows a kind of data cached schematic device providing according to a further embodiment of the invention.
Specific embodiment
It is more fully described the exemplary embodiment of the disclosure below with reference to accompanying drawings.Although showing the disclosure in accompanying drawing
Exemplary embodiment it being understood, however, that may be realized in various forms the disclosure and should not be by embodiments set forth here
Limited.On the contrary, these embodiments are provided to be able to be best understood from the disclosure, and can be by the scope of the present disclosure
Complete conveys to those skilled in the art.
Fig. 1 shows a kind of data cached method flow schematic diagram providing according to one embodiment of the invention.As Fig. 1
Shown, the method includes:
Step S110, for a data, arranges two key-value pair corresponding with this data in the buffer;Wherein, use
To depositing this data itself, arrange its effective time in the buffer is the first Preset Time to one key-value;With the second key-value pair
The pre- out-of-service time of this data of labelling, arranging its effective time in the buffer is the second Preset Time;Second Preset Time is little
In the first Preset Time.
In this step, the meaning representated by key of the key of the first key-value centering and the second key-value centering is similar to, and refers both to
The key message of this data, user, in solicited message, is made a look up by the key message of data, because each data
Key message is all unique, so when user conducts interviews for a data, can only find to should data
One key-value to and the second key-value centering one or two.The content of the value storage of the first key-value centering is data originally
Body, then during user's request data, the final result of return is the content of the value storage of the first key-value centering;Because the second key-
Value to effect be this data of labelling the pre- out-of-service time, then the value of the second key-value centering does not need specific meaning.
Separately, the first Preset Time in this step and the second Preset Time are the base attribute of corresponding data, and first
Preset Time is more than the second Preset Time it is meant that the second key-value contrasts the first key-value reaches the out-of-service time to relatively early, takes the lead in
Lost efficacy, and be buffered and delete.Such as, the first Preset Time is 30ms, and the second Preset Time is 25ms.
So, in the step s 120, when receiving a request of data, searched in the buffer according to this request of data and ask
Corresponding two key-value pair of data;If postponing files for reference finding the first key-value pair, but not finding the second key-value pair, saying
Bright second key-value was to having lost efficacy, and illustrated to deposit this data the first key-value itself to also losing efficacy, then by the first key-value
The value of centering returns to requesting party, and the data re-reading this request from data base to update corresponding first key-value caching
The value of centering, and reset corresponding second key-value to and corresponding first Preset Time and the second Preset Time.
In this step, if looking only for the first key-value pair from caching, but do not find the second key-value pair, then explanation should
Data will lose efficacy, and needs the data re-reading this request from data base to update corresponding first key-value centering caching
Value, and reset corresponding second key-value to and corresponding first Preset Time and the second Preset Time, to avoid heat
Data lost efficacy in the buffer.In the example of step S110, find the first key-value pair if postponing and filing for reference, but do not find second
Key-value pair, then illustrate the second key-value to having lost efficacy, the storage time of this data is between 25ms to 30ms, this data pair
The first key-value answered will lose efficacy it is therefore desirable to from data base re-read this data to update corresponding first key caching-
Value centering value, and reset corresponding second key-value to and corresponding first Preset Time 30ms and second preset when
Between 25ms.Here renewal, is on the one hand that the data in caching is stored again;On the other hand, the data in data base is
In real-time change, then carrying out when re-reading of data, the value of the data after updating is stored in corresponding the in caching
The value of one key-value centering, also functions to an effect updating data in caching.Generally, user is by current time
Data access, even if data is subsequently updated, also will not be impacted.
Technology according to the present invention scheme, arranges two key-value pair corresponding with this data when carrying out data buffer storage, the
One key-value is to depositing this data itself, and to arrange its effective time in the buffer be the first Preset Time, the second key-value pair
The pre- out-of-service time of this data of labelling, and its effective time in the buffer is the second Preset Time, the first Preset Time is big
In the second Preset Time, represent that the second key-value contrasts the first key-value pair and first lost efficacy.When accessing data, if two key-value pair
All it is searched, illustrate that this data temporarily will not lose efficacy, do not process;If looking only for a key-value pair, this data is described
Will lose efficacy, then, while this data being returned to requesting party, re-read this data from data base and reset inefficacy
Time.It can be seen that, the technical scheme is that while access with user, the out-of-service time of data in caching is examined
Look into, once check dsc data will lose efficacy, then again read from data base and arrange, thus ensureing that dsc data exists always
In caching, solve the problems, such as that in caching, dsc data lost efficacy, it is to avoid requestor accesses dsc data from data base, affect access speed
Situation.
In one embodiment of the invention, the data preserving in the buffer is dsc data, sets a preset value first,
Dsc data mentioned here is the data that the accessed frequency in data base is higher than preset value, and this preset value is according to the size of caching
And the amount of dsc data is set, if the amount of dsc data is relatively more, then set the higher preset value of standard it is ensured that heat
Data enters caching.Because the limited storage space of caching, not all dsc data can enter caching, only access
The higher dsc data of frequency meter just can enter, and the higher dsc data of access frequency here can be entered by the first Preset Time
Row limits, and the first Preset Time of setting is short, then the interval of the access time of the dsc data limiting is short, and that is, access frequency is high.
In one embodiment of the invention, the method shown in Fig. 1 further includes:If finding first from caching
Key-value pair, also finds the second key-value pair, illustrate this data upper once be accessed when also will not lose efficacy, then only by first
The value of key-value centering returns to requesting party, does not make other process.
In one embodiment of the invention, the method shown in Fig. 1 further includes:If not finding first from caching
Key-value pair, then obtain the data that this request of data asked from data base and return to requesting party.Because the technical side of the present invention
Case can ensure that dsc data in the buffer, does not have Problem of Failure, if so not finding the first key-value pair from caching,
Then illustrate that the data asked is non-dsc data, then directly obtaining from data base that the data that this request of data asked returns to please
The side of asking.
In one embodiment of the invention, in step S110, with the first key-value to depositing this data itself, use second
Key-value included to the pre- out-of-service time of this data of labelling:The value of the first key-value centering is set to this data itself;By
The value of two key-value centerings is set to fixed value or arbitrary value, fixed value here or arbitrary value can for " null " it is also possible to
Meaning sets, but does not have in all senses, and when requestor carries out request of data, the returned data obtaining is the first key-value centering
Value, the second key-value carries out the detection of data failure time to being intended merely to matching program.For example, access a certain CLERICAL SUPPLIES business
Data base, its access frequency highest commodity be pencil and pen, then pencil and the corresponding inventory data of pen are put
Enter caching, during setting data, the data of corresponding pencil, then two key-value pair, respectively pencil -200 are set;Pencil EX-
“null”;The data of corresponding pen, then arrange two key-value pair, respectively pen -300;Pen EX- " 0 ".
For carrying out the setting of data or the convenience resetting every time, in one embodiment of the invention, first is preset
Time corresponding time value and the corresponding time value of the second Preset Time are saved in specified location;Arrange every time or reset a number
According to the first Preset Time and during the second Preset Time, read corresponding time value from specified location and be configured or reset.
Further, because the storage area of caching is limited, data the hottest should be stored in order in access efficiency caching,
I.e. access frequency highest data.But dsc data is not unalterable.Such as, 1000 data can only be stored in caching,
When initial, in order to put into 1000 the hottest data in caching, according to the minimum access in this 1000 the hottest data
Frequency setting first Preset Time is 30ms;But it is as the change of visit capacity, access frequency lid and described minimum access frequency
Data far beyond 1000, for example have 2000.Now also the first Preset Time is set to 30ms, caching can not
After changing, all of dsc data all stores wherein, and the hotter data newly increasing may not enter caching yet, can not protect
1000 currently hot data of card are in the buffer.In this regard, in one embodiment of the invention, in order to ensure data the hottest
Caching can be entered, on the one hand can reset preset value, to redefine dsc data;On the other hand, with the visit of dsc data
Ask frequency and the size of caching, the adjustment corresponding time value of the first Preset Time and the corresponding time value of the second Preset Time;Often
Secondary setting or the first Preset Time and the second Preset Time that reset a data, read corresponding time value simultaneously from specified location
It is configured or resets, if the access frequency of this data meets the first Preset Time after replacement, then this data is to access
The higher dsc data of frequency, can have been stored in caching, if the access frequency of this data do not meet after replacement first pre-
If the time, though then illustrating that this data is dsc data, access frequency does not have the height of other data, then will not be always in this data
It is stored in caching.
Fig. 2 shows a kind of data cached schematic device providing according to one embodiment of the invention.As Fig. 2 institute
Show, this data cached device 200 includes:
Caching process unit 210, is suitable to, for a data, arrange two key-value corresponding with this data in the buffer
Right;Wherein, with the first key-value to depositing this data itself, arranging its effective time in the buffer is the first Preset Time;With
The pre- out-of-service time to this data of labelling for second key-value, arranging its effective time in the buffer is the second Preset Time;Second
Preset Time is less than the first Preset Time;
Requesting processing 220, is suitable to, when receiving a request of data, be searched in the buffer according to this request of data and ask
Corresponding two key-value pair of data asked;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair
When, corresponding for first key value is returned to requesting party, and sends the first notice to caching process unit;
Described caching process unit 210, when being further adapted for receiving the first notice, re-reads this request from data base
Data updating the value of corresponding first key-value centering in caching, and reset corresponding second key-value to and corresponding
First Preset Time and the second Preset Time.
In one embodiment of the invention, the data preserving in the buffer is dsc data, and dsc data is in data base
Accessed frequency is higher than the data of preset value.
In one embodiment of the invention, requesting processing 220, are further adapted for find first from caching
Key-value pair, when also finding the second key-value pair, the value of the first key-value centering is returned to requesting party, does not make other process.
In one embodiment of the invention, requesting processing 220, are further adapted for not finding first from caching
Key-value pair, then obtain the data that this request of data asked from data base and return to requesting party.
In one embodiment of the invention, caching process unit 210, is suitable to be set to the value of the first key-value centering
This data itself, the value of the second key-value centering is set to fixed value or arbitrary value.
In one embodiment of the invention, when the corresponding time value of the first Preset Time and the second Preset Time are corresponding
Between value be saved in specified location.
Then caching process unit 210, is suitable to pre- in the first Preset Time of each setting or replacement one data and second
If the time, read corresponding time value from specified location and be configured or reset.
Fig. 3 shows a kind of data cached schematic device providing according to a further embodiment of the invention.This caching
The device 300 of data includes:Caching process unit 310, requesting processing 320 and parameter adjustment unit 230.Wherein, cache
The caching process unit 210 of processing unit 310, requesting processing 320 and Fig. 2 shown device, requesting processing 220 have
Corresponding identical function, identical part will not be described here.
Parameter adjustment unit 230, is suitable to access frequency according to data and the size of caching, adjusts the first Preset Time
Corresponding time value and the corresponding time value of the second Preset Time.
It should be noted that the corresponding phase of each embodiment of each embodiment of Fig. 2 and Fig. 3 shown device and method shown in Fig. 1
Same, it is described in detail above, will not be described here.
Technology according to the present invention scheme, arranges two key-value pair corresponding with this data when carrying out data buffer storage, the
One key-value is to depositing this data itself, and to arrange its effective time in the buffer be the first Preset Time, the second key-value pair
The pre- out-of-service time of this data of labelling, and its effective time in the buffer is the second Preset Time, the first Preset Time is big
In the second Preset Time, represent that the second key-value contrasts the first key-value pair and first lost efficacy.When accessing data, if two key-value pair
All it is searched, illustrate that this data temporarily will not lose efficacy, do not process;If looking only for a key-value pair, this data is described
Will lose efficacy, then, while this data being returned to requesting party, re-read this data from data base and reset inefficacy
Time.It can be seen that, the technical scheme is that while access with user, the out-of-service time of data in caching is examined
Look into, once check dsc data will lose efficacy, then again read from data base and arrange, thus ensureing that dsc data exists always
In caching, solve the problems, such as that in caching, dsc data lost efficacy, it is to avoid requestor accesses dsc data from data base, affect access speed
Situation.In sum, the present invention can guarantee that the data in caching did not lost efficacy it is ensured that the access speed of data, strengthens user's
Experience.
It should be noted that:
Algorithm and display be not inherently related to any certain computer, virtual bench or miscellaneous equipment provided herein.
Various fexible units can also be used together with based on teaching in this.As described above, construct required by this kind of device
Structure be obvious.Additionally, the present invention is also not for any certain programmed language.It is understood that, it is possible to use various
Programming language realizes the content of invention described herein, and the description above language-specific done is to disclose this
Bright preferred forms.
In description mentioned herein, illustrate a large amount of details.It is to be appreciated, however, that the enforcement of the present invention
Example can be put into practice in the case of not having these details.In some instances, known method, structure are not been shown in detail
And technology, so as not to obscure the understanding of this description.
Similarly it will be appreciated that in order to simplify the disclosure and help understand one or more of each inventive aspect,
Above in the description to the exemplary embodiment of the present invention, each feature of the present invention is grouped together into single enforcement sometimes
In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor
The application claims of shield more features than the feature being expressly recited in each claim.More precisely, it is such as following
Claims reflected as, inventive aspect is all features less than single embodiment disclosed above.Therefore,
The claims following specific embodiment are thus expressly incorporated in this specific embodiment, wherein each claim itself
All as the separate embodiments of the present invention.
Those skilled in the art are appreciated that and the module in the equipment in embodiment can be carried out adaptively
Change and they are arranged in one or more equipment different from this embodiment.Can be the module in embodiment or list
Unit or assembly be combined into a module or unit or assembly, and can be divided in addition multiple submodule or subelement or
Sub-component.In addition to such feature and/or at least some of process or unit exclude each other, can adopt any
Combination is to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed
Where method or all processes of equipment or unit are combined.Unless expressly stated otherwise, this specification (includes adjoint power
Profit requires, summary and accompanying drawing) disclosed in each feature can carry out generation by the alternative features providing identical, equivalent or similar purpose
Replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include other embodiments
In included some features rather than further feature, but the combination of the feature of different embodiment means to be in the present invention's
Within the scope of and form different embodiments.For example, in the following claims, embodiment required for protection appoint
One of meaning can in any combination mode using.
The all parts embodiment of the present invention can be realized with hardware, or to run on one or more processor
Software module realize, or with combinations thereof realize.It will be understood by those of skill in the art that can use in practice
Microprocessor or digital signal processor (DSP) are realizing some in data cached device according to embodiments of the present invention
Or some or all functions of whole parts.The present invention be also implemented as execute method as described herein one
Partly or completely equipment or program of device (for example, computer program and computer program).Such realization is originally
The program of invention can store on a computer-readable medium, or can have the form of one or more signal.So
Signal can download from internet website and obtain, or provide on carrier signal, or provided with any other form.
It should be noted that above-described embodiment the present invention will be described rather than limits the invention, and ability
Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims,
Any reference markss between bracket should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not
Element listed in the claims or step.Word "a" or "an" before element does not exclude the presence of multiple such
Element.The present invention can come real by means of the hardware including some different elements and by means of properly programmed computer
Existing.If in the unit claim listing equipment for drying, several in these devices can be by same hardware branch
To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame
Claim.
The invention provides A1, a kind of data cached method, including:
For a data, two key-value pair corresponding with this data are set in the buffer;Wherein, with the first key-value pair
Deposit this data itself, arranging its effective time in the buffer is the first Preset Time;With the second key-value to this data of labelling
The pre- out-of-service time, arrange its effective time in the buffer be the second Preset Time;Second Preset Time is less than first and presets
Time;
When receiving a request of data, the data corresponding two with request is searched in described caching according to this request of data
Individual key-value pair;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair, then by the first key-value centering
Value return to requesting party, the data re-reading this request from data base to update corresponding first key-value centering caching
Value, and reset corresponding second key-value to and corresponding first Preset Time and the second Preset Time.
A2, the method as described in A1, wherein,
The data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base is higher than pre-
If the data of value.
A3, the method as described in A1, wherein, the method further includes:
If finding the first key-value pair from caching, also find the second key-value pair, then by the first key-value centering
Value returns to requesting party, does not make other process.
A4, the method as described in A1, wherein, the method further includes:
If not finding the first key-value pair from caching, obtain the data that this request of data is asked from data base
Return to requesting party.
A5, the method as described in A1, wherein, described use the first key-value to depositing this data itself, with the second key-value pair
The pre- out-of-service time of this data of labelling includes:
The value of the first key-value centering is set to this data itself;
The value of the second key-value centering is set to fixed value or arbitrary value.
A6, the method as any one of A1-A5, wherein,
Corresponding for described first Preset Time time value and the corresponding time value of the second Preset Time are saved in specific bit
Put;
Arrange or reset the first Preset Time and second Preset Time of a data every time, read from described specified location
Corresponding time value is simultaneously configured or resets.
A7, the method as described in A6, wherein, the method further includes:
Access frequency according to data and the size of caching, the adjustment corresponding time value of the first Preset Time and second pre-
If time corresponding time value.
Present invention also offers B8, a kind of data cached device, wherein, this device includes:
Caching process unit, is suitable to, for a data, arrange two key-value pair corresponding with this data in the buffer;
Wherein, with the first key-value to depositing this data itself, arranging its effective time in the buffer is the first Preset Time;With
The pre- out-of-service time to this data of labelling for two key-value, arranging its effective time in the buffer is the second Preset Time;Second is pre-
If the time is less than the first Preset Time;
Requesting processing, is suitable to when receiving a request of data, according to this request of data search in described caching with
Corresponding two key-value pair of data of request;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair
When, corresponding for first key value is returned to requesting party, and sends the first notice to caching process unit;
Described caching process unit, when being further adapted for receiving the first notice, re-reads the number of this request from data base
According to updating the value of corresponding first key-value centering in caching, and reset corresponding second key-value to and corresponding
One Preset Time and the second Preset Time.
B9, the device as described in B8, wherein,
The data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base is higher than pre-
If the data of value.
B10, the device as described in B8, wherein,
Described requesting processing, is further adapted for, when finding the first key-value pair from caching, also finding second
During key-value pair, the value of the first key-value centering is returned to requesting party, do not make other process.
B11, the device as described in B8, wherein,
Described requesting processing, is further adapted for when not finding the first key-value pair from caching, then obtaining from data base
The data that this request of data is asked is taken to return to requesting party.
B12, the device as described in B8, wherein,
Described caching process unit, is suitable to for the value of the first key-value centering to be set to this data itself, by the second key-
The value of value centering is set to fixed value or arbitrary value.
B13, the device as any one of B8-B12, wherein, the corresponding time value of described first Preset Time and
The corresponding time value of two Preset Times is saved in specified location;
Described caching process unit, is suitable to preset in each the first Preset Time and second arranging or resetting a data
Time, read corresponding time value from described specified location and be configured or reset.
B14, the device as described in B13, wherein, this device further includes:
Parameter adjustment unit, is suitable to access frequency according to data and the size of caching, adjusts the first Preset Time pair
The time value answered and the corresponding time value of the second Preset Time.
Claims (10)
1. a kind of data cached method, including:
For a data, two key-value pair corresponding with this data are set in the buffer;Wherein, with the first key-value to depositing
This data itself, arranging its effective time in the buffer is the first Preset Time;Pre- to this data of labelling with the second key-value
Out-of-service time, arranging its effective time in the buffer is the second Preset Time;Second Preset Time is less than the first Preset Time;
When receiving a request of data, corresponding two of the data with request is searched in described caching according to this request of data
Key-value pair;If postponing files for reference finding the first key-value pair, but do not find the second key-value pair, then by the first key-value centering
Value returns to requesting party, and the data re-reading this request from data base to update corresponding first key-value centering caching
Value, and reset corresponding second key-value to and corresponding first Preset Time and the second Preset Time.
2. the method for claim 1, wherein
The data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base is higher than preset value
Data.
3. the method for claim 1, wherein the method further includes:
If finding the first key-value pair from caching, also finding the second key-value pair, then the value of the first key-value centering being returned
Back to requesting party, do not make other process.
4. the method for claim 1, wherein the method further includes:
If not finding the first key-value pair from caching, obtain the data return that this request of data is asked from data base
To requesting party.
The method of claim 1, wherein 5. described use the first key-value to depositing this data itself, use the second key-value
The pre- out-of-service time of this data of labelling is included:
The value of the first key-value centering is set to this data itself;
The value of the second key-value centering is set to fixed value or arbitrary value.
6. a kind of data cached device, wherein, this device includes:
Caching process unit, is suitable to, for a data, arrange two key-value pair corresponding with this data in the buffer;Wherein,
With the first key-value to depositing this data itself, arranging its effective time in the buffer is the first Preset Time;With the second key-
The pre- out-of-service time to this data of labelling for the value, arranging its effective time in the buffer is the second Preset Time;Second default when
Between be less than the first Preset Time;
Requesting processing, is suitable to, when receiving a request of data, be searched and request in described caching according to this request of data
Corresponding two key-value pair of data;If postponing files for reference finding the first key-value pair, but when not finding the second key-value pair,
Corresponding for first key value is returned to requesting party, and sends the first notice to caching process unit;
Described caching process unit, when being further adapted for receiving the first notice, the data re-reading this request from data base is come
Update the value of corresponding first key-value centering in caching, and reset corresponding second key-value to and corresponding first pre-
If time and the second Preset Time.
7. device as claimed in claim 6, wherein,
The data being saved in described caching is dsc data, and described dsc data is the accessed frequency in data base is higher than preset value
Data.
8. device as claimed in claim 6, wherein,
Described requesting processing, is further adapted for, when finding the first key-value pair from caching, also finding the second key-value
Pair when, the value of the first key-value centering is returned to requesting party, do not make other process.
9. device as claimed in claim 6, wherein,
Described requesting processing, is further adapted for when not finding the first key-value pair from caching, then obtaining from data base should
The data that request of data is asked returns to requesting party.
10. device as claimed in claim 6, wherein,
Described caching process unit, is suitable to for the value of the first key-value centering to be set to this data itself, by the second key-value pair
In value be set to fixed value or arbitrary value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610804195.4A CN106407347B (en) | 2016-09-05 | 2016-09-05 | A kind of data cached method and apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610804195.4A CN106407347B (en) | 2016-09-05 | 2016-09-05 | A kind of data cached method and apparatus |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106407347A true CN106407347A (en) | 2017-02-15 |
CN106407347B CN106407347B (en) | 2019-08-06 |
Family
ID=57998514
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610804195.4A Active CN106407347B (en) | 2016-09-05 | 2016-09-05 | A kind of data cached method and apparatus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106407347B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107291920A (en) * | 2017-06-28 | 2017-10-24 | 南京途牛科技有限公司 | A kind of air ticket query caching method |
CN110837513A (en) * | 2019-11-07 | 2020-02-25 | 腾讯科技(深圳)有限公司 | Cache updating method, device, server and storage medium |
WO2022041812A1 (en) * | 2020-08-28 | 2022-03-03 | 平安科技(深圳)有限公司 | Data processing method, related device and computer-readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103401950A (en) * | 2013-08-21 | 2013-11-20 | 网宿科技股份有限公司 | Cache asynchronism refreshment method, as well as method and system for processing requests by cache server |
CN104391862A (en) * | 2014-10-23 | 2015-03-04 | 北京锐安科技有限公司 | Method and device for updating cache data |
CN104657401A (en) * | 2014-10-21 | 2015-05-27 | 北京齐尔布莱特科技有限公司 | Web cache updating method |
CN105095282A (en) * | 2014-05-14 | 2015-11-25 | 腾讯科技(深圳)有限公司 | Method, device and system for updating cache data |
CN105608115A (en) * | 2015-12-11 | 2016-05-25 | 北京奇虎科技有限公司 | Data acquisition method and apparatus |
CN105630819A (en) * | 2014-11-03 | 2016-06-01 | 阿里巴巴集团控股有限公司 | Cached data refreshing method and apparatus |
-
2016
- 2016-09-05 CN CN201610804195.4A patent/CN106407347B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103401950A (en) * | 2013-08-21 | 2013-11-20 | 网宿科技股份有限公司 | Cache asynchronism refreshment method, as well as method and system for processing requests by cache server |
CN105095282A (en) * | 2014-05-14 | 2015-11-25 | 腾讯科技(深圳)有限公司 | Method, device and system for updating cache data |
CN104657401A (en) * | 2014-10-21 | 2015-05-27 | 北京齐尔布莱特科技有限公司 | Web cache updating method |
CN104391862A (en) * | 2014-10-23 | 2015-03-04 | 北京锐安科技有限公司 | Method and device for updating cache data |
CN105630819A (en) * | 2014-11-03 | 2016-06-01 | 阿里巴巴集团控股有限公司 | Cached data refreshing method and apparatus |
CN105608115A (en) * | 2015-12-11 | 2016-05-25 | 北京奇虎科技有限公司 | Data acquisition method and apparatus |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107291920A (en) * | 2017-06-28 | 2017-10-24 | 南京途牛科技有限公司 | A kind of air ticket query caching method |
CN107291920B (en) * | 2017-06-28 | 2021-02-02 | 南京途牛科技有限公司 | Air ticket query caching method |
CN110837513A (en) * | 2019-11-07 | 2020-02-25 | 腾讯科技(深圳)有限公司 | Cache updating method, device, server and storage medium |
CN110837513B (en) * | 2019-11-07 | 2023-05-12 | 腾讯科技(深圳)有限公司 | Cache updating method, device, server and storage medium |
WO2022041812A1 (en) * | 2020-08-28 | 2022-03-03 | 平安科技(深圳)有限公司 | Data processing method, related device and computer-readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN106407347B (en) | 2019-08-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107273522B (en) | Multi-application-oriented data storage system and data calling method | |
US9576006B2 (en) | Method and system for storing data in a database | |
US20180239800A1 (en) | Data query method and apparatus | |
CN104809179B (en) | The device and method for accessing Hash table | |
US9992298B2 (en) | Relationship-based WAN caching for object stores | |
CN108255958A (en) | Data query method, apparatus and storage medium | |
KR102575913B1 (en) | Asymmetric set combined cache | |
US10838963B2 (en) | Optimized access for hierarchical low cardinality value synopsis in analytical databases | |
US20140052726A1 (en) | Hardware implementation of the aggregation/group by operation: hash-table method | |
US10078649B2 (en) | Pre-caching of relational database management system based on data retrieval patterns | |
CN104216724B (en) | A kind of method and system of web application interface upgrade | |
US10282437B2 (en) | Partial indexes for partitioned tables | |
CN105677580A (en) | Method and device for accessing cache | |
CN104035923A (en) | Data inquiry method and device | |
CN105164653A (en) | Multi-core page table sets of attribute fields | |
US11409722B2 (en) | Database live reindex | |
CN106407347A (en) | Data caching method and apparatus | |
CN105468644B (en) | Method and equipment for querying in database | |
CN112148217B (en) | Method, device and medium for caching deduplication metadata of full flash memory system | |
CN107341114A (en) | A kind of method of directory management, Node Controller and system | |
CN104598652B (en) | A kind of data base query method and device | |
CN109408539B (en) | Data operation method, device, server and storage medium | |
CN106503260A (en) | A kind of method and apparatus of the effective memory space for improving data base | |
CN107133183A (en) | A kind of cache data access method and system based on TCMU Virtual Block Devices | |
US10599572B2 (en) | Method and device for optimization of data caching |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220715 Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015 Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park) Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Patentee before: Qizhi software (Beijing) Co.,Ltd. |