Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.
Embodiment 1
As shown in Figure 1, the embodiment of the present invention provides a kind of method of high-speed cache, comprising:
Step 101: receive retrieval request, carry the retrieval string in this retrieval request;
Step 102: according to the search results pages of storing in this retrieval string search file system, if search out corresponding search results pages, execution in step 103, if do not search out corresponding search results pages, execution in step 104;
Step 103: the access frequency that increases this search results pages;
Step 104: search for Search Results corresponding to this retrieval string by search engine, the Search Results of searching for is assembled into search results pages and is stored in file system.
In embodiments of the present invention, after receiving retrieval request, whether there be the search results pages corresponding to retrieval string of carrying in retrieval request in the direct search file system, if, increase the access frequency of this search results pages, if not, search for Search Results corresponding to this retrieval string, Search Results is assembled into search results pages and is stored in file system.Search results pages due to direct memory scan in file system, carry the retrieval request of retrieval string when reception after, whether there be search results pages corresponding to this retrieval string in the direct search file system, thereby reduced the number of times that creates the CGI process, reduce the CGI process and forwarded the number of times of retrieval request and reduced the number of times of cancelling the CGI process, thereby reduced the consumption of time and resource.
Embodiment 2
As shown in Figure 2, the embodiment of the present invention provides a kind of method of high-speed cache, comprising:
Step 201: receive the retrieval request that client sends, carry the retrieval string in this retrieval request;
Wherein, after the user submits the retrieval string to client, the retrieval string that client is submitted to, then send the retrieval request of carrying this retrieval string.Wherein, client can be browser.
For example, the user opens the homepage of search engine in browser, and the retrieval string that input needs to search in browser is " Keyword ", and then submit this retrieval string to browser, browser receives the retrieval string " Keyword " of submitting to, then sends the retrieval request of carrying retrieval string " Keyword ".
Step 202: according to the retrieval string search file system of carrying in this retrieval request, if search out corresponding search results pages, execution in step 203, if do not search out corresponding search results pages, execution in step 204;
Wherein, be pre-created file system, the search results pages that the retrieval string of hot topic is corresponding is with Html(HyperText Mark-up Language, HTML (Hypertext Markup Language)) form of file is stored in file system, and directly with the filename of retrieval string as its corresponding search results pages.After receiving retrieval request, according to the retrieval string that carries in this retrieval request, whether there is the search results pages of file this retrieval string by name in the direct search file system.
For example, file system as shown in table 1, the search results pages of the popular retrieval string of storage in table 1, and in table 1 with the search results pages of the form memory scan string of Html file, with the filename of retrieval string as search results pages, as the search results pages of the file " www.qq.com " by name of the second row storage of table 1, and " www.qq.com " is the retrieval string.So in this step, directly search for the search results pages that whether has file retrieval string by name " Keyword " from file system as shown in table 1.
Table 1
Search results pages |
Access frequency |
The www.qq.com |
n1 |
China Mobile |
n2 |
...... |
...... |
Further, file system comprises memory subsystem and disk subsystem, and wherein, the capacity of memory subsystem is greater than the capacity of disk subsystem;
Correspondingly, this step is specially:
At first according to the retrieval string that carries in this retrieval request, the search memory subsystem, if search out corresponding search results pages, execution in step 203, otherwise, again according to the retrieval string that carries in this retrieval request, the search disk subsystem, if search out corresponding search results pages, execution in step 203, otherwise, execution in step 204.
Step 203: increase the access frequency of this search results pages in file system, EO;
Wherein, can be in file system the access frequency of this search results pages be added 1.In addition, after searching out this search results pages, also need this search results pages is returned to client, and when client after this search results pages of returning, this search results pages that receives is shown to the user.
For example, suppose to search out the search results pages of file " Keyword " by name in step 202 from file system as shown in table 1, in this step, the access frequency of the search results pages of " Keyword " in table 1 is added 1.In addition, also the search results pages of " Keyword " to be returned to client.
Wherein, after the retrieval request that receives the client transmission, directly search for corresponding search results pages according to the retrieval string that carries in this retrieval request from file system, if search search results pages corresponding to this retrieval string, directly return to client, thereby can reduce the number of times that creates the CGI process, reduce the number of times that the CGI process forwards retrieval request, also reduce the number of times of cancelling the CGI process, so, the consumption of minimizing time and resource.In addition, owing to directly searching out search results pages, thereby reduced establishment CGI process, the CGI process forwards retrieval request and needed time of CGI process assembly unit search results pages, thereby has improved search efficiency.
Step 204: search for Search Results corresponding to this retrieval string by search engine;
Particularly, create the CGI process, and by the CGI process, the retrieval request that receives is transmitted to search engine; After search engine received this retrieval request, search engine was searched for corresponding Search Results according to the retrieval string that carries in this retrieval request, then the Search Results of search is returned to the CGI process.
Wherein, search engine is that prior art is not described in detail at this according to Search Results corresponding to retrieval string search that carries in this retrieval request.
For example, suppose not search out the search results pages of file " Keyword " by name from file system as shown in table 1 in step 202, in this step, create the CGI process, and be transmitted to search engine by the retrieval request that the CGI process will be carried retrieval string " Keyword ", search engine searches out all corresponding Search Results according to retrieval string " Keyword ", and search engine returns to the CGI process with the Search Results of search again.
Step 205: Search Results is assembled into search results pages by the CGI process;
Wherein, after the complete all search results pages of CGI process assembly unit, also need to return to client the search results pages of assembly unit, and after the search results pages that client returns, show that the search results pages that receives is to the user.
For example, in step 204, search out Search Results corresponding to retrieval string " Keyword ", the CGI process will be retrieved Search Results corresponding to string " Keyword " and be assembled into search results pages in this step.
Step 206: the search results pages of assembly unit is stored in file system, and the filename of this search results pages is set to this retrieval string, and the initial value of the access frequency of this search results pages, EO are set.
Particularly, after assembly unit should the search results pages of retrieval string, be stored in file system by the step of following (1)-(3) search results pages with assembly unit, comprise:
(1): judge that unappropriated space in file system whether more than or equal to the needed space of this search results pages of storage, if so, carries out (3), if not, carry out (2);
(2): eliminate in file system the search results pages of least referenced recently, until when making unappropriated space in file system more than or equal to the needed space of this search results pages of storage;
Wherein, can adopt existing superseded algorithm to eliminate the search results pages of nearest least referenced in file system, superseded algorithm can be LRU(least recently used, uses at most) algorithm etc.
(3): this search results pages is stored in file system, and the filename of this search results pages is set to this retrieval string, the initial value of the access frequency of this search results pages is set simultaneously, EO.
Wherein, the search results pages of carrying out assembly unit due to CGI is a Html file, therefore, can be directly the search results pages of this assembly unit be stored in file system.The initial value of access frequency that in addition, can search results pages is set to 1.
For example, the search results pages of the retrieval string " Keyword " of CGI process creation is a Html file, therefore directly this search results pages is stored in file system as shown in table 1, and the file that this search results pages is set is called " Keyword ", and the access frequency that this search results pages is set is 1, and the result that obtains is as shown in table 2.
Table 2
Search results pages |
Access frequency |
Keyword |
1 |
The www.qq.com |
n1 |
China Mobile |
n2 |
...... |
...... |
Further, if file system comprises memory subsystem and disk subsystem, correspondingly, when assembly unit is complete should the search results pages of retrieval string after, be stored in file system by the step of following (a)-(e) search results pages with assembly unit, comprising:
(a): judge that unappropriated space in memory subsystem whether more than or equal to the needed space of search results pages of storage assembly unit, if not, carries out (b), if so, carry out (e);
(b): the search results pages of selecting nearest least referenced in memory subsystem, judge the needed space of the search results pages whether unappropriated space in disk subsystem is selected more than or equal to storage, if so, carry out (c), if not, carry out (d);
(c): eliminate in disk subsystem the search results pages of least referenced recently, until during the search results pages needed space that makes that the unappropriated space in disk subsystem selects more than or equal to storage;
(d): the search results pages of selecting is stored in disk subsystem, and the search results pages of selecting is deleted from memory subsystem, and return to execution (a);
(e): the search results pages of assembly unit is stored in memory subsystem, and the access times of the search results pages of assembly unit are set to 1, and the filename of the search results pages of assembly unit is set to this retrieval string, EO.
Wherein, in the present embodiment, all right recording user daily record, the user journal of record comprises user's IP at least, the time of user's request and the retrieval string of request etc., user journal as shown in table 3.
Table 3
User's IP |
The time of user's request |
The retrieval string of request |
IP1 |
T1 |
The www.qq.com |
IP2 |
T2 |
China Mobile |
IP3 |
T3 |
Keyword |
...... |
...... |
...... |
Wherein, the recording user daily record is prior art, no longer is described in detail at the present embodiment.
Further, every one-period, according to user journal, the search results pages of the nearest least referenced in file system is cleaned it out;
Wherein, periodic this operation of execution, the detailed process of each operation is: owing to naming each search results pages with the retrieval string in file system, therefore for one in file system retrieval string, should retrieve the access times of string in the statistics current period in user journal, add up as stated above the access times of each the retrieval string in the Cache system, clean it out by the existing algorithm search results pages that the retrieval string of nearest least referenced is corresponding of eliminating according to access times of each retrieval string.
Wherein, suppose, current time is t, and the cycle is T, in user journal as shown in table 3 counting user t-T to t during this period of time in, the access times of each the retrieval string in counting user demand file system.
Further, when file system comprises memory subsystem and disk subsystem, every one-period, M search results pages of the access frequency maximum in disk subsystem is loaded into memory subsystem, and M search results pages of the access frequency minimum in memory subsystem eliminated in disk subsystem;
Wherein, periodically carry out this operation, the detailed process of each operation is divided into the step of following (1)-(4), comprising:
(1): each search results pages in memory subsystem is sorted by access frequency; Each search results pages in disk subsystem is sorted by access frequency;
(2): select M search results pages of access frequency minimum from memory subsystem, and M the search results pages of selecting is stored in shared drive, M the search results pages that deletion is selected from memory subsystem;
(3): select M search results pages of access frequency maximum from disk subsystem, and M the search results pages of selecting is stored in memory subsystem, M the search results pages that deletion is selected from disk subsystem;
(4): M the search results pages of storing in shared drive is stored in disk subsystem.
Wherein, M is the threshold value that arranges in advance.
Further, every one-period, according to user journal, the access frequency of each the retrieval string in the Cache system of statistics search engine, obtain N retrieval string and the Search Results corresponding to each retrieval string of access frequency maximum from the Cache system of search engine, be assembled into search results pages with obtaining Search Results corresponding to each retrieval string, and each search results pages of assembly unit is stored in file system, the file that the search results pages of each assembly unit is set is called the retrieval string of its correspondence;
Wherein, periodically carry out this operation, the detailed process of each operation is divided into the step of following (1)-(3), comprising:
(1): the access frequency of each retrieval string intrasystem according to user journal statistics Cache in current period;
Particularly, for one in Cache system retrieval string, the access times of this retrieval string of statistics in current period in user journal are with the access frequency of these access times as this retrieval string; Count as stated above the access frequency of each the retrieval string in the Cache system.
(2): each the retrieval string in the Cache system is sorted from big to small by separately access frequency, and choose retrieval string and the Search Results corresponding to each retrieval string of top n access frequency maximum.
Wherein, N is the threshold value that arranges in advance.
(3): for one of them retrieval string and should search results pages corresponding to retrieval string, as a Html file, and the filename of Html file is set to this retrieval and goes here and there with this search results pages, then this search results pages is stored in file system; By above-mentioned identical method, search results pages corresponding to each retrieval string is stored in file system.
particularly, judge that unappropriated space in file system is whether more than or equal to the needed space of this search results pages of storage, if, the filename of this search results pages is set to this retrieval string, and this search results pages is stored in file system, if not, adopt existing superseded algorithm that the search results pages of nearest least referenced is cleaned it out from file system, until the unappropriated space in file system is during more than or equal to the space of needs of this search results pages of storage, the filename of this search results pages is set to this retrieval string again, and this search results pages is stored in file system.
In embodiments of the present invention, when receiving retrieval request, directly search for corresponding search results pages according to the retrieval string that carries in this retrieval request from file system, if search out corresponding search results pages, increase the access frequency of this search results pages and return to this search results pages to client.So, reduced the number of times that creates the CGI process, reduced the CGI process and forwarded the number of times of retrieval request and reduced the number of times of cancelling the CGI process, thereby reduced the consumption of time and resource.
Embodiment 3
As shown in Figure 3, the embodiment of the present invention provides a kind of equipment of high-speed cache, comprising:
Search module 301 be used for to receive the retrieval request of carrying the retrieval string, goes here and there the search results pages of storing in the search file system according to this retrieval;
Increase progressively module 302, if be used for searching out corresponding search results pages, increase the access frequency of this search results pages;
Memory module 303 if be used for not searching out corresponding search results pages, is searched for Search Results corresponding to this retrieval string by search engine, and the Search Results of searching for is assembled into search results pages and is stored in file system.
Wherein, under the first implementation in the present embodiment, memory module 303 specifically comprises:
The first search unit is used for searching for Search Results corresponding to this retrieval string by search engine, and the Search Results of searching for is assembled into search results pages;
The first judging unit is used for judge that file system unappropriated space is whether more than or equal to the needed space of the search results pages of storing assembly unit;
The first storage unit, be used for if, the search results pages of assembly unit is stored in described file system, and file this retrieval by name that the search results pages of assembly unit is set go here and there with and the initial value of access frequency;
The second storage unit, be used for if not, eliminate in file system the search results pages of least referenced recently, until when in file system, unappropriated space is more than or equal to the search results pages needed space of storage assembly unit, the search results pages of assembly unit is stored in file system;
Wherein, under the second implementation in the present embodiment, file system comprises memory subsystem and disk subsystem;
Correspondingly, memory module 303 specifically comprises:
The second search unit is used for searching for Search Results corresponding to this retrieval string by search engine, and the Search Results of searching for is assembled into search results pages;
The second judging unit is used for judge that whether memory subsystem unappropriated space is more than or equal to the needed space of search results pages of storing assembly unit;
The 3rd storage unit is yes if be used for the result of the second judgment unit judges, and the search results pages with assembly unit is stored in memory subsystem;
The 4th storage unit, if it is no being used for the result of the second judgment unit judges, the search results pages of the nearest least referenced in memory subsystem is eliminated in disk subsystem, until when in memory subsystem, unappropriated space is more than or equal to the search results pages of storage assembly unit, the search results pages of assembly unit is stored in memory subsystem;
Wherein, on the basis of the second implementation, the 4th storage unit specifically comprises:
Judgment sub-unit, the result that is used for the second judgment unit judges is no, judges that in disk subsystem, whether unappropriated space is more than or equal to the needed space of the search results pages of the nearest least referenced in the stored memory subsystem;
The first deletion subelement is used for if the search results pages of nearest least referenced is stored in disk subsystem the search results pages of the nearest least referenced in the deletion memory subsystem;
The second deletion subelement, be used for if not, eliminate the search results pages of the nearest least referenced in disk subsystem, the search results pages of nearest least referenced in memory subsystem is stored in disk subsystem, until when in disk subsystem, unappropriated space is more than or equal to the search results pages of the nearest least referenced in the stored memory subsystem, and the search results pages of the nearest least referenced in the deletion memory subsystem;
Further, under above any one implementation, this equipment also comprises:
The exchange module, be used for every one-period, the first threshold search results pages of the access frequency minimum in memory subsystem is eliminated in disk subsystem, the first threshold search results pages of the access frequency maximum in disk subsystem is loaded in memory subsystem;
Further, under above any one implementation, this equipment also comprises:
Module is set, and the filename that is used for the search results pages of described assembly unit is set to described retrieval string, and the initial value of access frequency that the search results pages of described assembly unit is set.
Further, under above any one implementation, this equipment also comprises:
Eliminate module, be used for every one-period, according to user journal, eliminate the search results pages of the nearest least referenced in file system;
Further, under above any one implementation, this equipment also comprises:
Load-on module, be used for each cycle, according to user journal, the access frequency of statistics each retrieval string in described Cache system in current period, obtain Second Threshold retrieval string and its corresponding Search Results of access frequency maximum from described Cache system, the Search Results that obtains is assembled into search results pages, the search results pages of assembly unit is carried in file system, and the filename of the search results pages of the assembly unit retrieval string that is set to obtain.
Wherein, this equipment can be Web server.
In embodiments of the present invention, when receiving the request of carrying the retrieval string, according to this retrieval string direct search file system, if search out corresponding search results pages, increase the access times of this search results pages, otherwise, then search for Search Results corresponding to this retrieval string, Search Results is assembled into search results pages and is stored in file system.So, reduce the number of times that creates the CGI process, reduce the CGI process and forward the number of times of retrieval request and reduce the number of times of destroying the CGI process, thus the consumption of minimizing time and resource.
All or part of content in the technical scheme that above embodiment provides can realize by software programming, and its software program is stored in the storage medium that can read, storage medium for example: the hard disk in computing machine, CD or floppy disk.
The above is only preferred embodiment of the present invention, and is in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, is equal to replacement, improvement etc., within all should being included in protection scope of the present invention.