Summary of the invention
Based on this, this specification embodiment provides data buffer storage and caching disaster recovery method and system, caching system.
According to this specification embodiment in a first aspect, providing a kind of data cache method, which comprises receiving
To operation system send service data request when, business datum is searched in caching system;If finding, the business is obtained
The logical validity phase of data;Wherein, the logical validity phase is the term of validity that the business datum corresponds to business;If described
The logical validity phase is already expired, and by the business datum from being distally cached to the caching system, and the business datum is being cached
Physics validity period in system is set as permanent effective.
Optionally, the method also includes: if not finding the business datum in caching system, by the business number
According to from being distally cached to the caching system.
Optionally, the method also includes: if not finding the business datum in caching system, getting caching
After data lock, the business datum is searched in caching system again, if not finding the business datum yet, by the industry
Business data are from being distally cached to the caching system.
Optionally, the method also includes: if obtaining data cached lock time-out, end process.
Optionally, by the business datum from including: by significance level height the step of being distally cached to the caching system
The first business datum second business datum low with significance level cached respectively into the caching system it is mutually isolated not
With in region.
Optionally, by the business datum before being distally cached to the caching system, the method also includes: if
The cache unit for storing the second business datum has been expired, and evicts longest second business datum of cache-time from caching.
Optionally, the method also includes: the business datum in caching system is back to operation system.
Optionally, the method also includes: if the logical validity phase is already expired, judge in the service data request whether
Carry data cached lock;If so, returning the business datum from the step of being distally cached to the caching system.
Optionally, the method also includes: if the logical validity phase non-mistake, the business that will be found in caching system
Data are back to operation system.
Optionally, physics validity period of the business datum in caching system is permanent effective.
According to the second aspect of this specification embodiment, a kind of caching disaster recovery method is provided, which comprises if distal end
Business datum obtains time-out, and business datum is searched in caching system;The business datum found is sent to operation system;Its
In, the business datum is cached according to the data cache method of any embodiment to the caching system.
According to the third aspect of this specification embodiment, a kind of data buffer storage device is provided, described device includes: first to look into
Module is looked for, for searching business datum in caching system when receiving the service data request of operation system transmission;First
Module is obtained, if obtaining the logical validity phase of the business datum for finding;Wherein, the logical validity phase is described
Business datum corresponds to the term of validity of business;First cache module, if being already expired for the logical validity phase, by the business
Physics validity period of the business datum in caching system is set as permanent from being distally cached to the caching system by data
Effectively.
Optionally, described device further include: the second cache module, if for not finding the business in caching system
Data, by the business datum from being distally cached to the caching system.
Optionally, described device further include: third searching module, for existing after getting data cached lock again
The business datum is searched in caching system;Third cache module, for not finding the business yet in third searching module
When data, by the business datum from being distally cached to the caching system.
Optionally, described device further include: waiting-timeout module, if terminating process for obtaining data cached lock time-out.
Optionally, the first cache module includes: cache unit, for by the first high business datum of significance level with it is important
The second low business datum of degree is cached respectively in the different zones mutually isolated into the caching system.
Optionally, described device further include: data evict module from, if the cache unit for storing the second business datum is
It is full, evict longest second business datum of cache-time from caching.
Optionally, described device further include: the first sending module, for the business datum in caching system to be back to industry
Business system.
Optionally, described device further include: judgment module judges the business if being already expired for the logical validity phase
Whether data cached lock is carried in request of data;If so, returning to the function of executing the first cache module.
Optionally, described device further include: the second sending module will cache if being used for the logical validity phase non-mistake
The business datum found in system is back to operation system.
Optionally, physics validity period of the business datum in caching system is permanent effective.
According to the fourth aspect of this specification embodiment, a kind of caching disaster tolerance device is provided, described device includes: second to look into
Module is looked for, if obtaining time-out for distal end business datum, business datum is searched in caching system;Sending module, for that will look into
The business datum found is sent to operation system;Wherein, the business datum is slow according to the data cache method of any embodiment
It deposits to the caching system.
According to the 5th of this specification embodiment the aspect, a kind of computer readable storage medium is provided, meter is stored thereon with
Calculation machine program, which is characterized in that the method for any embodiment is realized when the program is executed by processor.
According to the 6th of this specification embodiment the aspect, a kind of caching system, including memory, processor and storage are provided
On a memory and the computer program that can run on a processor, which is characterized in that when the processor executes described program
The method for realizing any embodiment.
Optionally, the caching system includes general caching unit and white list cache unit;The white list caching is single
Member is for storing the first high business datum of significance level, and the general caching unit is for storing the second low industry of significance level
Business data;Wherein, the second business datum cached at first is evicted from caching when the general caching unit is filled with.
Using this specification example scheme, on the one hand the physics validity period by business datum in caching system is set as forever
Long effectively, so that there is the business datum revealed all the details for realizing caching in caching system, always to realize caching disaster tolerance;It is another
To newest business datum is distally requested when business datum logic of the aspect in caching system is expired, to guarantee available
In the case where remote data, the business datum that operation system is got is the business datum within the logical validity phase.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
This specification embodiment can be limited.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with this specification embodiment.On the contrary, they are only
The example of the device and method consistent with some aspects as detailed in the attached claim, this specification embodiment
Son.
It is only to be not intended to be limiting merely for for the purpose of describing particular embodiments in the term that this specification embodiment uses
This specification embodiment.In this specification embodiment and the "an" of singular used in the attached claims, " institute
State " and "the" be also intended to including most forms, unless the context clearly indicates other meaning.It is also understood that making herein
Term "and/or" refers to and may combine comprising one or more associated any or all of project listed.
It will be appreciated that though various letters may be described using term first, second, third, etc. in this specification embodiment
Breath, but these information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example,
In the case where not departing from this specification scope of embodiments, the first information can also be referred to as the second information, similarly, the second letter
Breath can also be referred to as the first information.Depending on context, word as used in this " if " can be construed to
" ... when " or " when ... " or " in response to determination ".
As shown in Figure 1, being the distal end of this specification one embodiment and the schematic diagram that proximal end interacts.Wherein, proximal end
102 can be communicated with distal end 104, to obtain required data from distal end 104.It may include for executing industry in proximal end 102
The operation system 102a and caching system 102b of business, wherein operation system 102a can be long-range according to getting from distal end 104
The corresponding business of data run, meanwhile, in order to promote the efficiency of whole system, reduce with the data interaction between distal end 104, closely
End 102 can also store data in caching system 102b after getting teledata.Caching system 102b can be
Same proceeding internal memory, striding course memory, with the memory of physical machine different virtual machine, be also possible to the storage mediums such as hard disk.In reality
Under certain scenes of application, the high availability of guarantee business is generally required.For example, gateway is to slow for Alipay gateway scene
Configuration data dependence in deposit system 102b is stronger, if the data cached failure in caching system 102b, back-end services are again
Configuration data can not be got, it will lead to the failure of entire service link, this scene needs cache it is highly usable, even if
Back-end server goes wrong, and caching system 102b still can guarantee that business is available, and gateway arrives the dependence reduction of data
It is minimum.
Based on this, this specification embodiment provides a kind of data cache method.As shown in Fig. 2, the method can include:
Step 202: when receiving the service data request of operation system transmission, business number is searched in caching system
According to;
Step 204: if finding, obtaining the logical validity phase of the business datum;Wherein, the logical validity phase is institute
State the term of validity that business datum corresponds to business;
Step 206: if the logical validity phase is already expired, by the business datum from being distally cached to the caching system,
And physics validity period of the business datum in caching system is set as permanent effective.
In step 204, the logical validity phase of business datum refers to that the business datum needed for executing a certain business is opposite
In the term of validity of the business.After the logical validity phase, business datum is considered as stale data for the business, but
In order to be able to achieve caching disaster tolerance, still expired business datum can be stored in caching system, without stale data is deleted,
To realize that caching is revealed all the details.Therefore, the logical validity phase can be regarded as the term of validity of business datum.Physics has in contrast
The time limit that effect phase, i.e. business datum save in caching system.Business datum more than physics validity period will be expelled out of caching.
The logical validity phase of business datum can preset, for example, being set as 1 hour.It can be arranged for caching system
One time label carries logical validity phase information in time label, can the timing since being stored in caching system business datum,
When timing reaches the logical validity phase, it is believed that the business datum logical validity phase is already expired.
In step 206, it if the logical validity phase of business datum is already expired, can attempt from distally obtaining newest business
Data cache newest business datum to caching system if got, and the business datum expired to logic is covered
Lid, to guarantee the timeliness of business datum.Here distal end can be upstream application system, be also possible to database etc..
On the one hand physics validity period of the business datum in caching system is set as permanent effective by this specification embodiment, make
The business datum for existing always in caching system and revealing all the details for realizing caching is obtained, to realize caching disaster tolerance;On the other hand slow
To newest business datum is distally requested when business datum logic in deposit system is expired, to guarantee in available remote data
In the case where, the business datum that operation system is got is the business datum within the logical validity phase.
It in one embodiment, can be directly by the industry if not finding the business datum in caching system
Business data are from being distally cached to the caching system.If not finding the business datum in caching system, show caching system
System is not cached the business datum, even if be cached business datum, but because reasons, the general such as expire in caching system space
Business datum evicts caching from.Therefore, can be to distal end requested service data, and business datum is buffered in caching system,
To realize that caching is revealed all the details.
In one embodiment, if not finding the business datum in caching system, data cached lock is being got
Later, the business datum is searched in caching system again;If not finding the business datum yet, by the business datum
From being distally cached to the caching system.
In the present embodiment, every part it is data cached be owned by a data cached lock, can be carried in service data request
One " key " value, key can be considered the key assignments of caching system, be equivalent to the unique identification of business datum in the buffer.It is receiving
When service data request, judge whether service data request gets data cached lock.Only get the industry of data cached lock
Business request of data, just obtaining remote data for the service data request, this is the number in order to reduce distal end under high concurrent scene
According to interaction pressure.And the business datum why is searched in caching system again, it is because of a service data request
When taking data cached lock, it is possible to which other threads are from distally having got business datum and be stored to caching system
In.Therefore, by secondary judgement, can to avoid with distally carry out unnecessary data interaction.
Further, the timeout mechanism for obtaining data cached lock can be set in the present embodiment.If obtaining caching
Data lock time-out, directly terminates process.Timeout mechanism is unnecessary in order to prevent waits so that waste of resource, prevents extreme feelings
Request queue is waiting always under condition, occurs overloading so as to cause system snowslide.
It in one embodiment, can be by important journey by the business datum from when being distally cached to the caching system
Spend the first high business datum second business datum low with significance level cache respectively it is mutually isolated into the caching system
Different zones in.Here the first business datum can be the business pair that payment transaction data etc. require High Availabitity ability
The business datum answered.Label can be set for business datum in advance, the business datum with different labels is cached to not respectively
In same buffer zone.
Further, the buffer zone for caching the first business datum can be set to never evict data from, cache the second industry
The buffer zone of business data can be set to evict the longest business datum of cache-time from.By way of emphasis data isolation,
The proximal end of emphasis data and general data caching is kept apart, emphasis data carry out full dose caching, and general data is still according to slow
It deposits strategy to evict to execute, if caching system is not enough to support full dose data, this mode can guarantee significant data (example
Such as, the business datum of emphasis trade company) centainly can disaster tolerance, and for long-tail data disaster tolerance to a certain extent.
In one embodiment, if the logical validity phase of business datum is already expired, it can be determined that in the service data request
Whether data cached lock is carried;If so, returning the business datum from the step of being distally cached to the caching system.This reality
It applies in example, the business datum expired for logic, remote data can also be obtained by data cached lock.It is slow with aforementioned setting
Unlike the embodiment of deposit data lock, the present embodiment can be not provided with time-out time.Due to being storage in this caching system
There is business datum, although logic is expired, still the expired business datum of logic can be returned into business, is protected with this
The High Availabitity of card business.Obtaining data cached lock and being not provided with time-out time is to reduce in the case where physical store is hit
The response time of service data request, the performance of lifting system.
If the logical validity phase non-mistake, directly can be back to industry for the business datum found in caching system
Business system.
Physics validity period of the business datum in caching system is permanent effective.It should be noted that " permanently having here
Effect " refers to cache-time more than sometime threshold value, which can be one very long time (for example, 1 year), only
It wants to guarantee to realize caching disaster tolerance.
The proximal end cache logic of the present embodiment same can be encapsulated into a caching component, and business needs to obtain data
When, data are directly obtained by caching component, are to be obtained from caching, or obtained from remote service end as data
Judged by caching component, business does not need to perceive the logic of any caching and disaster tolerance.The programming flowchart of Fig. 3 shows proximal end
Caching component is how to carry out data buffer storage, and how to carry out disaster tolerance in the event of an anomaly.Specifically may include with
Lower step:
Step 302: operation system is obtained data cached by caching component.
Step 304: caching component searches business datum from caching system, if caching is breakdown, thens follow the steps
320;If cache hit (that is, finding business datum in the buffer), thens follow the steps 306.
Step 306: the key assignments (key) of business datum can be carried in service data request, each key-value pair answers unique one
A data cached lock, each time point only have a key assignments get it is data cached lock go distal end obtain data.In step 304
Cache it is breakdown after, will acquire the corresponding data cached lock of the key assignments, then execute step 308.
Step 308: if getting data cached lock, executing step 310;It is no to then follow the steps 318.
Step 310: since there may be other threads, and distal end have been gone to obtain business datum, and business datum being stored
Into caching system, it after getting data cached lock, will judge whether caching hits again, if miss, will carry out
Step 312, if hit, returns data to business, process terminates.
Step 312: obtaining remote data, then execute step 314.
Step 314: the data of proximal end caching are written in object in the remote data write-in proximal end caching system that will acquire here
Be in reason storage it is never expired, only caching, which has been expired, just understands trigger data when needing the data to evict from and is deleted by physics, but meeting
The logic expired time of setting business.Then step 316 is executed.
Step 316: the business datum in caching system is back to operation system.In this step, if distal end occurs
The problems such as Network Abnormal, database delay machine, is revealed all the details the data in caching system by this mechanism to guarantee that business is total
It is available to data, ensure that the high availability of business.
Step 318: if obtaining data cached lock time-out, directly terminating process.
Step 320: in the caching system of proximal end have business datum when, first judge this it is data cached whether logic is expired, such as
Fruit is out of date, then carries out step 322, and otherwise to operation system, process terminates direct return cache data.
Step 322: it is similar with step 306, the corresponding data cached lock of the key assignments is obtained, step 324 is then executed.
Step 324: if getting data cached lock, thening follow the steps 326;Otherwise, business datum is returned, and terminates to flow
Journey.
Step 326: obtaining distal end business datum, and execute step 328.
Step 328: if obtained successfully, thening follow the steps 314;If obtaining failure, (remote service end occurs abnormal
When), then follow the steps 316.
The scheme of this specification embodiment has at least the following advantages:
(1) it in the case where disaster occurs, is revealed all the details by the data for hitting physics as disaster tolerance data, is come with this
The high availability of guarantee business.
It (2), can be under high concurrent scene to distally protecting by the way that data cached lock is arranged.
(3) pass through setting timeout mechanism, it is therefore prevented that it is unnecessary to wait to waste of resource, and prevent extreme case
Lower request queue is waiting always, occurs overloading so as to cause system snowslide.
(4) by separately delaying higher first business datum of significance level and lower second business datum of significance level
It deposits, and the first business datum never evicts caching from, only just evicts second cached at first from when respective cache region is filled with
Business datum ensure that the disaster tolerance of emphasis business.
As shown in figure 4, this specification embodiment also provides a kind of caching disaster recovery method, which comprises
Step 402: if distal end business datum obtains time-out, business datum is searched in caching system;
Step 404: the business datum found is sent to operation system;
Wherein, the business datum is cached according to the data cache method of any embodiment to the caching system.
It is corresponding with the embodiment of preceding method, this specification embodiment additionally provide device, computer storage media and
The embodiment of caching system.
As shown in figure 5, Fig. 5 is a kind of this specification embodiment data buffer storage device shown according to an exemplary embodiment
Block diagram, described device includes:
First searching module 502, for receive operation system transmission service data request when, in caching system
Search business datum;
First obtains module 504, if obtaining the logical validity phase of the business datum for finding;Wherein, described to patrol
Collecting validity period is the term of validity that the business datum corresponds to business;
First cache module 506, if being already expired for the logical validity phase, by the business datum from being distally cached to institute
Caching system is stated, and physics validity period of the business datum in caching system is set as permanent effective.
As shown in fig. 6, Fig. 6 is a kind of this specification embodiment caching disaster tolerance device shown according to an exemplary embodiment
Block diagram, described device includes:
Second searching module 602 searches business datum if obtaining time-out for distal end business datum in caching system;
Sending module 604, for the business datum found to be sent to operation system;
Wherein, the business datum is cached according to the data cache method of any embodiment to the caching system.
The specific details of the realization process of the function of modules and effect, which are shown in, in above-mentioned apparatus corresponds to step in the above method
Realization process, details are not described herein.
The embodiment of this specification device can be applied on a computing device, such as server or terminal device.Device
Embodiment can also be realized by software realization by way of hardware or software and hardware combining.Taking software implementation as an example,
As the device on a logical meaning, being will be corresponding in nonvolatile memory by the processor of file process where it
Computer program instructions are read into memory what operation was formed.For hardware view, as shown in fig. 7, being this specification device
A kind of hardware structure diagram of place computer equipment, in addition to processor 702 shown in Fig. 7, memory 704, network interface 706, with
And except nonvolatile memory 708, server or electronic equipment in embodiment where device are set generally according to the computer
Standby actual functional capability can also include other hardware, repeat no more to this.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality
Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit
The module of explanation may or may not be physically separated, and the component shown as module can be or can also be with
It is not physical module, it can it is in one place, or may be distributed on multiple network modules.It can be according to actual
The purpose for needing to select some or all of the modules therein to realize this specification scheme.Those of ordinary skill in the art are not
In the case where making the creative labor, it can understand and implement.
Correspondingly, this specification embodiment also provides a kind of computer storage medium, is stored with journey in the storage medium
Sequence realizes the method in any of the above-described embodiment when described program is executed by processor.
Correspondingly, this specification embodiment also provides a kind of caching system, including memory, processor and is stored in storage
On device and the computer program that can run on a processor, which is characterized in that the processor is realized when executing described program
The method for stating any embodiment.
Further, as shown in figure 8, the caching system includes general caching unit 802 and white list cache unit
804;The white list cache unit 804 is for storing the first high business datum of significance level, the general caching unit 802
For storing the second low business datum of significance level;Wherein, will cached at first when the general caching unit 802 is filled with
Two business datums evict caching from.
It wherein includes storage medium (the including but not limited to disk of program code that the application, which can be used in one or more,
Memory, CD-ROM, optical memory etc.) on the form of computer program product implemented.Computer-usable storage medium packet
Permanent and non-permanent, removable and non-removable media is included, can be accomplished by any method or technique information storage.Letter
Breath can be computer readable instructions, data structure, the module of program or other data.The example packet of the storage medium of computer
Include but be not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM),
Other kinds of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory
(EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM), digital versatile disc
(DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices or any other non-biography
Defeated medium, can be used for storage can be accessed by a computing device information.
Those skilled in the art will readily occur to this after considering specification and practicing specification embodiment disclosed herein
Disclosed other embodiments.The disclosure is intended to cover any variations, uses, or adaptations of the disclosure, these changes
Type, purposes or adaptive change follow the general principles of this disclosure and undocumented in the art including the disclosure
Common knowledge or conventional techniques.The description and examples are only to be considered as illustrative, the true scope and spirit of the disclosure
It is indicated by the following claims.
It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and
And various modifications and changes may be made without departing from the scope thereof.The scope of the present disclosure is only limited by the accompanying claims.
The foregoing is merely the preferred embodiments of the disclosure, not to limit the disclosure, all essences in the disclosure
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of disclosure protection.