Data service execution result caching method and device, computer equipment and medium

By adding the target cache configuration table for the number of caches and cache time fields in Guava Cache, combined with the query mechanism of first-level cache and second-level cache, the problem of low API call performance in high concurrency scenarios is solved, and the orderly cache of data service execution results is realized, improving system performance and stability.

CN119597485APending Publication Date: 2025-03-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411772516.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In high concurrency scenarios, frequent API calls and data processing lead to extended service response time and increased system resource consumption, which in turn affects user experience and system stability.

Method used

Provides an ordered cache method for data service execution results, which forms the target cache configuration table by obtaining the initial cache configuration table of the API in Guava Cache, adding cache number fields and cache time fields. Detect API call events, query the first-level cache and second-level cache to get cache values, and clean cached data according to the target cache configuration table.

Benefits of technology

It effectively improves the performance and response speed of API calls, avoids repeated execution of the same data processing logic, reduces system resource consumption, and improves user experience and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597485A_ABST
    Figure CN119597485A_ABST
Patent Text Reader

Abstract

The invention relates to a data service execution result caching method and device, computer equipment and a medium, and the method comprises the steps: obtaining an initial cache configuration table of an API (Application Program Interface) in a Guava Cache, and adding a cache bar digital field and a cache time field in the initial cache configuration table to obtain a target cache configuration table; detecting an API calling event, and obtaining an API identity identifier and a target calling parameter corresponding to the API calling event; if the cache instance of the API identity identifier exists in the first-level cache of the Guava Cache, inquiring whether a second-level cache corresponding to the target calling parameter exists in the first-level cache or not; if yes, a cache value corresponding to the target calling parameter is inquired from a second-level cache, and a service execution result is fed back based on the cache value; if not, querying an execution result corresponding to the API calling event according to the actual service, and feeding back the execution result; and returning to the step of detecting the API calling event, and cleaning the cached data in the first-level cache and the second-level cache according to the target cache configuration table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data service execution result caching method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] In modern data service applications, API (Application Programming Interface) calls are the core method of data processing and interaction. However, with the growth of data volume and the diversification of user needs, the frequency and complexity of API calls have also increased, which has posed a severe challenge to the performance of data services. Especially in high-concurrency scenarios, frequent API calls and data processing often lead to longer service response time and increased system resource consumption, which in turn affects user experience and system stability.

[0003] To solve this problem, cache technology is widely used in the field of data services. By temporarily storing the results of data service execution in memory, cache technology avoids the repeated execution of the same data processing logic, thereby significantly improving the performance and response speed of service calls. Among many cache solutions, Guava Cache stands out for its powerful functions and ease of use, becoming the first choice of many developers. Guava Cache is part of Google's open source Guava project, which extends and enhances the Java collection framework and provides a thread-safe, high-performance cache implementation.

[0004] However, due to the limited service memory resources, the unlimited growth of conventional unordered cache will lead to problems such as memory overflow. Therefore, there is an urgent need for an ordered data service execution result caching solution. Summary of the invention

[0005] Based on this, it is necessary to provide an orderly data service execution result caching method, device, computer equipment, computer readable storage medium and computer program product to address the above technical problems.

[0006] In a first aspect, the present application provides a data service execution result caching method. The method comprises:

[0007] Get the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table;

[0008] Detect API call events and obtain the API identity and target call parameters corresponding to the API call events;

[0009] If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API;

[0010] If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it;

[0011] Return to the step of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0012] In one embodiment, the initial cache configuration table of the API in Guava Cache is obtained, and a cache entry field and a cache time field are added to the initial cache configuration table to obtain a target cache configuration table, including:

[0013] Get the initial cache configuration table and application scenario parameters of the API in Guava Cache;

[0014] Based on the application scenario parameters, analyzing the API application scenario type, API size, and API usage times;

[0015] Configure the number of cache entries and cache time of the API according to the API application scenario type, the API size, and the number of times the API is used;

[0016] According to the cache number and the cache time, a cache number field and a cache time field are added to the initial cache configuration table to obtain a target cache configuration table.

[0017] In one embodiment, configuring the number of cache entries and cache time of the API according to the API application scenario type, the API size, and the number of times the API is used includes:

[0018] Generate and push a configuration prompt message of the number of cache entries and cache time according to the API application scenario type, the API size, and the number of times the API is used;

[0019] Receiving configuration data input in response to the cache number and cache time configuration prompt message;

[0020] According to the configuration data, configure the number of cache entries and cache time of the API.

[0021] In one embodiment, the data service execution result caching method further includes:

[0022] If there is no cache instance of the API identity in the first-level cache of Guava Cache, then generate an API cache instance corresponding to the API call event;

[0023] Cache the generated API cache instance and the corresponding API identity in the first-level cache of Guava Cache.

[0024] In one embodiment, if there is no cache instance of the API identity in the first-level cache of Guava Cache, generating the API cache instance corresponding to the API call event includes:

[0025] If there is no cache instance of the API identity in the first-level cache of Guava Cache, query the call parameters and execution results corresponding to the API call event according to the actual business;

[0026] Storing the call parameters and execution results in the secondary cache of the corresponding API;

[0027] Based on the secondary cache of the corresponding API, an API cache instance corresponding to the API call event is generated.

[0028] In one embodiment, the data service execution result caching method further includes:

[0029] Generate a corresponding secondary cache key value according to the calling parameter;

[0030] According to the key value, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache.

[0031] In a second aspect, the present application also provides a data service execution result caching device. The device comprises:

[0032] The cache configuration module is used to obtain the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table;

[0033] The detection module is used to detect API call events and obtain the API identity and target call parameters corresponding to the API call events;

[0034] A processing module, for querying whether there is a second-level cache corresponding to the target call parameter in the first-level cache if there is a cache instance of the API identity in the first-level cache of Guava Cache, wherein the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if there is, querying the cache value corresponding to the target call parameter from the second-level cache, and feeding back the service execution result based on the cache value; if not, querying the execution result corresponding to the API call event according to the actual business and feeding back;

[0035] The cache cleaning module is used to control the detection module to re-execute the operation of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0036] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0037] Get the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table;

[0038] Detect API call events and obtain the API identity and target call parameters corresponding to the API call events;

[0039] If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API;

[0040] If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it;

[0041] Return to the step of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0042] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0043] Get the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table;

[0044] Detect API call events and obtain the API identity and target call parameters corresponding to the API call events;

[0045] If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API;

[0046] If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it;

[0047] Return to the step of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0048] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0049] Get the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table;

[0050] Detect API call events and obtain the API identity and target call parameters corresponding to the API call events;

[0051] If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API;

[0052] If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it;

[0053] Return to the step of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0054] The above-mentioned data service execution result caching method, device, computer equipment, storage medium and computer program product obtain the initial cache configuration table of the API in Guava Cache, add the cache item number field and the cache time field to the initial cache configuration table, and obtain the target cache configuration table; detect API call events, and obtain the API identity and target call parameters corresponding to the API call event; if there is a cache instance of the API identity in the first-level cache of Guava Cache, then query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if it exists, query the cache value corresponding to the target call parameter from the second-level cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it; return to the step of detecting API call events, and clean up the cached data in the first-level cache and the second-level cache according to the target cache configuration table. During the whole process, for API call events, we first determine whether the execution result corresponding to the API call event is cached in the first-level cache and the second-level cache. If so, we directly query and feedback the execution result. Secondly, we use the target cache configuration table with the cache entry field and cache time field to clean up the cached data in the first-level cache and the second-level cache to avoid disorderly increase of cached data, so as to realize orderly caching of data service execution results. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 An application environment diagram of a data service execution result caching method in one embodiment;

[0056] Figure 2 A schematic diagram of a flow chart of a data service execution result caching method in one embodiment;

[0057] Figure 3 A schematic diagram of a flow chart of a data service execution result caching method in another embodiment;

[0058] Figure 4 It is a structural block diagram of a data service execution result caching device in one embodiment;

[0059] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0061] The data service execution result caching method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. Terminal 102 sends a data service execution result cache request to server 104. Server 104 responds to the request, obtains the initial cache configuration table of the API in Guava Cache, adds the cache entry field and the cache time field to the initial cache configuration table, and obtains the target cache configuration table; detects API call events, obtains the API identity and target call parameters corresponding to the API call event; if there is a cache instance of the API identity in the first-level cache of Guava Cache, then queries whether there is a second-level cache corresponding to the target call parameter in the first-level cache, and the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if it exists, then query the cache value corresponding to the target call parameter from the second-level cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it; return to the step of detecting API call events, and clean up the cached data in the first-level cache and the second-level cache according to the target cache configuration table. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0062] In one embodiment, Figure 2 As shown, a data service execution result caching method is provided, and the method is applied to Figure 1 The server 104 in the example is used as an example to illustrate, and the following steps are included:

[0063] S100: Obtain an initial cache configuration table of the API in Guava Cache, add a cache entry field and a cache time field to the initial cache configuration table, and obtain a target cache configuration table.

[0064] Guava Cache is a lightweight local cache component provided by the Google Guava library, which is simple, lightweight, complete, and highly extensible. Here, first, the server obtains the initial cache configuration table of the API from Guava Cache. Guava Cache is a widely used Java cache library that provides powerful caching capabilities. Next, two new fields are added to the initial cache configuration table: the cache entry field and the cache time field. These two fields are used to specify the maximum storage quantity and storage time of each cache item, respectively. After this step, the target cache configuration table is obtained, which will be used to guide the subsequent cache management.

[0065] S200: Detecting an API call event, and obtaining an API identity and target call parameters corresponding to the API call event.

[0066] The server continuously detects API call events, that is, monitors whether an API is called. When an API call event is detected, the API identity (such as the API name or ID) and target call parameters (i.e., the parameters passed when calling the API) corresponding to the event are obtained.

[0067] S300: If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache. The first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API.

[0068] Next, the server checks whether there is a cache instance matching the API identity in the first-level cache of Guava Cache. The first-level cache is used to store different API identities and their corresponding cache information. If there is a cache instance of the API identity in the first-level cache, proceed to the next step; if not, query the execution result corresponding to the API call event according to the actual business logic and directly feedback the result.

[0069] S400: If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it.

[0070] After finding a matching API identity in the first-level cache, the server further checks whether there is a second-level cache corresponding to the target call parameters. The second-level cache is used to store cache results of different call parameters under the same API identity. If there is a second-level cache that matches the target call parameters, the corresponding cache value is queried from the second-level cache, and the service execution result is fed back based on this cache value. If there is no matching second-level cache, the execution result corresponding to the API call event is queried according to the actual business logic, and the result is fed back.

[0071] S500: Return to the step of detecting the API call event, and clear the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

[0072] After the service execution result is fed back, the server returns to the step of detecting API call events and continues to monitor new API call events. At the same time, according to the target cache configuration table, the data stored in the first-level cache and the second-level cache are cleaned up regularly. This includes removing cache items that have exceeded the specified storage time, and when the number of cache items exceeds the specified maximum value, according to certain strategies, such as LRU (Least Recently Used), deleting some cache items to maintain the effectiveness and performance of the cache and achieve orderly caching.

[0073] The above-mentioned data service execution result caching method obtains the initial cache configuration table of the API in Guava Cache, adds the cache entry field and the cache time field to the initial cache configuration table, and obtains the target cache configuration table; detects API call events, obtains the API identity and target call parameters corresponding to the API call event; if there is a cache instance of the API identity in the first-level cache of Guava Cache, then queries whether there is a second-level cache corresponding to the target call parameter in the first-level cache, and the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if it exists, then query the cache value corresponding to the target call parameter from the second-level cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it; return to the step of detecting API call events, and clean up the cached data in the first-level cache and the second-level cache according to the target cache configuration table. During the whole process, for API call events, we first determine whether the execution result corresponding to the API call event is cached in the first-level cache and the second-level cache. If so, we directly query and feedback the execution result. Secondly, we use the target cache configuration table with the cache entry field and cache time field to clean up the cached data in the first-level cache and the second-level cache to avoid disorderly increase of cached data, so as to realize orderly caching of data service execution results.

[0074] In one embodiment, if Figure 3 As shown, S100 includes:

[0075] S120: Obtain the initial cache configuration table and application scenario parameters of the API in Guava Cache.

[0076] Get the cache configuration table preset for the API from the Guava Cache system. This table may contain some basic configuration items, such as the cache concurrency level, whether to allow null values, etc. At the same time, collect and parse the application scenario parameters of the API, which may include key information such as the API call frequency, data size, and access mode.

[0077] S140: Based on the application scenario parameters, analyze the API application scenario type, API size, and API usage times.

[0078] Using the collected application scenario parameters, we can classify the application scenario types of the API, such as high concurrency, low latency, large data volume, etc. We can evaluate the size of the API, which involves the scale of the data returned by the API or the complexity of the API call. We can count the number of times the API is used, that is, the frequency with which the API is called, which helps us understand the activity and demand intensity of the API.

[0079] S160: Configure the number of cache entries and cache time of the API according to the API application scenario type, API size, and API usage times.

[0080] According to the application scenario type, size and number of times the API is used, set a reasonable number of cache entries and cache time. The number of cache entries determines the number of API results that can be stored in the cache and should be set according to the API call frequency and data scale. The cache time defines the validity period of the cached results and should be adjusted according to the update frequency and access pattern of the API data. Generally speaking, the larger the API or the more times the API is used, the smaller the corresponding number of cache entries and cache time of the API, that is, there is an approximately inverse correlation between the number of cache entries, cache time, API size and API usage times.

[0081] S180: According to the number of cache entries and the cache time, a cache entry number field and a cache time field are added to the initial cache configuration table to obtain a target cache configuration table.

[0082] Based on the initial cache configuration table, add the cache entry field and cache time field. According to the previous analysis, assign specific values ​​to these two fields to generate a customized target cache configuration table to support custom, intelligent, and automatic adjustment of cache configuration.

[0083] In one embodiment, according to the API application scenario type, the API size, and the number of times the API is used, configuring the number of cache entries and the cache time of the API includes:

[0084] Step 1: Generate and push a configuration prompt message for the number of cache entries and cache time based on the API application scenario type, API size, and API usage times.

[0085] Based on the collected key information such as API application scenario type, API size, and usage times, the server will intelligently generate a configuration prompt message about the number of cache entries and cache time. This prompt message will be clearly displayed to relevant configuration personnel so that they can configure appropriate cache parameters for the API based on this information.

[0086] Step 2: Receive configuration data input in the response cache number and cache time configuration prompt message.

[0087] The configuration personnel or system will receive the above configuration prompt message and enter the corresponding cache number and cache time configuration data according to their own professional knowledge and business needs. These configuration data will serve as an important basis for the subsequent configuration of cache parameters for the API.

[0088] Step 3: Configure the number of cache entries and cache time of the API according to the configuration data.

[0089] Based on the received configuration data, the server configures the number of cache entries and cache time for the API according to the current application requirements. These configuration parameters will directly affect the performance and efficiency of the API cache, so their accuracy and rationality must be ensured.

[0090] In one embodiment, the data service execution result caching method further includes:

[0091] If there is no cache instance of the API identity in the first-level cache of Guava Cache, an API cache instance corresponding to the API call event is generated; the generated API cache instance and the corresponding API identity are cached in the first-level cache of GuavaCache.

[0092] When the server detects an API call event, it will first check whether there is a cache instance corresponding to the API identity in the first-level cache of Guava Cache. If there is no cache instance for the API identity in the first-level cache, it means that this is a new API call or the previous cache has expired / been removed. After confirming that there is no corresponding cache instance in the first-level cache, the server will generate a new API cache instance based on the current API call event and necessary business logic. This cache instance will contain the API call results and possible other relevant information, such as call time, expiration time, etc. The newly generated API cache instance will be stored in the first-level cache of Guava Cache together with the corresponding API identity. This ensures that in subsequent API calls, if the parameters are the same, the results can be obtained directly from the cache, thereby improving the response speed of the data service.

[0093] In one embodiment, if there is no cache instance of the API identity in the first-level cache of Guava Cache, generating an API cache instance corresponding to the API call event includes:

[0094] If there is no cache instance of the API identity in the first-level cache of Guava Cache, query the call parameters and execution results corresponding to the API call event according to the actual business; store the call parameters and execution results in the second-level cache of the corresponding API; and generate the API cache instance corresponding to the API call event based on the second-level cache of the corresponding API.

[0095] When the server detects an API call event, it will first try to find a cache instance that matches the API identity in the first-level cache of Guava Cache. If the cache instance of the API identity does not exist in the first-level cache, it indicates that further measures need to be taken to generate a new cache instance. After the first-level cache query fails, the server will query the call parameters and execution results corresponding to the API call event according to the actual business logic. After obtaining the call parameters and execution results of the API call event, the server will store this information in the second-level cache of the corresponding API (corresponding to the call parameters). Based on the call parameters and execution results obtained from the second-level cache (or directly from the business query), the server will generate a new API cache instance. This cache instance will contain the API call results and possible other related information, such as call time, expiration time, API identity, etc. Finally, the newly generated API cache instance will be stored in the first-level cache of Guava Cache for fast access in subsequent API calls.

[0096] In one embodiment, the data service execution result caching method further includes:

[0097] Generate the corresponding secondary cache key value according to the calling parameters; according to the key value, query whether there is a secondary cache corresponding to the target calling parameters in the primary cache.

[0098] In this embodiment, the server generates a unique key value based on the API call parameters (such as request path, query parameters, request header, etc.). This key value will be used to identify and query the corresponding cache data in the secondary cache. Specifically, the process of generating the key value here can be understood as a "data compression" process. Furthermore, the API call parameters (such as request path, query parameters, request header, etc.) can be serialized, and then a hash function (such as MD5, SHA-1, SHA-256, etc.) can be applied to generate a fixed-length hash value as the key.

[0099] In one specific application example, the application data service execution result caching method includes the following steps:

[0100] 1. Create a data table model. Add two fields to the data service API configuration table: cache_count, the number of cache entries, and cache_time, the default cache time in minutes.

[0101] 2. Data service API development: When developing a data service API, you can configure the number of cache entries and cache time and save the API configuration information to the database, while also supporting the modification of configuration information.

[0102] 3. Data service API release: After the data service API is developed and tested, the API can be released to the corresponding node that executes the service.

[0103] 4. Data service API call. When calling the API, you can generate a first-level cache for a single API and a second-level cache for the calling parameters based on the API's cache configuration information. When calling the API, check whether there is a cache based on the API_ID. If not, create a corresponding first-level cache. If yes, get the cache instance of the corresponding API_ID from the cache. Generate the corresponding second-level cache key value based on the calling parameters. First determine whether there is a second-level cache key value in the first-level cache instance. If not, set the corresponding cache in the second-level cache, and set the number of cache entries and cache time for the API_ID. If yes, return the corresponding value, that is, the corresponding execution result cache.

[0104] 5. Cache clearing. The cache for the API will be automatically cleared after the cache time has expired; when the maximum number of cache entries is reached, the cache will be cleared using LRU. Alternatively, you can trigger manual clearing for a specific API.

[0105] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0106] Based on the same inventive concept, the embodiment of the present application also provides a data service execution result caching device for implementing the data service execution result caching method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data service execution result caching device embodiments provided below can refer to the limitations of the data service execution result caching method above, and will not be repeated here.

[0107] In one embodiment, Figure 4 As shown, a data service execution result caching device is provided, comprising:

[0108] The cache configuration module 100 is used to obtain the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field to the initial cache configuration table, and obtain the target cache configuration table;

[0109] The detection module 200 is used to detect API call events and obtain API identity identifiers and target call parameters corresponding to the API call events;

[0110] Processing module 300 is used to query whether there is a second-level cache corresponding to the target call parameter in the first-level cache if there is a cache instance of the API identity in the first-level cache of Guava Cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if there is, query the cache value corresponding to the target call parameter from the second-level cache, and feedback the service execution result based on the cache value; if not, query the execution result corresponding to the API call event according to the actual business and feedback;

[0111] The cache cleaning module 400 is used to control the detection module to re-execute the operation of detecting the API call event, and clean up the cached data in the first-level cache and the second-level cache according to the target cache configuration table.

[0112] In one of the embodiments, the cache configuration module 100 is also used to obtain the initial cache configuration table and application scenario parameters of the API in Guava Cache; based on the application scenario parameters, analyze the API application scenario type, API size and API usage times; configure the number of cache entries and cache time of the API according to the API application scenario type, API size and API usage times; according to the number of cache entries and cache time, add a cache entry field and a cache time field to the initial cache configuration table to obtain a target cache configuration table.

[0113] In one of the embodiments, the cache configuration module 100 is also used to generate and push a cache number and cache time configuration prompt message based on the API application scenario type, API size, and API usage times; receive configuration data input in response to the cache number and cache time configuration prompt message; and configure the API's cache number and cache time based on the configuration data.

[0114] In one embodiment, the processing module 300 is also used to generate an API cache instance corresponding to the API call event if there is no cache instance of the API identity in the first-level cache of Guava Cache; and cache the generated API cache instance and the corresponding API identity in the first-level cache of Guava Cache.

[0115] In one of the embodiments, the processing module 300 is also used to query the call parameters and execution results corresponding to the API call event according to the actual business if there is no cache instance of the API identity in the first-level cache of Guava Cache; store the call parameters and execution results in the second-level cache of the corresponding API; and generate an API cache instance corresponding to the API call event based on the second-level cache of the corresponding API.

[0116] In one embodiment, the processing module 300 is further configured to generate a corresponding secondary cache key value according to the calling parameter; and query the primary cache according to the key value whether there is a secondary cache corresponding to the target calling parameter.

[0117] Each module in the data service execution result cache device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0118] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store preset data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data service execution result caching method is implemented.

[0119] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0120] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned data service execution result caching method when executing the computer program.

[0121] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned data service execution result caching method is implemented.

[0122] In one embodiment, a computer program product is provided, including a computer program, which implements the above-mentioned data service execution result caching method when executed by a processor.

[0123] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0124] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0125] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A data service execution result caching method, characterized in that: The method comprises: Get the initial cache configuration table of the API in Guava Cache, add the cache entry field and the cache time field in the initial cache configuration table, and obtain the target cache configuration table; Detect API call events and obtain the API identity and target call parameters corresponding to the API call events; If there is a cache instance of the API identity in the first-level cache of Guava Cache, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache, the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; If it exists, query the cache value corresponding to the target call parameter from the secondary cache, and feedback the service execution result based on the cache value; if it does not exist, query the execution result corresponding to the API call event according to the actual business and feedback it; Return to the step of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

2. The method according to claim 1, characterized in that The initial cache configuration table of the API in Guava Cache is obtained, and the cache entry number field and the cache time field are added to the initial cache configuration table to obtain the target cache configuration table, including: Get the initial cache configuration table and application scenario parameters of the API in Guava Cache; Based on the application scenario parameters, analyzing the API application scenario type, API size, and API usage times; Configure the number of cache entries and cache time of the API according to the API application scenario type, the API size, and the number of times the API is used; According to the cache number and the cache time, a cache number field and a cache time field are added to the initial cache configuration table to obtain a target cache configuration table.

3. The method according to claim 2, characterized in that Configuring the number of cache entries and cache time of the API according to the API application scenario type, the API size, and the number of times the API is used includes: Generate and push a configuration prompt message of the number of cache entries and cache time according to the API application scenario type, the API size, and the number of times the API is used; Receiving configuration data input in response to the cache number and cache time configuration prompt message; According to the configuration data, configure the number of cache entries and cache time of the API.

4. The method according to claim 1, characterized in that: Also includes: If there is no cache instance of the API identity in the first-level cache of Guava Cache, generate an API cache instance corresponding to the API call event; Cache the generated API cache instance and the corresponding API identity in the first-level cache of Guava Cache.

5. The method according to claim 4, characterized in that If there is no cache instance of the API identity in the first-level cache of Guava Cache, generating an API cache instance corresponding to the API call event includes: If there is no cache instance of the API identity in the first-level cache of Guava Cache, query the call parameters and execution results corresponding to the API call event according to the actual business; Storing the call parameters and execution results in the secondary cache of the corresponding API; Based on the secondary cache of the corresponding API, an API cache instance corresponding to the API call event is generated.

6. The method according to claim 1, characterized in that Also includes: Generate a corresponding secondary cache key value according to the calling parameter; According to the key value, query whether there is a second-level cache corresponding to the target call parameter in the first-level cache.

7. A data service execution result caching device, characterized in that: The device comprises: A cache configuration module is used to obtain an initial cache configuration table of the API in Guava Cache, add a cache entry field and a cache time field to the initial cache configuration table, and obtain a target cache configuration table; The detection module is used to detect API call events and obtain the API identity and target call parameters corresponding to the API call events; A processing module, for querying whether there is a second-level cache corresponding to the target call parameter in the first-level cache if there is a cache instance of the API identity in the first-level cache of Guava Cache, wherein the first-level cache stores different call parameters corresponding to the API identity, and different second-level caches store different call parameters corresponding to the same API; if there is, querying the cache value corresponding to the target call parameter from the second-level cache, and feeding back the service execution result based on the cache value; if not, querying the execution result corresponding to the API call event according to the actual business and feeding back; The cache cleaning module is used to control the detection module to re-execute the operation of detecting the API call event, and clean up the data cached in the first-level cache and the second-level cache according to the target cache configuration table.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.