CPC G06F 16/24552 (2019.01) [G06F 16/2393 (2019.01); G06F 16/951 (2019.01); G06F 16/953 (2019.01); G06F 16/9574 (2019.01)] | 18 Claims |
1. A method for updating search cache, comprising:
when hot content is updated, extracting a first search term corresponding to information of the hot content, and updating the first search term into a pre-established first database, wherein, the hot content is preset by means of term segmentation or determined according to update frequency, and the first database stores a search term of hot content;
wherein cache content of a search result for the search term of hot content is stored in a pre-established second database, wherein a valid time of the search term of hot content in the first database is set to be longer than a valid time of the cache content of the search result for the search term of hot content in the second database;
when a search request is received, querying the first database according to a search term in the search request and determining whether a second search term identical to the search term in the search request is obtained, to determine whether the search request is for hot content or for non-hot content, wherein when the second search term is obtained, it is indicated that the search request is for hot content; otherwise, it is indicated that the search request is for non-hot content;
when the second search term is obtained and determined to be valid, querying the second database according to the second search term to obtain cache content of a first search result, wherein, when the second search term is determined to be valid, it is indicated that the second search term is still within a valid period and information corresponding to this second search term is still hot content; and
determining whether the cache content of the first search result is valid; if the cache content of the first search result is valid, taking information in the cache content of the first search result as a first search request result; if the cache content of the first search result is not valid, forwarding the search request to a search engine, obtaining a second search request result and updating the second search request result into the second database;
wherein, determining that the second search term is valid comprises:
determining a first difference between a timestamp of obtaining the second search term and a timestamp of writing the second search term;
if the first difference is smaller than a first preset valid period, determining that the second search term is valid; and
determining whether the cache content of the first search result is valid comprises:
determining a second difference between a timestamp of obtaining the cache content of the first search result and a timestamp of writing the cache content of the first search result;
determining whether the cache content of the first search result is valid according to whether the second difference is smaller than a second preset valid period.
|