Cache optimization method and device, equipment, medium and product
By introducing slot sets and template identifiers into the intelligent question-answering system, the cache is dynamically matched and updated, solving the problem of low cache hit rate and achieving more efficient cache management and query response.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, the cache hit rate of intelligent question answering systems is low because the same key slots and parameters may generate different structured query statements, causing the caching system to fail to accurately match the user's actual needs.
By introducing slot sets and template identifiers, user query information is parsed to generate a structured parameter set. A dynamically generated unique route identifier is used to dynamically select the cache level for matching and implement a dynamic update strategy to ensure the accuracy and efficiency of the cached results.
It improves cache hit rate, reduces cache confusion and redundancy, and enhances system response speed and resource utilization.
Smart Images

Figure CN121858624A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer science, and more particularly to a cache optimization method, apparatus, device, medium, and product. Background Technology
[0002] With the development of information technology, people's demand for information access is increasing. To meet this demand, various intelligent question-answering systems have emerged. These systems use natural language processing technology to enable users to obtain the information they need in a convenient way.
[0003] In existing technologies, the system parses the user's natural language input to identify key slots and parameters. Then, it uses these slots and parameters to generate corresponding structured query statements. These query statements interact with the database to obtain the information the user needs. Finally, the query results are presented to the user in natural language format.
[0004] However, existing technologies suffer from low cache hit rates. When generating structured query statements based on identified key slots and parameters, existing technologies may generate different structured query statements for the same key slots and parameters. This causes the caching system to fail to accurately match the user's actual needs, resulting in a low cache hit rate. Summary of the Invention
[0005] This application provides a cache optimization method, apparatus, device, medium, and product to solve the problem of low cache hit rate in the prior art.
[0006] In a first aspect, embodiments of this application provide a cache optimization method applied to a server of a cache optimization system, the cache optimization system further including a client and a database, the method comprising:
[0007] Retrieve query information;
[0008] The query information is input into a preset parsing model to obtain a slot set and a template identifier; wherein, the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content;
[0009] Based on the query information, the slot set, and the template identifier, the results are matched with a preset multi-level cache and multiple preset storage data to obtain a target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information.
[0010] Based on the query information, the slot set, the template identifier, and the target cache result, the multi-layer cache is updated to obtain the updated multi-layer cache.
[0011] In one possible design, the step of matching the query information, the slot set, and the template identifier with a preset multi-level cache and multiple preset storage data to obtain the target cache result includes:
[0012] Based on the query information, the slot set, and the template identifier, a match is made with the multi-layer cache to obtain a first matching result and a first cache result; wherein, the first matching result includes a first matching success and a first matching failure;
[0013] When the first matching result is a successful match, the first cached result is determined as the target cached result;
[0014] When the first matching result is that the first matching fails, a query statement is generated based on the slot set and the template identifier, and the query statement is sent to the database so that the database performs a data query based on the query statement and the multiple stored data to obtain the query result;
[0015] Receive the query result sent by the database and determine the query result as the target cache result.
[0016] In one possible design, the multi-layer cache includes a first-layer cache, a second-layer cache, and a third-layer cache; the slot set includes basic slots and non-basic slots; and the matching of the query information, the slot set, and the template identifier with the multi-layer cache to obtain a first matching result and a first cache result includes:
[0017] Based on the query information, a first cache key is generated;
[0018] The first cache key and the first layer cache are matched to obtain a second matching result and a second cache result; wherein, the second matching result includes a second successful match and a second failed match;
[0019] When the second matching result is that the second matching is successful, the first matching success is determined as the first matching result, and the second cached result is determined as the first cached result;
[0020] When the second matching result is that the second matching fails, a second cache key is generated based on the basic slot, the non-basic slot, and the template identifier;
[0021] Based on the second cache key and the second layer cache, a third matching result and a third cache result are obtained;
[0022] The first matching result and the first cached result are determined based on the third matching result and the third cached result.
[0023] In one possible design, the third matching result includes a third matching success and a third matching failure. Determining the first matching result and the first cached result based on the third matching result and the third cached result includes:
[0024] When the third matching result is a successful third match, the successful first match is determined as the first matching result, and the third cached result is determined as the first cached result;
[0025] When the third matching result is that the third matching fails, a third cache key is generated based on the basic slot;
[0026] The fourth matching result and the fourth cache result are obtained by matching the third cache key and the preset slot dependency cache; wherein, the fourth matching result includes the fourth matching success and the fourth matching failure.
[0027] When the fourth matching result is successful, the first cache result is determined based on the basic slot, the non-basic slot and the fourth cache result, and the first matching success is determined as the first matching result;
[0028] When the fourth matching result is that the fourth matching fails, a query statement is generated based on the basic slot, the non-basic slot, and the template identifier;
[0029] Based on the query statement, generate a fourth cache key;
[0030] The fifth matching result and the fifth cache result are obtained by matching the fourth cache key and the third cache layer; wherein, the fifth matching result includes a successful fifth match and a failed fifth match.
[0031] When the fifth matching result is a successful fifth match, the first successful match is determined as the first matching result, and the fifth cached result is determined as the first cached result;
[0032] When the fifth matching result is a failure, the first matching failure is determined as the first matching result.
[0033] In one possible design, determining the first cache result based on the base slot, the non-base slot, and the fourth cache result includes:
[0034] The fourth cache result is classified according to the non-basic slot to obtain target category data; wherein, the target data refers to the data in the fourth cache result corresponding to the non-basic slot;
[0035] The target category data is determined as the first cached result.
[0036] In one possible design, updating the multi-level cache based on the query information, the slot set, the template identifier, and the target cache result to obtain the updated multi-level cache includes:
[0037] The third-level cache is updated based on the fourth cache key and the target cache result to obtain the updated third-level cache.
[0038] The second-level cache is updated based on the second cache key and the target cache result to obtain the updated second-level cache;
[0039] The first layer cache is updated based on the first cache key and the target cache result to obtain the updated first layer cache;
[0040] The updated multi-layer cache is generated based on the updated third-layer cache, the updated second-layer cache, and the updated first-layer cache.
[0041] Secondly, embodiments of this application provide a cache optimization apparatus applied to a server of a cache optimization system, the cache optimization system further including a client and a database, the apparatus comprising:
[0042] The retrieval module is used to retrieve query information;
[0043] The parsing module is used to input the query information into a preset parsing model to obtain a slot set and a template identifier; wherein, the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content;
[0044] The matching module is used to match the query information, the slot set, and the template identifier with a preset multi-level cache and a preset multiple storage data to obtain a target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information;
[0045] The update module is used to update the multi-level cache based on the query information, the slot set, the template identifier, and the target cache result, so as to obtain the updated multi-level cache.
[0046] In one possible design, the matching module includes:
[0047] The first matching unit is used to match the multi-layer cache with the query information, the slot set and the template identifier to obtain a first matching result and a first cache result; wherein, the first matching result includes a first matching success and a first matching failure;
[0048] The first determining unit is configured to determine the first cached result as the target cached result when the first matching result is a successful first matching result;
[0049] The statement generation unit is used to generate a query statement based on the slot set and the template identifier when the first matching result is that the first matching fails, and send the query statement to the database so that the database performs a data query based on the query statement and the multiple stored data to obtain the query result;
[0050] The second determining unit is used to receive the query result sent by the database and determine the query result as the target cache result.
[0051] In one possible design, the multi-layer cache includes a first-layer cache, a second-layer cache, and a third-layer cache; the slot set includes basic slots and non-basic slots; and the first matching unit includes:
[0052] A first generation component is used to generate a first cache key based on the query information;
[0053] A first matching component is used to match the first cache key and the first layer cache to obtain a second matching result and a second cache result; wherein, the second matching result includes a second successful match and a second failed match;
[0054] The first determining component is configured to, when the second matching result is a successful second match, determine the successful first match as the first matching result and the second cached result as the first cached result;
[0055] The second generation component is used to generate a second cache key based on the base slot, the non-base slot, and the template identifier when the second matching result is that the second matching fails.
[0056] The second matching component is used to match the second cache key and the second layer cache to obtain the third matching result and the third cache result;
[0057] The second determining component is used to determine the first matching result and the first cached result based on the third matching result and the third cached result.
[0058] In one possible design, the third matching result includes a successful third match and a failed third match, and the second determining component includes:
[0059] The first determining component is used to determine the first matching success as the first matching result and the third cached result as the first cached result when the third matching result is the third matching success;
[0060] The first generation component is used to generate a third cache key based on the basic slot when the third matching result is that the third matching fails.
[0061] The first matching component is used to match the third cache key and the preset slot dependency cache to obtain a fourth matching result and a fourth cache result; wherein, the fourth matching result includes a fourth matching success and a fourth matching failure;
[0062] The second determining component is used to determine the first cache result based on the basic slot, the non-basic slot, and the fourth cache result when the fourth matching result is the fourth matching success, and to determine the first matching success as the first matching result;
[0063] A statement generation component is used to generate a query statement based on the basic slot, the non-basic slot, and the template identifier when the fourth matching result is that the fourth matching fails.
[0064] The second generation component is used to generate a fourth cache key based on the query statement;
[0065] The second matching component is used to match the fourth cache key and the third layer cache to obtain a fifth matching result and a fifth cache result; wherein, the fifth matching result includes a fifth matching success and a fifth matching failure;
[0066] The third determining component is used to determine the first matching success as the first matching result and the fifth cached result as the first cached result when the fifth matching result is the fifth matching success;
[0067] The fourth determining component is used to determine the first matching failure as the first matching result when the fifth matching result is the fifth matching failure.
[0068] In one possible design, the second defining component includes:
[0069] A data classification component is used to classify the fourth cache result according to the non-basic slot to obtain target category data; wherein, the target data refers to the data in the fourth cache result corresponding to the non-basic slot;
[0070] The result determination component is used to determine the target category data as the first cached result.
[0071] In one possible design, the update module includes:
[0072] The first update unit is used to update the third-level cache according to the fourth cache key and the target cache result to obtain the updated third-level cache.
[0073] The second update unit is used to update the second layer cache according to the second cache key and the target cache result to obtain the updated second layer cache;
[0074] The third update unit is used to update the first layer cache according to the first cache key and the target cache result to obtain the updated first layer cache.
[0075] The cache generation unit is used to generate the updated multi-layer cache based on the updated third-layer cache, the updated second-layer cache, and the updated first-layer cache.
[0076] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0077] The memory stores computer-executed instructions;
[0078] When the processor executes computer execution instructions stored in the memory, it is used to implement the cache optimization method as described in any of the first aspects.
[0079] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the cache optimization method as described in any of the first aspects.
[0080] Fifthly, this application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the cache optimization method as described in any of the first aspects.
[0081] This application provides a cache optimization method, apparatus, device, medium, and product. The method includes: acquiring query information; inputting the query information into a preset parsing model to obtain a slot set and a template identifier; wherein the slot set represents the type of data to be queried, and the template identifier represents different query templates to distinguish query information with the same slot set but different query content; matching the query information, the slot set, and the template identifier with a preset multi-level cache and preset multiple storage data to obtain a target cache result; wherein the multiple storage data are stored in a database, and the target cache result is the data queried by the query information; updating the multi-level cache based on the query information, the slot set, the template identifier, and the target cache result to obtain an updated multi-level cache. The cache optimization method of this application solves the problem of low cache hit rate in the prior art by introducing a slot set and a template identifier to standardize and distinguish query information. This method identifies slot sets and template identifiers in query information through a parsing model. The template identifier is used to distinguish queries with the same slot set but different query content, ensuring that queries with the same slot set can be correctly differentiated. The results are then matched against a pre-defined multi-layered cache and stored data in the database to obtain the target cached result, and the multi-layered cache is updated. This process reduces cache confusion and redundancy, improving cache hit rate. Attached Figure Description
[0082] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0083] Figure 1 This is a schematic diagram illustrating an application scenario of the cache optimization method provided in the embodiments of this application;
[0084] Figure 2 A flowchart illustrating the cache optimization method provided in this application embodiment;
[0085] Figure 3 A schematic diagram of the cache optimization device provided in the embodiments of this application;
[0086] Figure 4 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application.
[0087] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0088] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0089] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply difference. It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being better or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner. In the embodiments of this application, "at least one" refers to one or more, and "more than one" refers to two or more.
[0090] It should be noted that the phrase "at...time" in the embodiments of this application can refer to the instant at which a certain situation occurs, or to a period of time after the occurrence of a certain situation; the embodiments of this application do not specifically limit this. Furthermore, the cache optimization method, apparatus, device, medium, and product provided in the embodiments of this application are merely examples; a cache optimization method, apparatus, device, medium, and product may also include more or less content.
[0091] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below:
[0092] Caching is an efficient storage mechanism for temporarily storing data, designed to accelerate data access. By keeping frequently accessed or recently used copies of data in memory, caching reduces the frequency of reading data from slower storage devices, thereby improving the overall performance and responsiveness of the system.
[0093] Slot set: A set of placeholders used to describe and identify different data types or parameters in a query or data request. It is used in cache optimization and data querying to define the structure and type of the data to be retrieved, enabling the system to efficiently match and process requests based on these definitions.
[0094] Template identifier: A unique identifier used to mark and distinguish different query templates. It is used in cache optimization and data query processing to identify and differentiate requests with the same set of slots but different query content. By using template identifiers, the system can effectively manage and match cached data, ensuring that requests for specific query templates can quickly find the corresponding cached results, thereby improving query efficiency and system performance.
[0095] A cache key is an identifier used to store and retrieve specific data items in a caching system. It is typically composed of query parameters, slot sets, or other characteristics associated with the data to ensure that each cache key corresponds to a unique dataset. By using cache keys, the system can quickly locate and access data in the cache, thereby improving the speed and efficiency of data retrieval.
[0096] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0097] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.
[0098] To clearly understand the technical solution of this application, the solutions of existing technologies will first be described in detail. With the development of information technology, people's demand for information acquisition is increasing. To meet this demand, various intelligent question-answering systems have emerged. These systems, through natural language processing technology, enable users to conveniently obtain the information they need.
[0099] In existing technologies, systems parse user natural language input to identify key slots and parameters. These slots and parameters are then used to generate corresponding structured queries. The queries interact with the database to retrieve the information the user needs. Finally, the query results are presented to the user in natural language. However, in generating structured queries based on identified key slots and parameters, the same key slots and parameters may generate different structured queries. This causes the caching system to fail to accurately match the user's actual needs, resulting in a low cache hit rate. Therefore, existing technologies suffer from a low cache hit rate problem.
[0100] Therefore, addressing the low cache hit rate issue in existing technologies, this research found that to solve this problem, a structured parameter set and distinguishing identifier template can be generated by parsing user queries. Dynamic matching based on a multi-level caching architecture can then be implemented to improve cache accuracy: ① User queries can be transformed into a structured parameter set containing semantic intent, combined with dynamically generated unique routing identifiers, such as hash encoding or intent tags, to process queries with similar semantics but different expressions separately, avoiding misjudgments due to differences in statement structure. ② By analyzing the contextual features of the query, the cache level can be dynamically selected for matching, and associated indexes can be established for the same data at different levels. When a cache miss occurs, a cross-level collaborative retrieval strategy is triggered. ③ A dynamic cache update and replacement strategy can be implemented, adjusting cache content in real time based on query patterns and data changes. By monitoring query results and data changes in real time, the data content of each cache level is updated promptly, ensuring that the information in the cache is always up-to-date, optimizing cache utilization efficiency, and improving the response speed to user requests.
[0101] Specifically: user queries can be transformed into a structured set of parameters and combined with dynamically generated unique identifiers to accurately distinguish queries with similar semantics but different expressions; by analyzing the contextual features of the query, appropriate cache levels can be dynamically selected for matching, and cross-level related indexes can be established to improve cache hit rate; at the same time, dynamic update and replacement strategies are implemented to adjust cache content in real time according to query patterns and data changes to ensure the timeliness and relevance of cache information, thereby optimizing cache utilization efficiency and system response speed.
[0102] This application discloses a cache optimization method, apparatus, device, medium, and product that standardizes and distinguishes query information by introducing slot sets and template identifiers, thus solving the problem of low cache hit rate in the prior art. The method identifies the slot sets and template identifiers in the query information through a parsing model. The template identifiers are used to distinguish queries with the same slot set but different query content, ensuring that queries with the same slot set can be correctly distinguished and matched with preset multi-level caches and stored data in the database to obtain the target cache result and update the multi-level cache. This process reduces cache confusion and redundancy, improving the cache hit rate.
[0103] Based on the above-mentioned inventive discovery, the technical solution of this application is proposed.
[0104] The following describes the application scenarios of the cache optimization method provided in the embodiments of the present invention. Figure 1 This is a schematic diagram illustrating an application scenario of the cache optimization method provided in an embodiment of this application. For example... Figure 1As shown, this application scenario includes a client 101, a server 102, and a database 103. The client 101 obtains the query information input by the user and sends it to the server 102. The server 102 inputs the query information into the parsing model to obtain the slot set and template identifier. It then matches the query information, slot set, and template identifier with the data in the database 103 to obtain the target cache result. Finally, based on the query information, slot set, template identifier, and target cache result, it updates the multi-level cache to obtain the updated multi-level cache.
[0105] The embodiments of the present invention will now be described with reference to the accompanying drawings.
[0106] Figure 2 This is a flowchart illustrating the cache optimization method provided in an embodiment of this application. Figure 2 As shown, in this embodiment, the execution subject of this invention is a server. Therefore, the cache optimization method provided in this embodiment includes the following steps:
[0107] S201. Obtain query information.
[0108] Specifically, query information can be obtained through the communication interface between the client and the server. This process may involve parsing the user-input query string or structured request to extract specific query parameters and conditions. The purpose of obtaining query information is to provide the necessary data foundation for subsequent parsing and matching processes, ensuring that the system can identify the specific query requirements and perform effective matching and retrieval in the cache and database.
[0109] S202. Input the query information into the preset parsing model to obtain the slot set and template identifier; wherein, the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content.
[0110] Specifically, the acquired query information can be passed to a trained parsing model that can identify and extract the slot set and template identifiers used to distinguish different query patterns from the query. This process is used to structure the query information so that subsequent steps can accurately match data in the cache and database.
[0111] S203. Based on the query information, slot set, and template identifier, match them with the preset multi-level cache and multiple preset storage data to obtain the target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information.
[0112] Specifically, a query matching engine can be built. This engine uses the parsed slot set and template identifier as keys to first search for matches in multiple layers of caching. If a cache hit occurs, the target cached result is returned directly; if the cache misses, the required data is further searched and retrieved from the database. The goal of this process is to quickly locate and extract the data needed for the user's query, maximizing the use of caching to reduce the number of database accesses.
[0113] S204. Based on the query information, slot set, template identifier, and target cache result, update the multi-level cache to obtain the updated multi-level cache.
[0114] Specifically, a cache management module can be designed. After retrieving the target cache result, this module stores the new or updated result along with the corresponding slot set and template identifier in a multi-level cache. This may involve updating existing cache entries or adding new entries. This process ensures that the cache stores the latest query results and can quickly respond to the same or similar future queries, thereby improving cache hit rate and system performance, and reducing the need to access the underlying database.
[0115] This embodiment provides a cache optimization method, which includes: obtaining query information; inputting the query information into a preset parsing model to obtain a slot set and a template identifier; wherein the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content; matching the query information, slot set, and template identifier with a preset multi-level cache and multiple preset stored data to obtain a target cache result; wherein the multiple stored data are stored in a database, and the target cache result is the data queried by the query information; updating the multi-level cache according to the query information, slot set, template identifier, and target cache result to obtain an updated multi-level cache. This cache optimization method achieves the following technical effects: by introducing a slot set and template identifier to standardize and distinguish query information, it solves the problem of low cache hit rate in the prior art. This method identifies the slot set and template identifier in the query information through a parsing model, uses the template identifier to distinguish queries with the same slot set but different query content, ensures that queries with the same slot set can be correctly distinguished, and matches them with the preset multi-level cache and stored data in the database to obtain the target cache result, and updates the multi-level cache. This process reduces cache obfuscation and redundancy, and improves cache hit rate.
[0116] In one possible design, S203, based on the query information, slot set, and template identifier, matches the results with a preset multi-level cache and multiple preset storage data to obtain the target cache result, including:
[0117] S2031. Based on the query information, slot set, and template identifier, match with the multi-level cache to obtain the first matching result and the first cache result; wherein, the first matching result includes the first matching success and the first matching failure.
[0118] Specifically, a cache lookup algorithm can be set up. This algorithm uses the parsed slot set and template identifier as the lookup key to search through multiple layers of cache to determine if a cache entry matching the query information exists. If a matching entry is found, the algorithm returns the first successful match and the corresponding first cached result; otherwise, it returns a first match failure. This process is used to quickly determine whether the required query result already exists in the cache, thereby deciding whether further database access is needed to retrieve the data.
[0119] S2032. When the first matching result is successful, the first cached result is determined as the target cached result.
[0120] Specifically, a conditional judgment mechanism can be set in the cache lookup algorithm. When the cache lookup algorithm returns a successful first match, the system directly assigns the first cached result retrieved from the cache as the target cached result. The purpose of this process is to quickly return the required data when a cache hit occurs, avoiding unnecessary database access and reducing response time.
[0121] S2033. When the first matching result is that the first matching fails, a query statement is generated based on the slot set and template identifier, and the query statement is sent to the database so that the database can perform data query based on the query statement and multiple stored data to obtain the query result.
[0122] Specifically, a query generation module can be set up. This module uses a set of slots and template identifiers to construct a structured query statement that accurately expresses the user's query requirements. The generated query statement is then sent to the database for execution. The database retrieves the query results from its stored data based on the statement. The purpose of this process is to retrieve the latest data through database queries when a cache miss occurs, ensuring that the user's request is satisfied, and providing the necessary data for subsequent cache updates.
[0123] S2034. Receive the query results sent by the database and determine the query results as the target cache results.
[0124] Specifically, data can be received through the communication interface between the server and the database. After the database executes a query, it returns the result to the server, which receives the result and stores it as the target cache result. The purpose of this process is to ensure that the query result is correctly received and recognized even if the cache misses and the database query succeeds, so that subsequent steps can use the result to update the cache and respond to user requests, thereby maintaining the system's data consistency and query efficiency.
[0125] The technical effect of this solution in this embodiment is as follows: By introducing a multi-layer cache matching mechanism, hierarchical optimization of cache queries is achieved: First, the query is attempted to match within multiple layers of cache; if a match is found, the cached result is returned directly, improving response speed; only when the cache is not found is a query statement generated to access the database, reducing unnecessary database query pressure and ensuring the integrity of data retrieval. This hierarchical processing mechanism effectively balances system performance and data accuracy, improves query efficiency, and optimizes system resource utilization by accessing the database only when necessary.
[0126] In one possible design, the multi-layer cache includes a first-layer cache, a second-layer cache, and a third-layer cache. The slot set includes basic slots and non-basic slots. S2031: Based on the query information, the slot set, and the template identifier, the cache is matched against the multi-layer cache to obtain a first matching result and a first cache result, including:
[0127] S20311. Generate the first cache key based on the query information.
[0128] Specifically, the query information can be hashed or concatenated to obtain the first cache key. The system can extract key parameters and features from the query information and combine them into a unique identifier, i.e., the first cache key. A hash function is typically used to ensure the uniqueness and consistency of the key. The purpose of this process is to generate a unique cache key for each query, enabling quick location and retrieval of the corresponding cached results in the first-level cache.
[0129] S20312. Match the first cache key and the first layer cache to obtain the second matching result and the second cache result; wherein, the second matching result includes the second matching success and the second matching failure.
[0130] Specifically, the system can use the generated first cache key to search within the first-level cache data structure, such as a hash table or dictionary. If a matching key is found, a second match success status and the corresponding cached data are returned as the second cache result; otherwise, a second match failure status is returned. The purpose of this process is to quickly determine whether the required query result is already stored in the first-level cache, thereby deciding whether further checks of deeper cache levels or database access are necessary.
[0131] S20313. When the second matching result is a successful second match, the successful first match is determined as the first matching result, and the second cached result is determined as the first cached result.
[0132] Specifically, in the cache matching process, when the system detects a successful second match, it immediately sets the status flag to "first match successful" and assigns the second cached result retrieved from the first-level cache as the first cached result. The purpose of this process is to quickly confirm and return the required data when the first-level cache is hit, avoiding unnecessary further cache layer checks or database queries, thereby improving the system's response speed and efficiency.
[0133] S20314. When the second matching result is that the second matching fails, generate a second cache key based on the basic slot, non-basic slot and template identifier.
[0134] Specifically, the system can extract the values of basic and non-basic slots, combine them with template identifiers, and generate a second cache key through string concatenation or hash function processing. The purpose of this process is to generate a more distinctive key for the second-level cache when the first-level cache misses, so that it can be searched in deeper caches, thereby improving the cache system's hit rate and query efficiency.
[0135] S20315. Match the second cache key and the second-level cache to obtain the third matching result and the third cache result.
[0136] Specifically, the system uses the generated second cache key to search within the second-level cache data structure, such as a hash table, tree structure, or other suitable caching storage structure. If a matching key is found, a third match success status and the corresponding cached data are returned as the third cache result; otherwise, a third match failure status is returned. The purpose of this process is to continue searching in the second-level cache when the first-level cache is not found, thereby increasing the cache hit rate and reducing the need for database access.
[0137] S20316. Based on the third matching result and the third cached result, determine the first matching result and the first cached result.
[0138] Specifically, after the second-level cache lookup is complete, the system can check the status of the third matching result. If the third matching result is successful, the first matching result is set to a successful match, and the third cached result is assigned to the first cached result; if the third matching result fails, the first matching result remains in a failed match state. The purpose of this process is to update the overall matching status and cached results using the lookup results from the second-level cache after a first-level cache miss, thereby determining whether further database access is needed to ensure that the system efficiently provides query results.
[0139] The technical advantages of this solution in this embodiment are: by introducing a multi-layered caching structure and subdividing the slot set, a refined and hierarchical cache matching process is achieved. This structure allows the system to progressively match cache keys at different cache levels, thereby improving the cache hit rate. By generating and matching different cache keys in each cache layer, the system can effectively utilize cache resources, reduce the need for direct database queries, and thus improve the system's response speed.
[0140] In one possible design, the third matching result includes third matching success and third matching failure. S20316, based on the third matching result and the third cached result, determine the first matching result and the first cached result, including:
[0141] S203161. When the third matching result is a successful third match, the successful first match is determined as the first matching result, and the third cached result is determined as the first cached result.
[0142] Specifically, during the cache matching process, the system checks the status of the third matching result. If the third matching result is successful, the system sets the status of the first matching result to successful and assigns the third cached result to the first cached result. The purpose of this process is to quickly confirm and return the required data when the second-level cache is hit, avoiding further cache layer checks or database queries.
[0143] S203162. When the third matching result is a third matching failure, generate a third cache key based on the basic slot.
[0144] Specifically, the system can retrieve the necessary parameters from the base slots and generate a third cache key through string concatenation or a hash function to ensure its uniqueness and recognizability. The purpose of this process is to prepare a new key for lookup in the slot-dependent cache when the second-level cache misses, thereby improving the flexibility and hit rate of cache lookups, reducing the need for direct database access, and thus optimizing system performance.
[0145] S203163. Match the third cache key and the preset slot dependency cache to obtain the fourth matching result and the fourth cache result; wherein, the fourth matching result includes the fourth matching success and the fourth matching failure.
[0146] Specifically, the system can use the generated third cache key to look up the data structure of the slot-dependent cache, such as a hash table or dictionary. If a matching key is found, a fourth match success status and the corresponding cached data are returned as the fourth cache result; if not found, a fourth match failure status is returned. The purpose of this process is to further search for possible cache results through the slot-dependent cache when the first few layers of cache are missed, thereby improving the cache hit rate and reducing the need for database queries.
[0147] S203164. When the fourth matching result is a successful fourth match, the first cache result is determined based on the basic slot, the non-basic slot and the fourth cache result, and the successful first match is determined as the first matching result.
[0148] Specifically, when the fourth match is successful, the system uses the fourth cached result as a base and combines it with information from the base slot and non-base slots, possibly through data merging or transformation operations, to generate the final first cached result. Subsequently, the system sets the status of the first matching result to "match successful." The purpose of this process is to quickly construct a complete query result using existing cached data and slot information when a slot-dependent cache hit occurs, avoiding further cache lookups or database accesses.
[0149] S203165. When the fourth matching result is a failure, generate a query statement based on the basic slot, non-basic slot and template identifier.
[0150] Specifically, the system can extract parameter information from both basic and non-basic slots and combine it with template identifiers to determine the structure and conditions of the query. Then, the system integrates this information into a complete query statement to retrieve the required data from the database. The purpose of this process is to obtain the latest data by generating and executing a database query even when all cache levels are missed, ensuring that the system can return accurate query results.
[0151] S203166. Generate the fourth cache key based on the query statement.
[0152] Specifically, the system can perform a hash calculation on the complete query statement to generate a unique hash value, or extract key elements from the query statement and concatenate them to generate a fourth cache key. The purpose of this process is to create a unique identifier for the query result so that it can be stored in the third-level cache. When the same query occurs again, the system can quickly find and return the cached result using the fourth cache key, thereby improving query efficiency.
[0153] S203167. Match the fourth cache key and the third cache to obtain the fifth matching result and the fifth cache result; wherein, the fifth matching result includes the fifth matching success and the fifth matching failure.
[0154] Specifically, the system can use the generated fourth cache key to search within the third-level cache data structure, such as a hash table or other efficient key-value storage structure. If a matching key is found, a fifth match success status and the corresponding cached data are returned as the fifth cache result; otherwise, a fifth match failure status is returned. The purpose of this process is to improve the cache hit rate and reduce the need for direct database access after the first few cache levels have failed to find a match and a new query has been generated.
[0155] S203168. When the fifth matching result is a successful fifth match, the successful first match is determined as the first matching result, and the fifth cached result is determined as the first cached result.
[0156] Specifically, during the cache matching process, the system checks the status of the fifth matching result. If the fifth matching result is successful, the system sets the status of the first matching result to successful and assigns the fifth cached result to the first cached result. The purpose of this process is to quickly confirm and return the required data when the third-level cache is hit, avoiding further database queries, thereby improving the system's response speed and resource utilization efficiency.
[0157] S203169. When the fifth matching result is a failure of the fifth matching, the failure of the first matching is determined as the first matching result.
[0158] Specifically, during the cache matching process, the system checks the status of the fifth matching result. If the fifth matching result fails, the system sets the status of the first matching result to "match failed." The purpose of this process is to explicitly indicate the need for a database query to retrieve data when all cache levels have failed, thereby ensuring that the system can continue to execute subsequent steps to retrieve the required information. This mechanism helps to trigger database access in a timely manner in the event of a cache miss, ensuring data integrity and accuracy.
[0159] The technical effect of this solution in this embodiment is as follows: By further refining the cache matching strategy, especially in the case of failure of the third-level cache matching, a third cache key is generated using the basic slot, and then matched in the slot-dependent cache to obtain a fourth matching result. This process allows the system to attempt matching in a deeper cache structure, thereby maximizing the utilization of cache resources and reducing the frequency of database queries. In addition, by directly using the fourth cache result to determine the first cache result when the fourth match is successful, the efficiency and accuracy of the caching system are further improved, ensuring that even in the case of failure of multi-level cache matching, effective data retrieval can still be performed by generating new query statements and cache keys, thus improving the overall system performance.
[0160] In one possible design, S203164 determines the first cache result based on the base slot, non-base slot, and the fourth cache result, including:
[0161] S2031641. Classify the fourth cache results according to the non-basic slots to obtain target category data; where target data refers to the data in the fourth cache results that corresponds to the non-basic slots.
[0162] Specifically, the system can extract data matching the conditions or classification criteria provided by the non-basic slots from the fourth cache results, forming a precise subset, namely the target category data. The purpose of this process is to further refine and extract data highly relevant to the query requirements from the cache results, ensuring that the returned results are more targeted and accurate, thereby improving the system's response efficiency.
[0163] S2031642. The target category data is determined as the first cached result.
[0164] Specifically, after classifying the fourth cache result, the system can extract the target category data that meets the non-basic slot conditions and store or return it as the first cache result. The purpose of this process is to ensure that the final output data matches the user's specific query requirements, providing accurate response data, and caching the result so that it can quickly return results when similar queries occur.
[0165] The technical effect of this solution in this embodiment is as follows: by classifying and filtering the fourth cache result based on non-basic slots, intelligent filtering and accurate extraction of composite query results are achieved: when the system hits the data corresponding to the basic slot in the slot dependency cache, it can automatically filter out the target category data that completely matches the current query from the cached basic data based on the non-basic slots. This avoids the resource consumption of repeated database queries, ensures the accuracy of the returned results, and improves the system's processing efficiency for query requests with the same basic slot.
[0166] In one possible design, S204 updates the multi-level cache based on the query information, slot set, template identifier, and target cache result, resulting in an updated multi-level cache, including:
[0167] S2041. Based on the fourth cache key and the target cache result, update the third-level cache to obtain the updated third-level cache.
[0168] Specifically, the system can use the fourth cache key as an index to store the target cached result in the third-level cache data structure. If the key already exists, its corresponding value is updated to the new target cached result; if it does not exist, a new key-value pair is inserted. The purpose of this process is to ensure that the latest query results are cached so that they can be quickly retrieved when the same or similar queries occur again, improving the system's response speed and efficiency, and reducing frequent access to the database.
[0169] S2042. Update the second-level cache according to the second cache key and the target cache result to obtain the updated second-level cache.
[0170] Specifically, the second cache key can be used as an index to look up the corresponding entry in the second-level cache data structure. If the key already exists, its corresponding value is updated to the new target cache result; if it does not exist, a new key-value pair is inserted. The purpose of this process is to ensure that the middle layer of the caching system can store and provide the latest query results so that subsequent identical or similar query requests can quickly hit the cache, reducing dependence on the underlying database.
[0171] S2043. Update the first-level cache according to the first cache key and the target cache result to obtain the updated first-level cache.
[0172] Specifically, the first cache key can be used as an index to look up the corresponding entry in the first-level cache data structure. If the key already exists, its corresponding value is updated to the new target cached result; otherwise, a new key-value pair is inserted. The purpose of this process is to ensure that the latest query results are stored in the layer closest to the user request in the cache hierarchy, so that the cache can be hit immediately when the same or similar queries occur again, thereby improving system response speed and user experience, while reducing the need to access deeper caches and the database.
[0173] S2044. Generate an updated multi-level cache based on the updated third-level cache, the updated second-level cache, and the updated first-level cache.
[0174] Specifically, the system can update at each cache layer, ensuring consistency and integrity across all layers to form a unified multi-layered cache structure. This may involve synchronization operations between cache layers to ensure correct data transfer and storage across different layers. The goal of this process is to maintain an efficient multi-layered cache system, enabling each cache layer to function effectively and providing fast data access paths in various query scenarios.
[0175] The technical effect of this solution in this embodiment is as follows: It achieves efficient maintenance of the caching system through a hierarchical update mechanism. After obtaining the target cache result, the system updates each level of the cache sequentially from the third level to the second level and then to the first level. This bottom-up update strategy ensures both the reusability of basic data and fast access to frequently accessed query results. By using differentiated updates based on different cache keys, precise hierarchical storage of cached data is achieved, ensuring that each level of cache maintains optimal data coverage, avoiding redundant data storage, and optimizing the storage efficiency of the caching system.
[0176] Figure 3 This is a schematic diagram of the cache optimization device provided in an embodiment of this application. Figure 3 As shown, the cache optimization device includes:
[0177] The acquisition module 301 is used to obtain query information.
[0178] The parsing module 302 is used to input query information into a preset parsing model to obtain a slot set and a template identifier. The slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content.
[0179] The matching module 303 is used to match the query information, slot set and template identifier with the preset multi-level cache and preset multiple storage data to obtain the target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information.
[0180] The update module 304 is used to update the multi-level cache based on the query information, slot set, template identifier and target cache result, so as to obtain the updated multi-level cache.
[0181] In one possible design, the matching module 303 includes:
[0182] The first matching unit is used to match the query information, slot set and template identifier with the multi-level cache to obtain the first matching result and the first cache result; wherein, the first matching result includes the first matching success and the first matching failure.
[0183] The first determining unit is used to determine the first cached result as the target cached result when the first matching result is a successful first match.
[0184] The statement generation unit is used to generate a query statement based on the slot set and template identifier when the first matching result is a failure, and send the query statement to the database so that the database can perform data query based on the query statement and multiple stored data to obtain the query result.
[0185] The second determining unit is used to receive the query results sent by the database and determine the query results as the target cache results.
[0186] In one possible design, the multi-layer cache includes a first-layer cache, a second-layer cache, and a third-layer cache; the slot set includes basic slots and non-basic slots; and the first matching unit includes:
[0187] The first generation component is used to generate the first cache key based on the query information.
[0188] The first matching component is used to match based on the first cache key and the first layer cache to obtain the second matching result and the second cache result; wherein, the second matching result includes the second matching success and the second matching failure.
[0189] The first determining component is used to determine the first successful match as the first matching result and the second cached result as the first cached result when the second matching result is the second successful match.
[0190] The second generation component is used to generate a second cache key based on the base slot, non-base slot, and template identifier when the second matching result is a second matching failure.
[0191] The second matching component is used to match based on the second cache key and the second-level cache to obtain the third matching result and the third cache result.
[0192] The second determining component is used to determine the first matching result and the first cached result based on the third matching result and the third cached result.
[0193] In one possible design, the third matching result includes third matching success and third matching failure, and the second determining component includes:
[0194] The first determining component is used to determine the first matching success as the first matching result and the third cached result as the first cached result when the third matching result is the third matching success.
[0195] The first generation component is used to generate a third cache key based on the base slot when the third matching result is a third matching failure.
[0196] The first matching component is used to match the third cache key and the preset slot dependency cache to obtain the fourth matching result and the fourth cache result; wherein, the fourth matching result includes the fourth matching success and the fourth matching failure.
[0197] The second determining component is used to determine the first cache result based on the basic slot, non-basic slot and the fourth cache result when the fourth matching result is a successful fourth matching, and to determine the successful first matching as the first matching result.
[0198] The statement generation component is used to generate a query statement based on the basic slot, non-basic slot, and template identifier when the fourth match result is a failure.
[0199] The second generation component is used to generate the fourth cache key based on the query statement.
[0200] The second matching component is used to match based on the fourth cache key and the third-level cache to obtain the fifth matching result and the fifth cache result; wherein, the fifth matching result includes the fifth matching success and the fifth matching failure.
[0201] The third determining component is used to determine the first successful match as the first matching result and the fifth cached result as the first cached result when the fifth matching result is the fifth successful match.
[0202] The fourth determining component is used to determine the first matching failure as the first matching result when the fifth matching result is a fifth matching failure.
[0203] In one possible design, the second defined component includes:
[0204] The data classification component is used to classify the fourth cache results based on non-base slots to obtain target category data; where target data refers to the data in the fourth cache results that corresponds to the non-base slots.
[0205] The result determination component is used to determine the target category data as the first cached result.
[0206] In one possible design, update module 304 includes:
[0207] The first update unit is used to update the third-level cache based on the fourth cache key and the target cache result, so as to obtain the updated third-level cache.
[0208] The second update unit is used to update the second-level cache based on the second cache key and the target cache result, so as to obtain the updated second-level cache.
[0209] The third update unit is used to update the first-level cache based on the first cache key and the target cache result, so as to obtain the updated first-level cache.
[0210] The cache generation unit is used to generate an updated multi-level cache based on the updated third-level cache, the updated second-level cache, and the updated first-level cache.
[0211] The cache optimization device provided in this embodiment can perform... Figure 2 The technical solution of the cache optimization method embodiment shown herein, its implementation principle and technical effect are similar to Figure 2 The embodiment of the cache optimization method shown is similar and will not be described in detail here.
[0212] Figure 4 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 40 includes at least one processor 401 and a memory 402. The electronic device 40 also includes a communication component 403. The processor 401, memory 402, and communication component 403 are connected via a bus 404.
[0213] In a specific implementation, at least one processor 401 executes computer execution instructions stored in memory 402, causing at least one processor 401 to implement a cache optimization method of the above embodiment.
[0214] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0215] In the above embodiments, it should be understood that the processor 401 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0216] The memory 402 may include high-speed RAM memory, and may also include non-volatile memory (NVM), such as at least one disk storage.
[0217] Bus 404 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Bus 404 can be divided into address bus, data bus, control bus, etc. For ease of illustration, the bus 404 in the accompanying drawings of this application is not limited to only one bus or one type of bus.
[0218] The above description of the functions implemented by electronic devices and main control devices has introduced the solutions provided by the embodiments of the present invention. It is understood that, in order to implement the above functions, the electronic device or main control device includes hardware structures and / or software modules corresponding to the execution of each function. By combining the units and algorithm steps of the various examples described in the embodiments of the present invention, the embodiments of the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the technical solutions of the embodiments of the present invention.
[0219] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, these instructions implement a cache optimization method as described in the above embodiments. In a specific implementation of the aforementioned cache optimization method, each module can be implemented as a processor.
[0220] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0221] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in application-specific integrated circuits (ASICs). Alternatively, the processor and the readable storage medium can exist as discrete components in an electronic device or a host device.
[0222] This application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement a cache optimization method of the above embodiments.
[0223] The computer program is stored in a readable storage medium, and at least one processor can read the computer program from the readable storage medium and execute the computer program to perform the scheme provided in any of the above embodiments.
[0224] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disk, or optical disk.
[0225] The technical solutions of this application have been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it is readily understood by those skilled in the art that the scope of protection of this application is obviously not limited to these specific embodiments. The above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A cache optimization method, characterized in that, A server applied to a cache optimization system, the cache optimization system further including a client and a database, the method comprising: Retrieve query information; The query information is input into a preset parsing model to obtain a slot set and a template identifier; wherein, the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content; Based on the query information, the slot set, and the template identifier, the results are matched with a preset multi-level cache and multiple preset storage data to obtain a target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information. Based on the query information, the slot set, the template identifier, and the target cache result, the multi-layer cache is updated to obtain the updated multi-layer cache.
2. The cache optimization method according to claim 1, characterized in that, The step of matching the query information, the slot set, and the template identifier with a preset multi-layer cache and multiple preset storage data to obtain the target cache result includes: Based on the query information, the slot set, and the template identifier, a match is made with the multi-layer cache to obtain a first matching result and a first cache result; wherein, the first matching result includes a first matching success and a first matching failure; When the first matching result is a successful match, the first cached result is determined as the target cached result; When the first matching result is that the first matching fails, a query statement is generated based on the slot set and the template identifier, and the query statement is sent to the database so that the database performs a data query based on the query statement and the multiple stored data to obtain the query result; Receive the query result sent by the database and determine the query result as the target cache result.
3. The cache optimization method according to claim 2, characterized in that, The multi-layer cache includes a first-layer cache, a second-layer cache, and a third-layer cache. The slot set includes basic slots and non-basic slots. The process of matching the query information, the slot set, and the template identifier with the multi-layer cache to obtain a first matching result and a first cache result includes: Based on the query information, a first cache key is generated; The first cache key and the first layer cache are matched to obtain a second matching result and a second cache result; wherein, the second matching result includes a second successful match and a second failed match; When the second matching result is that the second matching is successful, the first matching success is determined as the first matching result, and the second cached result is determined as the first cached result; When the second matching result is that the second matching fails, a second cache key is generated based on the basic slot, the non-basic slot, and the template identifier; Based on the second cache key and the second layer cache, a third matching result and a third cache result are obtained; The first matching result and the first cached result are determined based on the third matching result and the third cached result.
4. The cache optimization method according to claim 3, characterized in that, The third matching result includes a successful third matching and a failed third matching. Determining the first matching result and the first cached result based on the third matching result and the third cached result includes: When the third matching result is a successful third match, the successful first match is determined as the first matching result, and the third cached result is determined as the first cached result; When the third matching result is that the third matching fails, a third cache key is generated based on the basic slot; The fourth matching result and the fourth cache result are obtained by matching the third cache key and the preset slot dependency cache; wherein, the fourth matching result includes the fourth matching success and the fourth matching failure. When the fourth matching result is successful, the first cache result is determined based on the basic slot, the non-basic slot and the fourth cache result, and the first matching success is determined as the first matching result; When the fourth matching result is that the fourth matching fails, a query statement is generated based on the basic slot, the non-basic slot, and the template identifier; Based on the query statement, generate a fourth cache key; The fifth matching result and the fifth cache result are obtained by matching the fourth cache key and the third cache layer; wherein, the fifth matching result includes a successful fifth match and a failed fifth match. When the fifth matching result is a successful fifth match, the first successful match is determined as the first matching result, and the fifth cached result is determined as the first cached result; When the fifth matching result is a failure, the first matching failure is determined as the first matching result.
5. The cache optimization method according to claim 4, characterized in that, The step of determining the first cache result based on the basic slot, the non-basic slot, and the fourth cache result includes: The fourth cache result is classified according to the non-basic slot to obtain target category data; wherein, the target data refers to the data in the fourth cache result corresponding to the non-basic slot; The target category data is determined as the first cached result.
6. The cache optimization method according to claim 4, characterized in that, The step of updating the multi-layer cache based on the query information, the slot set, the template identifier, and the target cache result to obtain the updated multi-layer cache includes: The third-level cache is updated based on the fourth cache key and the target cache result to obtain the updated third-level cache. The second-level cache is updated based on the second cache key and the target cache result to obtain the updated second-level cache; The first layer cache is updated based on the first cache key and the target cache result to obtain the updated first layer cache; The updated multi-layer cache is generated based on the updated third-layer cache, the updated second-layer cache, and the updated first-layer cache.
7. A cache optimization device, characterized in that, A server used in a cache optimization system, the cache optimization system further including a client and a database, the device comprising: The retrieval module is used to retrieve query information; The parsing module is used to input the query information into a preset parsing model to obtain a slot set and a template identifier; wherein, the slot set is used to represent the type of data to be queried, and the template identifier is used to represent different query templates to distinguish query information with the same slot set but different query content; The matching module is used to match the query information, the slot set, and the template identifier with a preset multi-level cache and a preset multiple storage data to obtain a target cache result; wherein, the multiple storage data are stored in the database, and the target cache result is the data queried by the query information; The update module is used to update the multi-level cache based on the query information, the slot set, the template identifier, and the target cache result, so as to obtain the updated multi-level cache.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; When the processor executes computer execution instructions stored in the memory, it is used to implement the cache optimization method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the cache optimization method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, is used to implement the cache optimization method as described in any one of claims 1 to 6.