Method and apparatus for managing cached data
Patent Information
- Application Number
- CN202510450876.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2026-10-20
AI Technical Summary
但如果缓存过期时长设置的不够合理,会给系统的正常运行带来了不良影响
[0042]上述发明中的一个实施例具有如下优点或有益效果:目标缓存位置为调用缓存的代码在目标代码体中的位置。目标代码体可以为:方法、函数、存储过程等。根据目标缓存位置对应的缓存执行信息、配置信息及服务器状态信息,确定目标缓存位置对应的缓存过期时长。再根据缓存过期时长,对目标缓存位置对应的缓存数据进行存储管理。能够实现缓存过期时长的自动调整,合理地设置缓存过期时长,保证系统的正常运行。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for managing cached data. Background Technology
[0002] To improve system performance and reduce the pressure on backend services, results of remote calls, database queries, and data calculations are typically cached. In practical applications of caching, to effectively manage cache resources and ensure data timeliness, a reasonable cache TTL (Time To Live) needs to be set. This expiration time is usually determined based on the developer's experience. However, if the cache expiration time is not set appropriately, it can negatively impact the normal operation of the system. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method and apparatus for managing cached data, which can reasonably set the cache expiration time to ensure the normal operation of the system.
[0004] In a first aspect, embodiments of the present invention provide a method for managing cached data, including:
[0005] Retrieve cache execution information corresponding to the target cache location;
[0006] Retrieve the configuration information corresponding to the target cache location;
[0007] Retrieve server status information corresponding to the target cache location;
[0008] Based on cache execution information, configuration information, and server status information, determine the cache expiration time corresponding to the target cache location;
[0009] Based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed.
[0010] Optionally, the target cache location is located within the target code body; a cache annotation is added to the target code body.
[0011] Retrieve cache execution information corresponding to the target cache location, including:
[0012] During the execution of the target code body, cache annotations are used to determine the location information and cache markers corresponding to the target cache location; among them, the cache markers are used to indicate whether the cache data corresponding to the target cache location has been hit;
[0013] Based on the location information and cache tag corresponding to the target cache location, generate cache execution information corresponding to the target cache location.
[0014] Optionally, before obtaining the configuration information corresponding to the target cache location, the following steps are also included:
[0015] Receive configuration instructions for the target cache location;
[0016] Determine the input information corresponding to the configuration command;
[0017] The input information is determined to be the configuration information corresponding to the target cache location.
[0018] Optionally, obtain the server status information corresponding to the target cache location, including:
[0019] Determine the cache type corresponding to the target cache location;
[0020] In response to the cache type characterization of the local cache, determine the local server corresponding to the target cache location; and determine the status information corresponding to the local server as the server status information corresponding to the target cache location.
[0021] In response to the distributed cache type, determine the cache server corresponding to the target cache location; and use the status information of the cache server as the server status information corresponding to the target cache location.
[0022] Optionally, the cache expiration time corresponding to the target cache location is determined based on cache execution information, configuration information, and server status information, including:
[0023] Based on the server status information, determine the original expiration time corresponding to the target cache location;
[0024] Based on cache execution information, configuration information, and cache server status information, at least one influencing factor is determined;
[0025] Determine the duration adjustment factor based on at least one influencing factor;
[0026] The cache expiration time corresponding to the target cache location is determined based on the original expiration time and the time adjustment factor.
[0027] Optionally, after obtaining the server status information corresponding to the target cache location, the method further includes:
[0028] Based on cache execution information, configuration information, and server status information, determine the cache performance information corresponding to the target cache location;
[0029] Based on the configuration information, determine the preset range corresponding to the cache performance information;
[0030] In response to cache performance information falling outside the preset range, an alarm message corresponding to the cache performance information is generated.
[0031] Secondly, embodiments of the present invention provide a management device for cached data, comprising:
[0032] The first acquisition module is used to acquire cache execution information corresponding to the target cache location;
[0033] The second acquisition module is used to acquire the configuration information corresponding to the target cache location;
[0034] The third acquisition module is used to acquire server status information corresponding to the target cache location;
[0035] The duration determination module is used to determine the cache expiration duration corresponding to the target cache location based on cache execution information, configuration information, and server status information.
[0036] The storage management module is used to manage the storage of cached data corresponding to the target cache location based on the cache expiration time.
[0037] Thirdly, embodiments of the present invention provide an electronic device, comprising:
[0038] One or more processors;
[0039] A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the methods of any of the above embodiments.
[0040] Fourthly, embodiments of the present invention provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method of any of the above embodiments.
[0041] Fifthly, embodiments of the present invention provide a computer program product, including a computer program, wherein the computer program, when executed by a processor, implements the method of any of the above embodiments.
[0042] One embodiment of the above invention has the following advantages or beneficial effects: The target cache location is the position of the code that calls the cache within the target code body. The target code body can be: a method, function, stored procedure, etc. Based on the cache execution information, configuration information, and server status information corresponding to the target cache location, the cache expiration time corresponding to the target cache location is determined. Then, based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed. This enables automatic adjustment of the cache expiration time, reasonably sets the cache expiration time, and ensures the normal operation of the system.
[0043] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0044] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0045] Figure 1 This is a schematic diagram of a process for managing cached data according to an embodiment of the present invention;
[0046] Figure 2 This is a schematic diagram of a method for managing cached data according to another embodiment of the present invention;
[0047] Figure 3 This is a schematic diagram of the execution flow of a cached data management system provided in one embodiment of the present invention;
[0048] Figure 4 This is a schematic diagram illustrating the architecture deployment of a data caching management system according to an embodiment of the present invention;
[0049] Figure 5 This is a schematic diagram of the execution flow of a calling module provided in an embodiment of the present invention;
[0050] Figure 6 This is a schematic diagram illustrating the execution principle of an information collection module according to an embodiment of the present invention;
[0051] Figure 7 This is a schematic diagram of the execution flow of an information collection module provided in an embodiment of the present invention;
[0052] Figure 8 This is a schematic diagram of the execution flow of a computing module provided in one embodiment of the present invention;
[0053] Figure 9 This is a schematic diagram of the execution flow of an instruction execution module provided in an embodiment of the present invention;
[0054] Figure 10 This is a schematic diagram of the structure of a cached data management device provided in one embodiment of the present invention;
[0055] Figure 11 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0056] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0057] It should be noted that the acquisition, storage, use, and processing of data in the technical solutions of this invention comply with the relevant provisions of national laws and regulations.
[0058] Figure 1 This is a schematic diagram illustrating the flow of a cached data management method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0059] Step 101: Obtain the cache execution information corresponding to the target cache location.
[0060] The target cache location is the position of the code that calls the cache within the target code body. The target code body can be a method, function, stored procedure, etc. The target cache location may include: the name of the target code body, the position of the target code within the target code body, and the host information where the target code body resides. The target code is the code within the target code body that calls the cache.
[0061] For example, the target cache location could be: Process1|Job1.java.43|127.0.0.1. Here, Process1 is the name of the target code body. Job1.java.43 is the location of the target code within the target code body. 127.0.0.1 is the host machine where the target code body resides.
[0062] Cache execution information refers to the execution information of the target code obtained during the execution of the target code body. Cache execution information may include: target cache location, input parameters, output parameters, cache flags, local cache size, local cache TTL, etc. Among these, the cache flags are used to indicate whether the cached data corresponding to the target cache location has been hit.
[0063] Step 102: Obtain the configuration information corresponding to the target cache location.
[0064] The configuration information includes attribute information related to the target cache location. This information may include: cache type, target cache location, maximum extension, maximum memory usage, minimum cache hit rate, input parameter duplication rate, output parameter duplication rate, alarm recipient, and alarm group. Users can configure the configuration information corresponding to the target cache location according to their business needs.
[0065] Step 103: Obtain the server status information corresponding to the target cache location.
[0066] The server status information refers to the status information of the target server. The target server is the server where the cached data called by the target code resides. Server status information may include: distributed cache size, total cache memory size, distributed cache TTL, etc.
[0067] In one embodiment of the present invention, obtaining server status information corresponding to a target cache location includes: determining the cache type corresponding to the target cache location; determining the local server corresponding to the target cache location in response to the cache type representing a local cache; determining the status information corresponding to the local server as the server status information corresponding to the target cache location; determining the cache server corresponding to the target cache location in response to the cache type representing a distributed cache; and determining the status information corresponding to the cache server as the server status information corresponding to the target cache location.
[0068] If the cache type indicates a local cache, then the cached data called by the target code is stored on the local server. The local server corresponding to the target cache location is then determined. The status information of the local server is then used to determine the server status information corresponding to the target cache location.
[0069] If the cache type represents a distributed cache, then the cached data accessed by the target code is stored on the cache server. The cache server corresponding to the target cache location is then identified. The status information of the cache server is then used to determine the server status information corresponding to the target cache location.
[0070] Step 104: Determine the cache expiration time corresponding to the target cache location based on the cache execution information, configuration information, and server status information.
[0071] Cache execution information, configuration information, and server status information can be input into the duration prediction model. Based on the output of the duration prediction model, the cache expiration duration corresponding to the target cache location can be determined.
[0072] Step 105: Based on the cache expiration time, manage the storage of cache data corresponding to the target cache location.
[0073] If the cache expiration time differs from the cache expiration time applied at the target cache location, modify the cache expiration time applied at the target cache location based on the original cache expiration time.
[0074] Based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed. Specifically, the storage time of the target cache data in the target server is determined; if the storage time exceeds the cache expiration time, the target cache data is deleted from the target server.
[0075] In this embodiment of the invention, the cache expiration time corresponding to the target cache location is determined based on the cache execution information, configuration information, and server status information corresponding to the target cache location. Then, based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed. This enables automatic adjustment of the cache expiration time, reasonably sets the cache expiration time, and ensures the normal operation of the system.
[0076] Figure 2 This is a schematic diagram of a method for managing cached data according to another embodiment of the present invention. Figure 2 As shown, the method includes:
[0077] Step 201: During the execution of the target code body, use cache annotations to determine the location information and cache markers corresponding to the target cache location; among them, the cache markers are used to indicate whether the cache data corresponding to the target cache location has been hit.
[0078] The target cache location is within the target code body. The JAR file is included in the target code body. After including the JAR file, methods within the JAR file can be called within the target code body to retrieve cached data, determine if cached data has been hit, record input and / or output parameters, generate cache execution information, and generate and send cache messages corresponding to the cache execution information.
[0079] Add cache annotations to the target code body. Cache annotations are metadata in the code that can be used to provide information or instructions. Using cache annotations, you can determine the location information, execution-related information, and cache tags corresponding to the target cache location. Location information may include: the name of the target code body, the code position of the target code within the target code body, and the host information where the target code body is located. The target code is the code within the target code body that calls the cache. Execution-related information may include: input parameters, output parameters, local cache size, and local cache TTL.
[0080] Step 202: Generate cache execution information corresponding to the target cache location based on the location information and cache tag corresponding to the target cache location.
[0081] Cache execution information may include: location information and cache tags corresponding to the target cache location. Cache execution information may also include: execution-related information, etc.
[0082] Step 203: Obtain the configuration information corresponding to the target cache location.
[0083] Step 204: Obtain the server status information corresponding to the target cache location.
[0084] Step 205: Determine the cache expiration time corresponding to the target cache location based on the cache execution information, configuration information, and server status information.
[0085] Step 206: Based on the cache expiration time, perform storage management on the cache data corresponding to the target cache location.
[0086] This invention provides a method for dynamically adjusting cache expiration time. By including a specific JAR package in the target code body that needs to be cached and adding a specific cache annotation to the target code body, the system can automatically configure the cache. The system calculates and sets an appropriate cache expiration time based on code execution status, server status, and configuration information. With this invention, developers can achieve automated and dynamic adjustment of cache expiration time without manually setting and adjusting it.
[0087] In one embodiment of the present invention, before obtaining the configuration information corresponding to the target cache location, the method further includes: receiving a configuration instruction for the target cache location; determining the input information corresponding to the configuration instruction; and determining the input information as the configuration information corresponding to the target cache location.
[0088] The configuration information consists of attributes related to the target cache location. This information may include: cache type, target cache location, maximum duration, maximum memory usage, minimum cache hit rate, input parameter duplication rate, and output parameter duplication rate. Users can input or modify the values of each configuration item using configuration commands according to business needs. The system can preset default values for each configuration item. If the user does not input a value for the configuration item, the default value will be used.
[0089] In one embodiment of the present invention, determining the cache expiration duration corresponding to the target cache location based on cache execution information, configuration information, and server status information includes: determining the original expiration duration corresponding to the target cache location based on server status information; determining at least one influencing factor based on cache execution information, configuration information, and cache server status information; determining a duration adjustment factor based on at least one influencing factor; and determining the cache expiration duration corresponding to the target cache location based on the original expiration duration and the duration adjustment factor.
[0090] Multiple influencing factors, their value ranges, calculation formulas, and time-to-live (TTL) adjustment factors can be set according to requirements. Influence factors may include: memory usage, cache hit rate, input parameter duplication rate, and output parameter duplication rate. The value range for each influencing factor can be 0-0.1.
[0091] For example, if the current cache hit rate is less than the minimum cache hit rate, then the TTL needs to be extended. The cache hit rate impact factor = minimum cache hit rate - cache hit rate impact factor. The TTL adjustment factor = TTL adjustment factor * (1 + cache hit rate impact factor).
[0092] If the current cache hit rate is greater than the minimum cache hit rate, then the TTL needs to be shortened. The cache hit rate impact factor = cache hit rate impact factor - minimum cache hit rate. The TTL adjustment factor = TTL adjustment factor * (1 - cache hit rate impact factor).
[0093] For example, if the parameter duplication rate is greater than the estimated parameter duplication rate, then the time-to-live (TTL) needs to be extended. The parameter duplication rate impact factor = parameter duplication rate - estimated parameter duplication rate. The TTL adjustment factor = TTL adjustment factor * (1 + parameter duplication rate impact factor).
[0094] If the parameter duplication rate is less than the estimated parameter duplication rate, then the time-to-live (TTL) needs to be shortened. The parameter duplication rate impact factor = estimated parameter duplication rate - parameter duplication rate. The TTL adjustment factor = TTL adjustment factor * (1 - parameter duplication rate impact factor).
[0095] When the influencing factors include cache hit rate and parameter duplication rate, and the current cache hit rate is less than the minimum cache hit rate, and the parameter duplication rate is greater than the estimated parameter duplication rate, the TTL adjustment factor is calculated as: TTL adjustment factor * (1 + cache hit rate influencing factor) * (1 + parameter duplication rate influencing factor).
[0096] This process is repeated to calculate the final TTL adjustment factor. The calculated new cache TTL = current cache TTL * TTL adjustment factor.
[0097] In one embodiment of the present invention, after obtaining the server status information corresponding to the target cache location, the method further includes: determining the cache performance information corresponding to the target cache location based on the cache execution information, configuration information, and server status information; determining the preset range corresponding to the cache performance information based on the configuration information; and generating alarm information corresponding to the cache performance information in response to the cache performance information not being within the preset range.
[0098] Cache performance information and its determination method can be configured according to business needs. The configuration information may include a preset range for the cache performance information. Users can adjust this preset range using configuration commands. If the determined cache performance information is outside the preset range, an alarm will be generated to alert relevant technical personnel to investigate the issue promptly.
[0099] Figure 3 This is a schematic diagram illustrating the execution flow of a data caching management system according to an embodiment of the present invention. Figure 3 As shown, the complete process of the management system is as follows:
[0100] Step 01: Developers include the JAR file in the target code body and add cache annotations to the methods that need caching. The JAR file is used to retrieve cached data, determine whether cached data has been hit, record input parameters and / or output parameters, and generate cache execution information, etc.
[0101] The calling module generates a unique cache ID (identifier) based on the code location, server deployment address, and interface input parameters. This module asynchronously transmits the cached messages to the information collection module using message middleware such as Kafka or JDQ. The cached messages include: cache ID, interface call input parameters, output parameters, cache hit status, and cache server connection information.
[0102] Step 02: After receiving the cache message from the calling module, the information collection module starts a timer to periodically acquire configuration information managed by the configuration module. Configuration information may include: cache type, cache address, exception alarm contact person, alarm group, accepted latency, maximum memory usage, minimum cache hit rate, and other cache estimation boundary information. In addition, the timer also periodically acquires information related to the cache key from the cache server based on the cache address, such as memory usage and the current TTL. After merging and processing, the above information will be sent to the calculation module for further analysis and processing.
[0103] Step 03: The calculation module calculates the call frequency and cache hit rate of the current cache address in real time based on the execution status at the cache. Then, combining this with the configured cache prediction boundary information and server status information, and based on a series of weights, it calculates the new TTL and cache performance information corresponding to the cache ID. Finally, the new TTL and cache ID are sent to the instruction execution module. The cache performance information is then sent to the monitoring module.
[0104] Step 04: After receiving the cache performance information from the status calculation module, the monitoring module displays this information on the front-end page. If the cache performance information corresponding to a certain cache ID exceeds the configured boundary, or if abnormal situations such as excessive cache memory usage occur, an alarm message will be issued.
[0105] Step 05: After receiving the cache ID and its corresponding TTL from the computing module, the instruction execution module executes the corresponding cache TTL change instruction according to different cache types. This completes one cycle.
[0106] Figure 4 This is a schematic diagram illustrating the architecture deployment of a data caching management system according to an embodiment of the present invention. Figure 4As shown, developers configure cache-related settings through the configuration module. They include the JAR file in the target code body and add cache annotations to methods where caching is required. The information collection module receives cache execution information, configuration information, and server status information. The calculation module calculates the cache expiration time based on these information. After receiving cache performance information from the status calculation module, the monitoring module displays this information on the front-end page. The instruction execution module receives the cache ID and its corresponding TTL from the calculation module and executes the corresponding cache TTL change instruction.
[0107] Figure 5 This is a schematic diagram illustrating the execution flow of a calling module according to an embodiment of the present invention. Figure 5 As shown, the calling module utilizes the aspect mechanism of annotations to weave an aspect before and after each interface call or data query. Aspect 1 is responsible for cache initialization and hit detection, while aspect 2 is responsible for sending cached messages.
[0108] Before making an API call or querying data, Aspect 1 first determines whether it is the first execution. If so, it generates a unique cache ID based on the API or method class name, call location, server address, and other information, and initializes a local cache with a default TTL. If it is not the first execution, it directly queries the local cache. Finally, it marks whether the cache has been hit.
[0109] After an API call or data query, Aspect 2 asynchronously generates a cache message. This cache message includes: the API return value, cache size, input parameters, output parameters, and cache hit status. This cache information is then sent to the information collection module.
[0110] The configuration module is responsible for centrally storing the caching information required by developers for use in information collection. The module's execution flow is as follows: Developers need to configure the following information: cached code location, cache type, cache address, exception alert contact person, alert group, and estimated boundary parameters. Boundary parameters may include: maximum latency, maximum memory usage, minimum cache hit rate, and estimated input / output parameter duplication rate, etc. Cache types may include: local cache and distributed cache. These configuration items all provide system default values. For example, the cache type is set to local cache by default, and the maximum latency is set to 10 minutes by default, etc.
[0111] User-configured cached information is stored in the configuration module's database, supporting update and deletion operations. The configuration module provides an RPC (Remote Procedure Call) interface for the information collection module to use.
[0112] Figure 6This is a schematic diagram illustrating the execution principle of an information collection module according to an embodiment of the present invention. Figure 6 As shown, the information collection module is used to collect cache information issued by the calling module. Cache information may include: cache ID, input parameters, and output parameters. This module periodically retrieves configuration information defined in the configuration module, such as cache type, cache address, and alert recipients. It also periodically extracts server status information from the cache server, such as cache key size and cache expiration time. By integrating these three types of information, the information collection module transmits the comprehensive data to the calculation module and the monitoring and alarm module to support further processing and analysis.
[0113]
[0114] Figure 7 This is a schematic diagram illustrating the execution flow of an information collection module according to an embodiment of the present invention. Figure 7 As shown, the execution flow of the information collection module includes:
[0115] Step 11: After receiving the cache message from the calling module, obtain the cache execution information based on the cache message. Store the cache ID of the cache message in a SET set. A SET set is used to ensure that the cache ID is unique. This set can be stored in a local cache or a distributed cache.
[0116] Step 12: Start the scheduler to asynchronously retrieve various cache information from the configuration module periodically based on the cache ID in the Set collection.
[0117] Step 13: Start the scheduler to asynchronously retrieve server status information periodically based on the cache ID in the Set collection and the configured cache address.
[0118] Step 14: Store the obtained configuration information and server status information, usually using a distributed cache.
[0119] Step 15: Query the cache based on the cache ID set, and integrate the configuration information, cache execution information, and server status information. The integrated data is usually in JSON format.
[0120] Step 16: Send the integrated data to the computing module.
[0121] Figure 8 This is a schematic diagram illustrating the execution flow of a computing module according to an embodiment of the present invention. Figure 8 As shown, the calculation module is responsible for performing calculations on the information transmitted from the information collection module. The specific implementation method is as follows:
[0122] Step 21: Receive cached messages from the information collection module. Group them according to the cache ID in each cached message.
[0123] Step 22: Set up a sliding window with a fixed duration, such as a sliding window with a score of 10. Aggregate the data within the sliding window and output the calculation result once for each sliding window.
[0124] Step 23: Calculate the cache expiration time within the sliding window. The specific implementation process for this step is as follows:
[0125] Step 231: Calculate the call frequency. For each cached message received within the sliding window, the total number of cached messages is incremented by one to obtain the total number of cached messages. Divide the total number of cached messages by the duration of the sliding window to obtain the call frequency.
[0126] Step 232: Obtain the input parameter repetition rate. Store all input parameters under this cache ID. Then, for each cached message containing a duplicate input parameter, increment the repetition count counter to obtain the number of duplicate input parameters. Divide the number of duplicate input parameters by the total number of cached messages to obtain the input parameter repetition rate.
[0127] Obtain the output parameter repetition rate. Store all output parameters under this cache ID. Then, for each cached message with a repeated output parameter, increment the repetition counter to obtain the number of repeated output parameters. Divide the number of repeated output parameters by the total number of cached messages to obtain the output parameter repetition rate.
[0128] Step 233: Obtain the cache hit rate. Divide the number of messages marked as cache hits within the sliding window by the total number of cached messages to obtain the cache hit rate.
[0129] Step 234: Calculate TTL. A feasible method for calculating TTL is given below.
[0130] Step 234.1: Initialize the TTL adjustment factor. The initial value of the adjustment factor can be 1.
[0131] Step 234.2: Calculate each influencing factor and the time-to-live (TTL) adjustment factor. Multiple influencing factors, their value ranges, calculation formulas, and the TTL adjustment factor can be set according to requirements. Influencing factors may include: memory usage influencing factor, cache hit rate influencing factor, input parameter duplication rate influencing factor, and output parameter duplication rate influencing factor. The value range of influencing factors can be 0-0.1.
[0132] Step 234.3: Calculate the final TTL adjustment factor. The calculated new cache TTL = current cache TTL * TTL adjustment factor.
[0133] Step 24: Close the sliding window, integrate and output the calculation results.
[0134] Step 25: Send the calculation results to the monitoring module and the instruction execution module.
[0135] After receiving the adjustment message from the calculation module, the monitoring dashboard module performs the following steps:
[0136] Step 31: Deduplicate the adjustment messages and store them in a relational database.
[0137] Step 32: Based on the stored ID, cache execution information, configuration information, server status information, etc. in the data table, visualize the data on the front-end page and highlight the indicators that are close to the alarm threshold.
[0138] Step 33: If the current cache status information exceeds the configured boundary, or if the current cache server experiences an anomaly such as exceeding the maximum memory limit, an alarm message is sent to the alarm recipient or alarm group. Furthermore, when a developer clicks on an alarm message, the system retrieves the cache ID corresponding to the alarm message and automatically redirects to the relevant configuration page, allowing developers to easily adjust configuration information through the configuration page.
[0139] Figure 9 This is a schematic diagram illustrating the execution flow of an instruction execution module according to an embodiment of the present invention. Figure 9 As shown, after receiving an adjustment message from the state calculation module, it checks whether the old and new cache types are consistent. If they are inconsistent, the cache data is migrated, and the old cache object is deleted. Next, it checks whether the TTL has changed. If it has changed, it generates and executes the corresponding TTL update instruction based on the cache type.
[0140] This invention proposes a configuration-based adaptive cache expiration time adjustment method. This method adaptively determines a suitable TTL based on configuration information, cache execution information, and server status information, achieving automatic TTL adjustment and thus reducing the workload of developers in code writing, system deployment, and maintenance.
[0141] Figure 10 This is a schematic diagram of a cached data management device provided in one embodiment of the present invention. Figure 10 As shown, the device includes:
[0142] The first acquisition module 1001 is used to acquire cache execution information corresponding to the target cache location;
[0143] The second acquisition module 1002 is used to acquire configuration information corresponding to the target cache location;
[0144] The third acquisition module 1003 is used to acquire server status information corresponding to the target cache location;
[0145] The duration determination module 1004 is used to determine the cache expiration duration corresponding to the target cache location based on cache execution information, configuration information, and server status information.
[0146] The storage management module 1005 is used to manage the storage of cache data corresponding to the target cache location based on the cache expiration time.
[0147] Optionally, the target cache location is located within the target code body; a cache annotation is added to the target code body.
[0148] The first acquisition module 1001 is specifically used for:
[0149] During the execution of the target code body, cache annotations are used to determine the location information and cache markers corresponding to the target cache location; among them, the cache markers are used to indicate whether the cache data corresponding to the target cache location has been hit;
[0150] Based on the location information and cache tag corresponding to the target cache location, generate cache execution information corresponding to the target cache location.
[0151] Optionally, the second acquisition module 1002 is further configured to:
[0152] Receive configuration instructions for the target cache location;
[0153] Determine the input information corresponding to the configuration command;
[0154] The input information is determined to be the configuration information corresponding to the target cache location.
[0155] Optionally, the third acquisition module 1003 is specifically used for:
[0156] Determine the cache type corresponding to the target cache location;
[0157] In response to the cache type characterization of the local cache, determine the local server corresponding to the target cache location; and determine the status information corresponding to the local server as the server status information corresponding to the target cache location.
[0158] In response to the distributed cache type, determine the cache server corresponding to the target cache location; and use the status information of the cache server as the server status information corresponding to the target cache location.
[0159] Optionally, the duration determination module 1004 is specifically used for:
[0160] Based on the server status information, determine the original expiration time corresponding to the target cache location;
[0161] Based on cache execution information, configuration information, and cache server status information, at least one influencing factor is determined;
[0162] Determine the duration adjustment factor based on at least one influencing factor;
[0163] The cache expiration time corresponding to the target cache location is determined based on the original expiration time and the time adjustment factor.
[0164] Optionally, it also includes:
[0165] The alarm module is used to determine the cache performance information corresponding to the target cache location based on cache execution information, configuration information, and server status information.
[0166] Based on the configuration information, determine the preset range corresponding to the cache performance information;
[0167] In response to cache performance information falling outside the preset range, an alarm message corresponding to the cache performance information is generated.
[0168] This invention provides an electronic device, comprising:
[0169] One or more processors;
[0170] A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the methods of any of the above embodiments.
[0171] This invention provides a computer program product, including a computer program that, when executed by a processor, implements the method of any of the above embodiments.
[0172] The following is for reference. Figure 11 It shows a schematic diagram of the structure of a computer system 1100 suitable for implementing a terminal device of the present invention. Figure 11 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0173] like Figure 11As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1102 or programs loaded from storage section 1108 into random access memory (RAM) 1103. The RAM 1103 also stores various programs and data required for the operation of the system 1100. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0174] The following components are connected to I / O interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to I / O interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1110 as needed so that computer programs read from them can be installed into storage section 1108 as needed.
[0175] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by central processing unit (CPU) 1101, it performs the functions defined above in the system of this invention.
[0176] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0177] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0178] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be located in a processor, and for example, can be described as: a first acquisition module, a second acquisition module, a third acquisition module, a duration determination module, and a storage management module. The names of these modules do not necessarily limit the module itself; for example, the first acquisition module can also be described as "a module for acquiring cache execution information corresponding to the target cache location".
[0179] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include:
[0180] Retrieve cache execution information corresponding to the target cache location;
[0181] Retrieve the configuration information corresponding to the target cache location;
[0182] Retrieve server status information corresponding to the target cache location;
[0183] Based on cache execution information, configuration information, and server status information, determine the cache expiration time corresponding to the target cache location;
[0184] Based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed.
[0185] According to the technical solution of this embodiment of the invention, the target cache location is the position of the code that calls the cache within the target code body. The target code body can be a method, function, stored procedure, etc. Based on the cache execution information, configuration information, and server status information corresponding to the target cache location, the cache expiration time corresponding to the target cache location is determined. Then, based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed. This enables automatic adjustment of the cache expiration time, reasonably sets the cache expiration time, and ensures the normal operation of the system.
[0186] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for managing cached data, characterized in that, include: Retrieve cache execution information corresponding to the target cache location; Obtain the configuration information corresponding to the target cache location; Obtain the server status information corresponding to the target cache location; Based on the cache execution information, the configuration information, and the server status information, determine the cache expiration time corresponding to the target cache location; Based on the cache expiration time, the cache data corresponding to the target cache location is stored and managed.
2. The method according to claim 1, characterized in that, The target cache location is located within the target code body; a cache annotation has been added to the target code body. The step of obtaining the cache execution information corresponding to the target cache location includes: During the execution of the target code body, the cache annotation is used to determine the location information and cache tag corresponding to the target cache location; wherein, the cache tag is used to indicate whether the cache data corresponding to the target cache location is hit; Based on the location information and cache tag corresponding to the target cache location, cache execution information corresponding to the target cache location is generated.
3. The method according to claim 1, characterized in that, Before obtaining the configuration information corresponding to the target cache location, the process also includes: Receive configuration instructions for the target cache location; Determine the input information corresponding to the configuration command; The input information is determined to be the configuration information corresponding to the target cache location.
4. The method according to claim 1, characterized in that, The step of obtaining the server status information corresponding to the target cache location includes: Determine the cache type corresponding to the target cache location; In response to the cache type representing a local cache, the local server corresponding to the target cache location is determined; the status information corresponding to the local server is determined as the server status information corresponding to the target cache location. In response to the cache type representing a distributed cache, the cache server corresponding to the target cache location is determined; the status information corresponding to the cache server is determined as the server status information corresponding to the target cache location.
5. The method according to claim 1, characterized in that, The step of determining the cache expiration time corresponding to the target cache location based on the cache execution information, the configuration information, and the server status information includes: Based on the server status information, determine the original expiration duration corresponding to the target cache location; Based on the cache execution information, the configuration information, and the cache server status information, at least one influencing factor is determined; Based on the at least one influencing factor, determine the duration adjustment factor; The cache expiration time corresponding to the target cache location is determined based on the original expiration time and the duration adjustment factor.
6. The method according to claim 1, characterized in that, After obtaining the server status information corresponding to the target cache location, the process further includes: Based on the cache execution information, the configuration information, and the server status information, determine the cache performance information corresponding to the target cache location; Based on the configuration information, determine the preset range corresponding to the cache performance information; In response to the cache performance information being outside the preset range, an alarm message corresponding to the cache performance information is generated.
7. A management device for cached data, characterized in that, include: The first acquisition module is used to acquire cache execution information corresponding to the target cache location; The second acquisition module is used to acquire configuration information corresponding to the target cache location; The third acquisition module is used to acquire server status information corresponding to the target cache location; The duration determination module is used to determine the cache expiration duration corresponding to the target cache location based on the cache execution information, the configuration information, and the server status information. The storage management module is used to manage the storage of cached data corresponding to the target cache location based on the cache expiration time.
8. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.
10. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.