Background technology
Along with domestic internet formally enters Web2.0 epoch on the universal significance, unidirectional, the popular information propagation pattern of tradition can't satisfy users and obtain demand abundant, minorityization information.Therefore, in order to meet the need, the website distribution technology is changed to dynamic web pages such as PHP, JSP, ASPX by traditional HTML static page gradually.But for large-scale website, the dynamic web page distribution technology is limited by hardware environment, the quick response of system in the time of can't satisfying a large amount of concurrent request.For addressing this problem, usually adopt at present following three kinds of modes: increase server hardware specification, the dynamic and stalic state page mixing issue and full page face buffer memory, these three kinds of modes have own significantly shortcoming.
Increase the hardware server specification and refer to increase number of servers or configuration.The advantage of this mode is that software cost is low, convenient, simple, only need configure on a small quantity and can finish expansion.But shortcoming is also very obvious, and hardware cost rises, and extended capability is very limited, along with the increase of number of servers, and hardware environment more complex and be difficult to safeguard, the expense such as water power net also significantly rises thereupon simultaneously.For the internet industry of very valuing operating cost, this mode obviously can't be accepted.
The dynamic and stalic state page mixes issue and refers to the page that does not have interactive requirements is adopted the static page issue, and the page that interactive requirements is arranged is adopted the dynamic page issue.The advantage of this mode is rationally to have utilized limited website issue resource; Shortcoming is that the shared ratio of static page also decreases along with the netizen is more and more higher to requirement interactive, the minorityization content, therefore this mixing distribution technology solution that only is a kind of interim transition.
Full page face buffer memory refers to the dynamic content revealing result of script is carried out buffer memory.This mode is present widely used solution.Its advantage is that technology realizes simply, cost is low, efficient is high; Its shortcoming is that interactivity is under some influence, and especially to the propagation of following minorityization information, the effect that full page face buffer memory plays is very limited.
The dynamic page efficiency for issuing is affected by mainly two aspects, i.e. dynamic data acquisition speed and page pattern aggregate velocity.
Obtain for dynamic data, traditional approach is directly to inquire about according to condition in database.Along with the rising of access concurrency, this mode can increase the weight of the load of database; Complete memory contents entity causes database space to increase in database in addition, has influence on the database retrieval performance; Along with the increase of data volume, how from mass data, to find fast qualified record also to become the difficult problem that to avoid simultaneously.
For synthesizing of page pattern, the processing logic that traditional page represents is each data in conjunction with getting access to, and again splices page object code.The content of carrying along with webpage is more and more abundanter, and the process that pattern synthesizes is also more and more consuming time, even full page is carried out buffer memory, also can reduce the buffer memory effect along with the difference of netizen's Access status and querying condition.
Summary of the invention
For the defective that exists in the prior art, technical matters to be solved by this invention provides a kind of dynamic web page data buffer storage and dissemination method and system that can improve efficiency for issuing.
For solving the problems of the technologies described above, the technical solution used in the present invention is as follows:
A kind of dynamic web page data cache method may further comprise the steps:
The content-data of dynamic web page is buffered in the first order buffer storage;
The content-data of the dynamic web page that will retrieve in first order buffer storage according to search condition is buffered in the buffer storage of the second level;
Content area block code after will being synthesized by the content-data in the content area piece of the dynamic web page page and pattern is buffered in the third level buffer storage.
A kind of dynamic web page dissemination method that adopts above-mentioned data cache method may further comprise the steps:
(1) request dynamic webpage splits into each content area piece with described dynamic web page, and the content-data of resolving each content area piece obtains condition;
(2) content-data according to each content area piece obtains condition, obtains successively each content area block code, then goes to step (3); The process of obtaining a content area block code is as follows:
(a) content-data with the content area piece obtains condition as search condition, access third level buffer storage; If described search condition is hit, then return the content area block code that meets described search condition; Otherwise, enter next step;
(b) according to described search condition, access second level buffer storage; If described search condition is hit, then return the content-data that meets described search condition, synthesize the content area block code in conjunction with pattern, and this content area block code is deposited in the third level buffer storage; Otherwise, enter next step;
(c) according to described search condition, access first order buffer storage; If described search condition is hit, then return the content-data that meets described search condition, and described content-data deposited in the buffer storage of the second level, in conjunction with synthetic this content area block code of pattern, and this content area block code is cached in the described third level buffer storage;
If described search condition is not hit, the content-data that then again will meet described search condition is loaded in the first order buffer storage; Return described content-data, and described content-data is deposited in the buffer storage of the second level, synthesize this content area block code in conjunction with pattern, and this content area block code is deposited in the third level buffer storage;
(3) after being spliced, each content area block code fragment represents.
A kind of dynamic web page data buffering system comprises the first order buffer storage for the content-data of buffer memory dynamic web page;
The second level buffer storage that is used for the content-data of the dynamic web page that buffer memory retrieves at first order buffer storage according to search condition;
The third level buffer storage that is used for the content area block code of buffer memory after synthetic by the content-data of the content area piece of the dynamic web page page and pattern.
A kind of dynamic web page delivery system based on said system comprises with lower device:
Request unit is used for request website dynamic page;
Resolver is used for dynamic page is split into each content area piece, and the content-data of resolving each content area piece obtains condition;
Third level cache access device is used for the content-data of content area piece is obtained condition as search condition access third level buffer storage; If described search condition is hit, then to splicing apparatus returned content region unit code;
Second level cache access device is used for the content-data of content area piece is obtained condition as search condition access second level buffer storage, if described search condition is hit, then to splicing apparatus returned content data;
First order cache access device, be used for the content-data of content area piece is obtained condition as search condition access first order buffer storage, if described search condition is hit, then to splicing apparatus returned content data, and described content-data is buffered in the buffer storage of the second level; If described search condition is not hit, the content-data that then will meet described search condition is loaded in the first order buffer storage; Return described content-data to splicing apparatus, and described content-data is buffered in the buffer storage of the second level;
Splicing apparatus is used for content-data and the synthetic content area block code of pattern are cached to the content area block code in the third level buffer storage, and each content area block code fragment is re-started splicing.
The method of the invention and system by the dynamic web page data of different purposes being carried out hierarchical cache, obtain the mode of dynamic web page data from buffer memory, have improved the reusability of buffered results, and then have improved the efficiency for issuing of dynamic web page.
Embodiment
Describe the present invention below in conjunction with embodiment and accompanying drawing.
Embodiment 1
The present embodiment provides a kind of dynamic web page data buffering system and method.As shown in Figure 1, this system comprises first order buffer storage 11, second level buffer storage 12 and third level buffer storage 13.First order data buffer storage device 11 comprises file-level buffer unit 111, database level buffer unit 112 and internal memory level buffer unit 113.
First order buffer storage 11 is used for buffer memory, and all meet the content-data of the dynamic web page that imposes a condition, as all issued states be sign and issue, column is news channel, the contribution expired time is later than setting-up time content-data set.Wherein, file-level buffer unit 111 is for all meet the complete content data that impose a condition with entity file form buffer memory.Preferably, file layout adopts XML, because the impact that the speed of retrieval and loading XML file is not increased by quantity of documents.Database level buffer unit 112 is used for providing elementary retrieval and inquisition service, be to reduce the database load, only buffer memory need retrieval and inquisition field contents (such as user right rank, key word etc.) and with the file path of content-data in file-level buffer unit 111 of this Related fields.Internal memory level buffer unit 113 is used for the frequent content-data that uses of buffer memory, the delay that causes to reduce the magnetic disc i/o operation.
The purpose that three grades of buffer memorys are set in first order buffer storage 11 is in order to improve the inquiry response speed of content-data.The impact that file-level buffer unit 111 can make the speed of retrieval and loading data not increased by data volume, database level buffer unit 112 can more effectively utilize disk space, reduce the delay of I/O operation, internal memory level buffer unit 113 can further improve inquiry response speed.
Second level buffer storage 12 is used for the content-data that buffer memory retrieves at first order buffer storage 11 according to search condition, preferably adopts internal memory level buffer memory.
Third level buffer storage 13 is used for buffer memory by content-data and the synthetic content area block code of pattern of the content area piece of the dynamic web page page, preferably adopts internal memory level buffer memory.
As shown in Figure 3, adopt the method for system shown in Figure 1 buffer memory dynamic web page data may further comprise the steps:
(1) content-data that all is met the dynamic web page that imposes a condition is buffered in the first order buffer storage 11.
Particularly, all being met the complete content solid data that imposes a condition is buffered in the file-level buffer unit 111 with the XML document form.To need the field contents of retrieval and inquisition and be buffered in the database level buffer unit 112 with the file path of content-data in file-level buffer unit 111 of this Related fields.The content-data that frequently uses is buffered in the internal memory level buffer unit 113.
(2) will be buffered in according to the content-data that search condition retrieves in first order buffer storage 11 in the second level buffer storage 12.
(3) will be buffered in the third level buffer storage 13 by the content-data in the content area piece of the dynamic web page page and the synthetic content area block code of pattern.
Because the dynamic web page page of a website is comprised of a plurality of content area pieces, when dynamic web content occured to upgrade, usually only having wherein, a few content area piece changed.Therefore content-data and the synthetic content area block code of pattern with the content area piece is buffered in the third level buffer storage 13, when this page of access, can from third level buffer storage 13, directly obtain content area block code after synthetic according to search condition, avoid the again synthetic of same content.
Embodiment 2
Based on the cache way described in the embodiment 1, the present embodiment provides a kind of dynamic web page delivery system and method.As shown in Figure 2, this system also comprises request unit 21, resolver 22, first order cache access device 25, second level cache access device 24, third level cache access device 23, splicing apparatus 26, demonstration device 27, updating device 28 and buffer memory cleaning plant 29 except comprising the buffer storage described in the embodiment 1.Wherein, first order cache access device 25 comprises the first counter 251, and second level cache access device 24 comprises the second counter 241, and third level cache access device 23 comprises the 3rd counter 231.
Request unit 21 is used for asking the dynamic web page W of website.
Resolver 22 is used for dynamic web page W is split into each content area piece, resolves the data acquisition condition of each content area piece.
Third level cache access device 23 is used for the content-data of content area piece is obtained condition as search condition access third level buffer storage 13.If this search condition is hit, then return the content area block code that meets this search condition to splicing apparatus 26.The 3rd counter 231 is used for cumulative search condition at the hit-count of third level buffer storage 13.
Second level cache access device 24 is used for the content-data of content area piece is obtained condition as search condition access second level buffer storage 12.If this search condition is hit, then return the content-data that meets this search condition to splicing apparatus 26.The second counter 241 is used for cumulative search condition at the hit-count of second level buffer storage 12.
First order cache access device 25 is used for the content-data of content area piece is obtained condition as search condition access first order buffer storage 11.If search condition is hit, then returns the content-data that meets this search condition to splicing apparatus 26, and this content-data is deposited in the second level buffer storage 12; If search condition is not hit, the content-data that then again all is met this search condition is loaded in the first order buffer storage 11; Deposit in the second level buffer storage 12 again to splicing apparatus 26 returned content data, and with this content-data.The first counter 251 is used for cumulative search condition at the hit-count of first order buffer storage 11.
Splicing apparatus 26 is used for content-data and the synthetic content area block code of pattern are cached to the content area block code in the third level buffer storage 13, and each content area block code fragment is spliced.Wherein, pattern is set by the user.
Demonstration device 27 is used for representing through the splicing apparatus 26 spliced dynamic web page pages.
Updating device 28 is used for upgrading the data of buffer memory in first order buffer storage 11, second level buffer storage 12 and the third level buffer storage 13 when the content-data of dynamic web page changes.
Cache cleaner device 29 is used for clearing up the data in the buffer storages at different levels when the data of buffer storages at different levels have expired.
As shown in Figure 4, adopt the method for system shown in Figure 2 issue dynamic web page may further comprise the steps:
(1) the dynamic web page W of request unit 21 request websites.Because dynamic web page is comprised of a plurality of content area pieces, each content area piece comprises content-data and pattern, therefore at first by resolver 22 dynamic web page is split into each content area piece, and resolves the condition of obtaining of the content-data of each content area piece.
(2) content-data according to each content area piece obtains condition, obtains successively each content area block code, then goes to step (3).Wherein, obtain the process of a content area block code as follows:
(a) third level cache access device 23 is accessed third level buffer storage 13 with the condition of obtaining of the content-data of content area piece as search condition.If search condition is hit, then return content area block code corresponding to this content-data to splicing apparatus 26, the 3rd counter 231 adds 1 with the hit-count of this search condition in third level buffer storage 13.If search condition is not hit, then enter step (b).
(b) second level cache access device 24 is according to this search condition access second level buffer storage 12, if this search condition is hit, then return the content-data that meets this search condition to splicing apparatus 26, the second counter 241 adds 1 with the hit-count of this search condition in second level buffer storage 12.Splicing apparatus 26 synthesizes this content area block code according to content-data and pattern, and this content area block code is cached in the third level buffer storage 13.If this search condition is not hit, then enter step (c).
(c) first order cache access device 25 is according to this search condition access first order buffer storage 11, if this search condition is hit, then return the content-data that meets this search condition to splicing apparatus 26, the first counter 251 adds 1 with the hit-count of this search condition in first order buffer storage 11, and this content-data is buffered in the second level buffer storage 12.Splicing apparatus 26 synthesizes this content area block code according to content-data and pattern, and the page code of this content area piece is cached in the third level buffer storage 13.
Particularly, first order cache access device 25 is at first according to this search condition access memory level buffer unit 113; If this search condition is not hit, then continue accessing database level buffer unit 112, if this search condition is hit, then from file-level buffer unit 111, obtain file according to file path, behind the resolution file, obtain content-data wherein, and this content-data is deposited in the internal memory level buffer unit 113.
If this search condition is not hit, the content-data that then again all is met this search condition is loaded in the first order buffer storage 11.Then be buffered in the second level buffer storage 12 to splicing apparatus 26 returned content data, and with this content-data.Splicing apparatus 26 synthesizes this content area block code according to content-data and pattern, and this content area block code is cached in the third level buffer storage 13.
(4) behind each content area block code of splicing apparatus 26 synthetic dynamic web pages, each content area block code is spliced, represent spliced dynamic web page by demonstration device 27 at last.
In the website, generally the content-data with dynamic web page is stored in the content data base.When the dynamic web content data in the content data base change, need to upgrade the data of buffer memory in the buffer storages at different levels.In the present embodiment, updating device 28 provides two kinds of update modes, and a kind of is passive update mode, and a kind of is the active update mode.
Passive update mode refers to only record affected data area when change occurs the content-data in the content data base 20, and the content-data in the buffer storage does not upgrade first.And when according to search condition access cache device, if this search condition is hit, continue to judge that then the content-data that hits is whether in affected data area.If in this data area, illustrate that the content-data of buffer memory is inaccurate, need to reload, this moment, the content-data of buffer memory was invalid; If not in this data area, illustrate that then the content-data of buffer memory is still effective, can continue to use.The advantage of this update mode is to reduce the synchronous expense of buffer memory, but response speed can descend to some extent.
Initiatively update mode refers to initiatively upgrade affected data in the buffer memorys at different levels when change occurs the content-data of dynamic web page.As shown in Figure 5, initiatively the process of update mode may further comprise the steps:
(1) judges whether comprise the content-data that needs upgrade in the first order buffer storage 11, if comprise, then upgrade this content-data.
Particularly, at first judge whether comprise the content-data that needs upgrade in the file-level buffer unit 111.If comprise, then delete the raw content data file, again the content-data that upgrades is deposited in the file-level buffer unit 111 with document form.Then upgrade the record of this content-data in the database level buffer unit 112, namely delete former record, the field contents of the retrieval and inquisition after upgrading and the file path in file-level buffer unit 111 are deposited in the database level buffer unit 112.Judge at last and whether comprise the content-data that needs upgrade in the internal memory level buffer unit 113; If comprise, then upgrade the raw content data with new content, the hit-count of keeping simultaneously this content-data is constant; If do not comprise, then do not do any processing.
If do not comprise the content-data that needs upgrade in the file-level buffer unit 111, illustrate that then this content-data increases newly, this content-data is deposited in the file-level buffer unit 111 with the XML document form, the retrieval and inquisition field contents of this content-data and the file path in file-level buffer unit 111 are deposited in the database level buffer unit 112.
Whether the hit rate of (2) judging successively each search condition in the second level buffer storage 12 satisfies initiatively more new demand, and namely whether search condition is greater than setting threshold.If greater than, then according to this search condition again loading content data from first order buffer storage 11, deposit in the second level buffer storage 12; If be not more than, then with this search condition and content-data directly deletion from second level buffer storage 12 of meeting this search condition.Total hits of the hit-count of the hit rate=search condition of described search condition/this content-data of access.Experiment shows, it is better that threshold value is got 10% effect.
When the data in the first order buffer storage 11 occur to upgrade, determine the update mode of data in the buffer storage 12 of the second level according to the hit rate of search condition, the search condition that shoots straight can initiatively be upgraded buffered results, and low its buffered results of search condition of hit rate can be cleared.Namely only upgrade content-data corresponding to search condition that shoots straight in the second level buffer storage 12, can not upgrade content-data corresponding to all search conditions fully.The purpose of this treatment mechanism is to reduce under the same terms the pressure of first order buffer storage 11, improves simultaneously reusability and the hit rate of content-data in the second level buffer storage 12, and improves the update efficiency of content-data.
Whether the hit rate of (3) judging successively search condition in the third level buffer storage 13 satisfies initiatively more Secretary, and namely whether search condition is greater than setting threshold.If greater than, then again from second level buffer storage 12, load the content-data that meets this search condition, in conjunction with pattern again synthetic content area block code, and deposit in the third level buffer storage 13, keep simultaneously the hit-count of this search condition constant.If be not more than, then will meet the directly deletion from third level buffer storage 13 of content area block code of this search condition, to reach the purpose that improves Buffer Utilization and hit rate.
When certain one-level buffer storage was expired, cache cleaner device 29 was according to hit-count cleaning content-data or the data relevant with content-data.For example, when third level buffer storage 13 is expired, one or several search condition that hit rate is minimum and meet the content area block code deletion of this search condition.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technology thereof, then the present invention also is intended to comprise these changes and modification interior.