Summary of the invention
In view of this, the object of the invention is to propose a kind of catalogue method for refreshing of cache file, effectively flush buffers file directory.
Catalogue method for refreshing based on above-mentioned purpose a kind of cache file provided by the invention, comprising:
Cache file in log folder is sorted;
The log folder that sequence is completed merges to Database Folder;
Described Database Folder is equally divided into N subdata base, respectively from the 1st subdata base to N-1 database extracts i cache file as cache file sample, by all cache file Sample preservation indexed file underedges;
In indexed file folder, find out the target cache file in the catalogue that need to refresh, and find this present position of target cache file in Database Folder;
From this target cache file present position Database Folder, ergodic data library archive, in the time that cache file suits the requirements one of target cache file in the catalogue refreshing, deletes this cache file;
In the time that cache file does not meet the arbitrary target cache file in the catalogue that need to refresh, finish.
In one embodiment, the catalogue method for refreshing of described cache file also comprises: the instant proxy caching server cache file producing is saved in to this log folder.
In another embodiment, the catalogue method for refreshing of described cache file also comprises: the cache file number higher limit of setting log folder, in the time that the cache file number of log folder rises to this higher limit, the cache file in log folder is sorted.
In another embodiment, cache file number higher limit is less than or equal to 10000.
In another embodiment, the merge algorithm between described sequence completes log folder and described Database Folder adopts MERGING/SORTING ALGORITHM.
In another embodiment, the sort method of described log folder comprises:
Suppose to have 2 cache files, title is respectively A and B, the length of LenA=A, and the length of LenB=B, establishes LenA≤LenB;
Period m is set and is recycled to LenA from 1, contrast one by one successively m the character of A and B, in the time that the ASCII character of n the character of A is less than the ASCII character of n character of B, think that A should come before B; Otherwise, in the time that the ASCII character of n the character of B is less than the ASCII character of n character of A, think that B should come before A;
In the time being recycled to LenA, on each correspondence position of A and B, all characters equate, so, shorter A comes before longer B; If A and B are completely equal, in the time that log folder and Database Folder merge, appoint and get one of them and put into Database Folder.
In another embodiment, the number N value of described subdata base is 128.
In another embodiment, last cache file that i the cache file extracting is this subdata base, makes extracted sample cache file lay respectively at 1/N, the 2/N in whole Database Folder ... (N-1)/N place.
The present invention also provides the proxy caching server of the catalogue method for refreshing that adopts above-mentioned cache file, comprise: for storing the log folder module of the instant cache file that described proxy caching server produces, be used for the Database Folder module of the history buffer file of storing described proxy caching server generation, carry out the index file clamping piece of index for the history buffer file to Database Folder.
As can be seen from above, the proxy caching server of the catalogue method for refreshing of a kind of cache file provided by the invention and employing the method, by setting up log folder and index file folder, can at any time the instant proxy server cache file producing be preserved, and find at short notice by Index Algorithm the target cache file that needs deletion.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with specific embodiment, and with reference to accompanying drawing, the present invention is described in more detail.
With reference to figure 1, it is the embodiment process flow diagram of the catalogue method for refreshing of a kind of cache file provided by the present invention.
The catalogue method for refreshing of described a kind of cache file comprises the following steps:
Step 1: the cache file in log folder is sorted;
Step 2: the log folder that sequence is completed merges to Database Folder;
Step 3: described Database Folder is equally divided into N subdata base, respectively from the 1st subdata base to N-1 database extracts i cache file as cache file sample, by all cache file Sample preservation indexed file underedges;
Step 4: find out the target cache file in the catalogue that need to refresh in indexed file folder, and find this present position of target cache file in Database Folder;
Step 5: from this target cache file present position Database Folder, ergodic data library archive, in the time that cache file suits the requirements one of target cache file in the catalogue refreshing, deletes this cache file;
Step 6: in the time that cache file does not meet the arbitrary target cache file in the catalogue that need to refresh, finish.
Wherein, also comprise initialization step: in proxy caching server, set up log folder, and the instant proxy caching server cache file producing is saved in to this log folder.
The sort method of described log folder is:
Suppose to have 2 cache files, title is respectively A and B, the length of LenA=A, and the length of LenB=B, might as well establish LenA≤LenB;
Period m is set and is recycled to LenA from 1, contrast one by one successively m the character of A and B, in the time that the ASCII character of n the character of A is less than the ASCII character of n character of B, think that A should come before B; Otherwise, in the time that the ASCII character of n the character of B is less than the ASCII character of n character of A, think that B should come before A;
In the time being recycled to LenA, on each correspondence position of A and B, all characters equate, so, shorter A comes before longer B; If A and B are completely equal, in the time that log folder and Database Folder merge, appoint and get one of them and put into Database Folder.
Can find out according to the above, in proxy caching server, increase a log folder and an index file folder are set, can at any time the instant cache file producing in proxy caching server be preserved, and adopt Index Algorithm to be clipped in the target cache file that just can find required deletion in Database Folder within several milliseconds by index file, simultaneously effectively, stablize, delete rapidly this target cache file.
Preferably, described step 1 also comprises: set the cache file number higher limit of log folder, in the time that the cache file number of log folder rises to this higher limit, the cache file in log folder is sorted.
Preferably, described higher limit is less than or equal to 10000; Because this higher limit is very little, the speed that sorts is very fast.
In addition, because Database Folder is to be accumulated by log folder each time in history, although may there be up to ten million records, it is orderly all the time.And the merge algorithm between the log folder that described sequence completes and described Database Folder adopts MERGING/SORTING ALGORITHM.
Preferably, the number N value of described subdata base is 128, and so, index file folder can be not excessive, can not cause because index number is very few again having looked into after index the overlong time of sequential search in Database Folder.
Especially, last cache file that i the cache file extracting is subdata base, makes extracted sample cache file lay respectively at 1/N, the 2/N in whole Database Folder ... (N-1)/N place; So just, reduced the process that order is searched plain Database Folder.
The invention also discloses a kind of proxy caching server of combination in any of the catalogue method for refreshing that adopts above-mentioned cache file, comprise: for storing the log folder module of the instant cache file that described proxy caching server produces, be used for the Database Folder module of the history buffer file of storing described proxy caching server generation, carry out the index file clamping piece of index for the history buffer file to Database Folder.
Preferably, the method of the foundation of the index file folder in described index file clamping piece is: described Database Folder is equally divided into N subdata base, from the 1st subdata base to N-1 database, i cache file of each extraction is as cache file sample, by all cache file Sample preservation indexed file underedges.
Preferably, the number N value of described subdata base is 128, and so, index file folder can be not excessive, can not cause because index number is very few again having looked into after index the overlong time of sequential search in Database Folder.
Especially, last cache file that i the cache file extracting is subdata base, makes extracted sample cache file lay respectively at 1/N, the 2/N in whole Database Folder ... (N-1)/N place; So just, reduced the process that order is searched plain Database Folder.
Especially, can also set the cache file number higher limit of log folder in described log folder module, in the time that the cache file number of log folder rises to this higher limit, the cache file in log folder be sorted; Preferably, described cache file number higher limit is less than or equal to 10000.
Wherein, preferred, the merge algorithm between the log folder that described sequence completes and described Database Folder adopts MERGING/SORTING ALGORITHM.
Can find out according to the above, in described proxy caching server, increase a log folder and an index file folder are set, can at any time the instant cache file producing in proxy caching server be preserved, and adopt Index Algorithm to be clipped in the target cache file that just can find required deletion in Database Folder within several milliseconds by index file, simultaneously effectively, stablize, delete rapidly this target cache file.
Those of ordinary skill in the field are to be understood that: the foregoing is only specific embodiments of the invention; be not limited to the present invention; within the spirit and principles in the present invention all, any amendment of making, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.