Shared cache data query method and device, storage medium and electronic equipment

By using a shared caching method, the hash values ​​of multiple similar words are stored in the first-level cache, and the target data is stored in the second-level cache. This solves the problem of wasted cache storage space and achieves storage space saving and improved query efficiency.

CN121365073APending Publication Date: 2026-01-20BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511283522.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-09
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

In existing technologies, cache storage space is heavily occupied, leading to waste.

Method used

A shared caching method is adopted, which stores the hash values ​​of multiple similar words in the first-level cache and stores the mapping of the target data in the second-level cache, thereby reducing the number of hash values ​​stored.

Benefits of technology

It saves cache storage space, improves query efficiency, and reduces the amount of hash values ​​to be stored.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365073A_ABST
    Figure CN121365073A_ABST
Patent Text Reader

Abstract

The invention relates to a shared cache data query method and device, a storage medium and electronic equipment. The method comprises the steps that when a query text of a user is obtained, keywords are obtained from the query text; according to the keyword, a target hash value matched with the keyword is inquired from a first-level cache, each hash value in the first-level cache corresponds to a set of words, and the set of words comprise a plurality of words similar to one another; when the target hash value is queried, determining mapping of target data matched with the target hash value from a second-level cache according to the target hash value, and acquiring the target data from a database according to the mapping; and returning the target data to the user. The technical problem that a large amount of storage space of the cache is occupied is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data query, and in particular to a data query method and device sharing cache, a storage medium and an electronic device. BACKGROUND

[0002] With the development of the Internet, in the prior art, when data in a database is queried, a unique identifier can be generated from a keyword in a cache, and the corresponding data is queried from the database using the unique identifier.

[0003] However, the above method generates a unique identifier for each keyword, and the unique identifier is stored in the cache, resulting in a large amount of cache occupation and wasting of cache storage space. SUMMARY

[0004] The present application provides a data query method and device sharing cache, a storage medium and an electronic device to solve the technical problem of a large amount of cache storage space being occupied.

[0005] In a first aspect, the present application provides a data query method and device sharing cache, comprising: when a query text of a user is obtained, a keyword is obtained from the query text; according to the keyword, a target hash value matching the keyword is queried from a first cache, wherein each hash value in the first cache corresponds to a group of words, and the group of words includes a plurality of mutually similar words; when the target hash value is queried, according to the target hash value, a mapping of target data matching the target hash value is determined from a second cache, and the target data is obtained from a database according to the mapping; and the target data is returned to the user.

[0006] In a second aspect, the present application provides a data query device sharing cache, comprising: an acquisition module configured to obtain a keyword from a query text of a user when the query text is obtained; a first query module configured to query a target hash value matching the keyword from a first cache according to the keyword, wherein each hash value in the first cache corresponds to a group of words, and the group of words includes a plurality of mutually similar words; a second query module configured to determine a mapping of target data matching the target hash value from a second cache according to the target hash value when the target hash value is queried, and obtain the target data from a database according to the mapping; and a sending module configured to return the target data to the user.

[0007] The first query module can include a first query unit configured to calculate a first hash value of the keyword, compare the first hash value with each hash value in the first cache, and determine an existing hash value as the target hash value when there is a hash value matching the first hash value in the first cache.

[0008] The first query unit can include a comparison subunit configured to regard the first hash value and each hash value in the first cache as a set respectively, compare the similarity between the first hash value set and each hash value set in the first cache by using a hash comparison algorithm, and determine the matching degree of the hash values according to the similarity of the sets.

[0009] The device can further include a determination module configured to determine that the target hash value is not included in the first cache when all hash values in the first cache do not match the first hash value after comparing the first hash value with each hash value in the first cache.

[0010] The first query module can further include a second query unit configured to determine the first hash value of the keyword according to each stroke and the order relationship between strokes of the keyword, compare the first hash value with each hash value in the first cache, determine the proportion of the same sequence in the hash values, and determine the hash value with the proportion exceeding a preset value in the hash values in the first cache as the target hash value.

[0011] The device can further include a processing module configured to search for a mapping of the target data matching the keyword from the second cache according to the first hash value of the keyword when the target hash value is not found in the first cache, store the first hash value in the first cache when the mapping of the target data is found, search for the target data from the memory according to the keyword when the mapping of the target data is not found, store the first hash value of the keyword in the first cache, and store the mapping of the target data in the second cache.

[0012] The device can further include a deletion module configured to delete the hash value in the first cache after being stored in the first cache for a first time length, and delete the mapping data in the second cache after being stored in the second cache for a second time length, wherein the first time length is shorter than the second time length.

[0013] In a third aspect, the present application provides an electronic device, comprising: at least one communication interface; at least one bus connected with the at least one communication interface; at least one processor connected with the at least one bus; at least one memory connected with the at least one bus, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the shared cache data query method of any one of the above aspects.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the shared cache data query method of any one of the above aspects.

[0015] The above technical solution provided by the embodiments of the present application has the following advantages compared with the prior art: when the query text of the user is obtained, the key word is obtained from the query text; the target hash value matching the key word is queried from the first-level cache according to the key word, wherein each hash value in the first-level cache corresponds to a group of words, and the group of words includes a plurality of mutually approximate words; when the target hash value is queried, the mapping of the target data matching the target hash value is determined from the second-level cache according to the target hash value, and the target data is obtained from the database according to the mapping; and the target data is returned to the user, so that the mutually approximate words can be queried to the same hash value, and thus only a small amount of hash values need to be stored in the first-level cache, thereby saving the storage space of the cache. BRIEF DESCRIPTION OF DRAWINGS

[0016] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed in the embodiment or prior art description will be briefly introduced as follows, and obviously, other drawings can also be obtained by those skilled in the art without any creative labor under the premise of these drawings.

[0018] One or more embodiments are exemplarily illustrated by the pictures in the drawings corresponding thereto, and these exemplary illustrations do not constitute a limitation on the embodiments, and the elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified, and the drawings in the drawings do not constitute a proportional limitation.

[0019] Figure 1 A flowchart of a shared cache data query method provided by the embodiments of the present application is shown in FIG. 1;

[0020] Figure 2 FIG. 1 is a flowchart of another data query method of sharing cache provided by an embodiment of the present application;

[0021] Figure 3 FIG. 1 is a flowchart of another data query method of sharing cache provided by an embodiment of the present application;

[0022] Figure 4 FIG. 1 is a flowchart of another data query method of sharing cache provided by an embodiment of the present application;

[0023] Figure 5 FIG. 1 is a flowchart of another data query method of sharing cache provided by an embodiment of the present application;

[0024] Figure 6 FIG. 1 is a flowchart of another data query method of sharing cache provided by an embodiment of the present application; DETAILED DESCRIPTION

[0025] To make the objectives, technical schemes and advantages of the embodiments of the present application clearer, the technical schemes in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0026] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present application. For the purpose of simplification, the components and arrangements of the specific examples are described in the following. Of course, they are only examples and the purpose is not to limit the present application. In addition, the present application can repeatedly refer to the numbers and / or letters in different examples. Such repetition is for the purpose of simplification and clarity, and it does not indicate the relationship between the various embodiments and / or arrangements discussed.

[0027] To solve the technical problem that the storage space of the cache is occupied in large quantities in the prior art, the present application provides a data query method of sharing cache, which achieves the effect of saving the storage space of the cache.

[0028] Figure 1 FIG. 1 is a flowchart of a data query method of sharing cache provided by an embodiment of the present application. As shown in FIG. 1, the data query method of sharing cache comprises the following steps. Figure 1

[0029] S102, when the query text of the user is acquired, acquiring the keyword from the query text;

[0030] ​S104, query, from the primary cache, a target hash value matching the keyword according to the keyword, wherein each hash value in the primary cache corresponds to a set of words, and the set of words includes a plurality of mutually approximate words;

[0031] S106, when the target hash value is queried, determine, from the secondary cache according to the target hash value, a mapping of the target data matching the target hash value, and obtain the target data from the database according to the mapping;

[0032] S108, return the target data to the user.

[0033] The above-mentioned data query method of the shared cache can be applied in the process of querying data in the database. The application scenario can be a scenario where the user searches for videos, episodes, electronic coupons, activities, etc. with user input content.

[0034] The above-mentioned query text is the text provided for the user, that is, the text input by the user or the text obtained by converting the user's voice into text. The text is used to express the user's intention, that is, what the user wants to search for.

[0035] The present example can obtain keywords from the query text, and the keywords are part or all of the words in the query text. The query text can be segmented to obtain a plurality of segmented words, and then the remaining keywords are obtained by removing non-controversial or conjunction words from the plurality of segmented words. For example, prepositions and adverbs in the segmented words can be removed, and nouns or verbs can be retained.

[0036] After obtaining the keywords, the matching target hash value can be queried from the primary cache according to the keywords. The target hash value is one of the hash values in the primary cache. The primary cache stores zero to multiple hash values, and each hash value corresponds to a set of words. The plurality of words in the set of words are mutually approximate.

[0037] In the present example, each hash value stored in the primary cache is a hash value commonly matched by a plurality of words. The plurality of mutually approximate words are commonly matched to the same hash value, so that the hash value is stored in the primary cache. When searching for any one of the plurality of approximate words, the hash value in the primary cache is matched. Thus, each keyword does not correspond to a hash value in the primary cache, thereby saving the storage space of the cache.

[0038] The above-mentioned primary cache and secondary cache can be different storage spaces in the cache space of the computer. The read-write speed of the primary cache is higher than that of the secondary cache, and the capacity of the primary cache is smaller than that of the secondary cache.

[0039] When the target hash value is queried from the primary cache according to the keyword, there can be multiple cases. One case is that the target hash value cannot be queried from the primary cache, i.e., there is no hash value matching the keyword. In this case, the corresponding target hash value cannot be obtained from the primary cache, and the mapping of the target data cannot be found from the secondary cache. In this case, the target data corresponding to the keyword needs to be searched from the database according to the keyword. Another case is that the target hash value can be queried from the primary cache, which means that the keyword has been searched before or the mutually approximate words of the keyword have been searched before. The keyword and the mutually approximate words searched before are mapped to the target hash value, and the mapping of the target data matching the target hash value is searched from the secondary cache. According to the mapping, the target data can be obtained from the database.

[0040] After the target data is returned to the user, the user queries the target data according to the query text.

[0041] The scheme provided by the embodiment of the application obtains the keyword from the query text when the query text of the user is obtained; the target hash value matching the keyword is queried from the primary cache according to the keyword, wherein each hash value in the primary cache corresponds to a group of words, and the group of words includes multiple mutually approximate words; when the target hash value is queried, the target data matching the target hash value is determined from the secondary cache according to the target hash value; and the target data is returned to the user, so that the mutually approximate words can be queried to the same hash value, and therefore only a small amount of hash values need to be stored in the primary cache, thereby saving the storage space of the cache.

[0042] Exemplarily, since the target hash value needs to be queried from the primary cache according to the keyword, the method for querying the target hash value is given in this example.

[0043] A method for querying the target hash value matching the keyword from the primary cache according to the keyword is shown in Figure 2

[0044] S202, a first hash value of the keyword is calculated;

[0045] S204, the first hash value is compared with each hash value in the primary cache;

[0046] S206, when there is a hash value matching the first hash value in the primary cache, the existing hash value is determined as the target hash value.

[0047] ​In this example, whether the hash values match can be that the approximation degree of the hash values exceeds a certain limit value. According to the keywords, the first hash value of the keywords can be calculated, and then the first hash value is compared with each hash value in the first-level cache to check whether the first-level cache includes a hash value that matches the first hash value. If a matching hash value can be found, it means that there is a hash value in the first-level cache with a relatively high approximation degree to the first hash value of the keywords, and the found hash value is the target hash value.

[0048] Exemplarily, if the first hash value is compared with the target hash value, the first hash value and each hash value in the first-level cache can be regarded as a set respectively; the similarity between the set of the first hash value and the set of each hash value in the first-level cache is compared through a hash comparison algorithm; the matching degree of the hash values is determined according to the similarity level of the sets. There can be multiple algorithms for comparison. In this example, a locality-sensitive hashing algorithm can be used, such as the simhash algorithm or the minhash algorithm.

[0049] For example, if the simhash algorithm is used to match hash values, then when calculating the first hash value, the query text can be segmented to obtain the keywords therein. For example, Chinese word segmentation can divide "Huai River Bamboo Pavilion" into ["Huai River", "Bamboo Pavilion"]. If there are redundant prepositions, adverbs, meaningless words, etc., they can all be removed, such as words like "of", "and". Next, the weight or simple word frequency of each word is counted. For example: "Huai River" appears 1 time, "Bamboo Pavilion" appears 1 time, and the weights are both 1. If it appears multiple times, the weight is the number of times it appears. Next, a 64-bit SimHash is generated. If the weight of each bit is greater than zero, the corresponding bit of the hash value is 1, otherwise the hash value is zero.

[0050] In this example, the number of keywords determines the number of first hash values. The first hash values form a first set, and each hash value in the first-level cache forms a second set. The similarity between the first set and each second set is calculated through the simhash algorithm or the minhash algorithm, so as to determine the most matching target set from the second sets, and the hash value corresponding to the target set is the target hash value.

[0051] Another method for querying the target hash value that matches the keywords from the first-level cache is as Figure 3 shown:

[0052] S302, determine the first hash value of the keyword according to the strokes of each stroke and the sequential relationship between strokes;

[0053] S304, compare the first hash value with each hash value in the first-level cache to determine the proportion of the same sequence in the hash values;

[0054] S306, determine the hash value whose proportion exceeds the preset value in the first cache as the target hash value.

[0055] In the above example, the corresponding target hash value can be matched from the first cache through an algorithm. In this example, the target hash value in the first cache can be matched through the strokes and stroke order of the keyword.

[0056] In this example, when calculating the hash value of the keyword, a method is proposed to calculate the strokes and the order between the strokes of the keyword as the hash value, so that the hash value records the strokes and the order of the keyword. For example, horizontal is 000, vertical is 001, stroke is 010, n is 011, dot is 100, bend is 101, lift is 110, and hook is 111. Thus, for the strokes, a string of characters can be generated, which can be regarded as a hash value, and the order of the characters in the string represents the order between the strokes of the keyword. Through this method, the keyword is converted into a string of characters, which can be regarded as obtaining a first hash value. The hash values in the first cache are also calculated in the same way, so the first hash value is compared with the hash values in the first cache to check the length of the same sequence contained in the two hash values. The longer the length of the same sequence, the higher the similarity of the keywords corresponding to the hash values.

[0057] Through this method, the hash value in the first cache whose length of the same sequence as the first hash value exceeds a certain preset value is determined as the target hash value.

[0058] After the target hash value is determined, if the target hash value can be determined from the hash values in the first cache, the target hash value can be used to search the mapping of the target data from the second cache. If the target hash value cannot be found in the first cache, it means that there is no hash value matching the keyword in the first cache. At this time, the first hash value of the keyword is used to search the corresponding target data from the database.

[0059] In this example, when the keyword is used and the target hash value is not found in the first cache, the first hash value of the keyword is used to search the mapping of the target data matching the keyword from the second cache. When the mapping of the target data is found, the first hash value is stored in the first cache. When the mapping of the target data is not found, the keyword is used to search the target data from the memory, the first hash value of the keyword is stored in the first cache, and the mapping of the target data is stored in the second cache.

[0060] The flow in this example is that after calculating the first hash value using the keyword, the target hash value matching the first hash value is searched from the first cache. If the target hash value cannot be searched from the first cache, the first hash value is used as the target hash value to search the mapping of the target data from the second cache. If the mapping of the target data can be searched, the first hash value is stored in the first cache as the target hash value. If the mapping of the target data cannot be searched from the second cache using the first hash value as the target hash value, the target data is queried from the database using the first hash value, and the mapping of the queried target data is stored in the second cache, and the first hash value is stored in the first cache as the target hash value. In this way, when the word in the query text is a word similar to the keyword, since the keyword has been stored in the hash value to the first cache and the mapping of the target data to the second cache, the word similar to the keyword can match the target hash value from the first cache after determining the hash value, and further match the mapping of the target data from the second cache, so that the target data is obtained from the database according to the mapping and returned to the user.

[0061] Figure 4 The example is to query the target data by simhash. When the calculated hash value is stored in the first cache, it can be stored in the structure of (Redis Hash). For example, the above example of "Huai Shui Zhu Ting" can be stored as: Key: "simhash:{simhash value}" Value: {"query":"Huai Shui Zhu Ting", "code":"WELFARE_001"}. For the words similar to the keyword, the same hash value is corresponded.

[0062] The storage structure of the second cache can be the structure of (Redis String), for example, Key: "welfare:{code}", Value: JSON.stringify({"name":"Huai Shui Zhu Ting", "discount":"50%",...}).

[0063] In this way, when "Huai Shui Zhu Ting" or "Huai Shui", "Zhu Ting" and the like are queried, the same hash value is hit in the first cache, the mapping is queried from the second cache using the hash value, and the target data corresponding to the mapping is further obtained from the database. For the hash value in the first cache, it can be deleted after being stored in the first cache for a first time length, and the mapping of the target data in the second cache can be deleted after being stored in the second cache for a second time length, wherein the first time length is shorter than the second time length. For the memory, the least recently used strategy can be used to periodically clean the data in the memory.

[0064] Through the means of periodic cleaning, the data in the first-level cache and the second-level cache can not be too much, and can be kept in a suitable order of magnitude, which not only ensures that the mapping of the hash value and the target data exists in the cache, so that the user's query execution can quickly query the target data, but also, through the sharing of the hash value by the keywords that are similar to each other and the periodic cleaning, the storage space of the cache will not be too much.

[0065] Figure 5 A structural schematic diagram of a shared cache data query device provided by an embodiment of the present application is shown in FIG. 1. Figure 5 As shown in the figure, the shared cache data query device includes:

[0066] The obtaining module 502 is configured to obtain keywords from the query text when the query text of the user is obtained.

[0067] The first query module 504 is configured to query a target hash value that matches the keywords from the first-level cache according to the keywords, wherein each hash value in the first-level cache corresponds to a group of words, and the group of words includes multiple words that are similar to each other.

[0068] The second query module 506 is configured to determine the mapping of the target data that matches the target hash value from the second-level cache according to the target hash value when the target hash value is queried, and obtain the target data from the database according to the mapping.

[0069] The sending module 508 is configured to return the target data to the user.

[0070] The shared cache data query method of the present application can be applied in the process of querying the data in the database. The application scenario can be a scenario in which the user searches for videos, episodes, electronic coupons, activities, etc.

[0071] The query text is the text provided by the user, that is, the text input by the user or the text obtained by converting the user's voice into text. The text is used to express the user's intention, that is, what the user wants to search for.

[0072] The present example can obtain keywords from the query text. The keywords are part or all of the words in the query text. The query text can be segmented to obtain multiple segmented words, and then the non-controversial or conjunction words in the multiple segmented words are removed to obtain the remaining keywords. For example, the prepositions and adverbs in the segmented words can be removed, and the nouns or verbs are retained.

[0073] After the keywords are obtained, the matching target hash value can be queried from the first-level cache according to the keywords. The target hash value is one of the hash values in the first-level cache. The first-level cache stores zero to multiple hash values, and each hash value corresponds to a group of words. The multiple words in the group of words are similar to each other.

[0074] In this example, each hash value stored in the first cache is a hash value matched by multiple words, and the multiple similar words are matched to the same hash value, so that the hash value is stored in the first cache. When searching for any one of the multiple similar words, the hash value in the first cache is matched. Therefore, each keyword does not correspond to a hash value in the first cache, saving the storage space of the cache.

[0075] The first cache and the second cache described above can be different storage spaces in the cache space of the computer. The read-write speed of the first cache is higher than that of the second cache, and the capacity of the first cache is smaller than that of the second cache.

[0076] When the target hash value is queried from the first cache according to the keyword, there can be multiple cases. One case is that the target hash value cannot be queried from the first cache, that is, there is no hash value matched with the keyword. In this case, the corresponding target hash value cannot be obtained from the first cache, and the mapping of the target data cannot be found from the second cache. In this case, the target data corresponding to the keyword needs to be searched from the database according to the keyword. Another case is that the target hash value can be queried from the first cache, which means that the keyword has been searched before or the similar words of the keyword have been searched before. The keyword and the similar words searched before are all mapped to the target hash value, and the mapping of the target data matched with the target hash value is searched from the second cache. According to the mapping, the target data can be obtained from the database.

[0077] After the target data is returned to the user, the user queries the target data according to the query text.

[0078] The scheme provided by the embodiment of the present application acquires the keyword from the query text when the query text of the user is acquired; queries the target hash value matched with the keyword from the first cache according to the keyword, wherein each hash value in the first cache corresponds to a group of words, and the group of words includes multiple similar words; when the target hash value is queried, the target data matched with the target hash value is determined from the second cache according to the target hash value; and the target data is returned to the user, so that the similar words can be queried to the same hash value, and only a small amount of hash values need to be stored in the first cache, thereby saving the storage space of the cache.

[0079] Illustratively, the first query module can include a first query unit for calculating a first hash value of the keyword; comparing the first hash value with each hash value in the first cache; when there is a hash value matched with the first hash value in the first cache, the existing hash value is determined as the target hash value.

[0080] For example, the first query unit may include a comparison subunit, which is used to treat the first hash value and each hash value in the first-level cache as a set respectively; compare the similarity between the set of the first hash value and the set of each hash value in the first-level cache using a hash comparison algorithm; and determine the matching degree of the hash value based on the similarity of the sets.

[0081] For example, the above apparatus may further include a determining module, configured to determine that the target hash value is not included in the first-level cache when, after comparing the first hash value with each hash value in the first-level cache, all hash values ​​in the first-level cache do not match the first hash value.

[0082] For example, the first query module may further include a second query unit, used to determine the first hash value of the keyword according to the number of strokes of each stroke and the order relationship between strokes; compare the first hash value with each hash value in the first-level cache to determine the proportion of the same sequence in the hash values; and determine the hash values ​​in the first-level cache whose proportion exceeds a preset value as the target hash value.

[0083] For example, the apparatus may further include a processing module for searching for a mapping of target data matching the keyword in a second-level cache when the target hash value is not found in the first-level cache; storing the first hash value in the first-level cache when the mapping of the target data is found; and searching for target data in memory when the target data is not found when the target hash value is not found, storing the first hash value of the keyword in the first-level cache, and storing the mapping of the target data in the second-level cache.

[0084] For example, the apparatus may further include a deletion module for deleting hash values ​​in the first-level cache after a first period of time after they are stored in the first-level cache; and for deleting mapping data in the second-level cache after a second period of time after they are stored in the second-level cache, wherein the first period of time is shorter than the second period of time.

[0085] For other examples of this embodiment, please refer to the examples above, which will not be repeated here.

[0086] like Figure 6 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0087] Memory 113 is used to store computer programs;

[0088] In an embodiment of the present application, the processor 111, when executing the program stored in the memory 113, implements the shared cache data query method provided by any one of the foregoing method embodiments.

[0089] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the shared cache data query method provided by any one of the foregoing method embodiments.

[0090] The apparatus embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0091] Through the description of the foregoing embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, or by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, or an optical disk, and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0092] It should be understood that the terms used herein are for the purpose of describing particular example embodiments only and are not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order in which they are described, unless specifically indicated as such. It is also to be understood that additional or alternative steps can be employed.

[0093] The foregoing is considered as illustrative only of the principles of the application. Numerous modifications and changes will readily occur to those skilled in the art, and it is intended to embrace all such modifications and changes that fall within the scope of the application. Accordingly, the application is not to be restricted in scope to the specific embodiments disclosed herein but is to be accorded the full scope that the principles and novel features request appropriately granted.

Claims

1. A data query method of a shared cache, characterized by, The method comprises the following steps: When the query text of the user is obtained, a keyword is obtained from the query text; According to the keyword, a target hash value matching the keyword is queried from a primary cache, wherein each hash value in the primary cache corresponds to a group of words, and the group of words comprises a plurality of mutually approximate words; When the target hash value is queried, a mapping of target data matching the target hash value is determined from a secondary cache according to the target hash value, and the target data is obtained from a database according to the mapping; The target data is returned to the user.

2. The method of claim 1, wherein, The step of querying the target hash value from the primary cache according to the keyword comprises the following steps: A first hash value of the keyword is calculated; The first hash value is compared with each hash value in the primary cache; When a hash value in the primary cache matches the first hash value, the existing hash value is determined as the target hash value.

3. The method of claim 2, wherein, The step of comparing the first hash value with each hash value in the primary cache comprises the following steps: The first hash value and each hash value in the primary cache are respectively regarded as a set; The similarity between the first hash value set and each hash value set in the primary cache is compared through a hash comparison algorithm; The matching degree of the hash value is determined according to the similarity of the set.

4. The method of claim 2, wherein, After the first hash value is compared with each hash value in the primary cache, the method further comprises the following steps: When all hash values in the primary cache do not match the first hash value, it is determined that the target hash value is not included in the primary cache.

5. The method of claim 1, wherein, The step of querying the target hash value from the primary cache according to the keyword comprises the following steps: The first hash value of the keyword is determined according to the strokes and the sequence relationship between the strokes of each stroke; The proportion of the same sequence in the hash value is determined by comparing the first hash value with each hash value in the primary cache; The hash value in the primary cache, whose proportion exceeds a preset value, is determined as the target hash value.

6. The method of claim 1, wherein, After the target hash value matching the keyword is queried from the primary cache according to the keyword, the method further comprises the following steps: When the target hash value is not queried in the primary cache, a mapping of target data matching the keyword is searched from the secondary cache according to the first hash value of the keyword; When the mapping of the target data is searched, the first hash value is stored in the primary cache; When the mapping of the target data is not searched, the target data is searched from the memory according to the keyword, the first hash value of the keyword is stored in the primary cache, and the mapping of the target data is stored in the secondary cache.

7. The method of claim 1, wherein, The method further comprises the following steps: For the hash value in the primary cache, the hash value is deleted after being stored in the primary cache for a first time length; For the mapping data in the secondary cache, the mapping data is deleted after being stored in the secondary cache for a second time length, wherein the first time length is shorter than the second time length.

8. A data query apparatus sharing a cache, characterized by, The method comprises the following steps: An acquisition module is configured to obtain a keyword from a query text of a user when the query text is obtained. The first query module is configured to query a target hash value matching the keyword from a first cache according to the keyword, wherein each hash value in the first cache corresponds to a group of words, and the group of words includes a plurality of mutually approximate words. The second query module is configured to, when the target hash value is queried, determine a mapping of target data matching the target hash value from a second cache according to the target hash value, and acquire the target data from a database according to the mapping. The sending module is configured to return the target data to the user.

9. An electronic device, comprising: The data query method includes: at least one communication interface; at least one bus connected with the at least one communication interface; at least one processor connected with the at least one bus; at least one memory connected with the at least one bus, wherein the memory stores a computer program, and the processor executes the computer program to implement the data query method of the shared cache.

10. A computer readable storage medium, characterized in that, The storage medium stores computer executable instructions, and the computer executable instructions are used to execute the data query method of the shared cache according to any one of the preceding claims 1 to 7. The storage medium stores computer executable instructions, and the computer executable instructions are used to execute the data query method of the shared cache according to any one of the preceding claims 1 to 7.