Hybrid caching methods, apparatus, terminal devices, and storage media
By obtaining the request count table of the business application interface and generating a hybrid caching strategy using the sliding window algorithm, the problem of low caching efficiency in existing technologies that cannot balance high traffic and core business needs is solved, thus achieving priority protection for core business in high traffic scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2026-04-03
AI Technical Summary
Existing general-purpose caching solutions cannot meet the caching needs of core businesses in high-traffic scenarios, nor can they flexibly adjust the usage strategy of local caching, resulting in low caching processing efficiency.
By obtaining the request count table of the business application interface, and combining the sliding window algorithm and Bloom filter, a hybrid caching strategy is generated. The corresponding caching strategy is selected according to the traffic ratio, so as to realize flexible caching management for core business, important business and high-frequency business.
It improves the efficiency of cache processing, enabling priority to ensure the performance and stability of core businesses in high-traffic scenarios, and solves the problem of not being able to flexibly adjust local cache usage strategies.
Smart Images

Figure CN116756191B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of caching technology, and in particular to a hybrid caching processing method, apparatus, terminal device, and storage medium. Background Technology
[0002] Current general caching solutions cannot guarantee the performance of high-traffic or core business scenarios. High-traffic caching can only guarantee high-traffic business scenarios and cannot take into account the caching needs of core businesses. Conversely, when facing core business scenarios, it can only guarantee the caching needs of certain businesses and cannot guarantee the performance of business during sudden traffic surges.
[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this invention is to provide a hybrid caching processing method, apparatus, terminal device, and storage medium, aiming to solve the technical problem of the inability to flexibly adjust the usage strategy of local caching.
[0005] To achieve the above objectives, the present invention provides a hybrid caching processing method, the hybrid caching processing method comprising:
[0006] Retrieve the table of request counts for the business application's API;
[0007] Based on the request count table and the preset initial cache processing strategy, a hybrid cache processing strategy is generated;
[0008] The sliding window algorithm is used to obtain the percentage of total application interface traffic in the system's maximum traffic.
[0009] Based on the traffic percentage, select the corresponding hybrid caching strategy.
[0010] Optionally, the step of generating a hybrid caching strategy based on the request count table and a preset initial caching strategy includes:
[0011] The request count table is filtered according to a preset ratio to obtain high-frequency request business application interfaces.
[0012] Based on the preset initial cache processing strategy one, generate hybrid cache processing strategy one;
[0013] The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy two, a hybrid cache processing strategy two is generated.
[0014] The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy three, a hybrid cache processing strategy three is generated.
[0015] Optionally, the step of selecting the corresponding hybrid caching strategy based on the traffic proportion includes:
[0016] Based on the traffic ratio, a comparison is made using a preset first traffic limiting threshold and a second traffic limiting threshold to obtain a comparison result;
[0017] If the traffic percentage is less than the preset first rate limiting threshold, then the hybrid caching processing strategy three is selected;
[0018] If the traffic percentage is above the first rate limiting threshold and below the preset second rate limiting threshold, then the hybrid caching processing strategy two is selected.
[0019] If the traffic percentage is greater than the second rate limiting threshold, then the first hybrid caching strategy is selected.
[0020] Optionally, after the step of selecting the corresponding hybrid caching strategy based on the traffic ratio, the method further includes:
[0021] According to the hybrid caching strategy, queries are performed by inputting a preset filter through the business application interface to obtain query results;
[0022] Based on the query results, obtain the business application interface that uses the preset first-level cache.
[0023] Optionally, after the step of obtaining the business application interface using the preset first-level cache based on the query result, the method further includes:
[0024] The system monitors data from preset data sources using a pre-defined monitoring mechanism.
[0025] When the data in the data source changes, the changed data is synchronized to the preset three-level cache;
[0026] The changed data is synchronized to the preset second-level cache through the three-level cache;
[0027] According to the second-level cache, the changed data is synchronized to the preset first-level cache through a preset transmission mode.
[0028] Optionally, the step of synchronizing the changed data to a preset second-level cache through the three-level cache includes:
[0029] The preset monitoring mechanism monitors the preset second-level cache and the third-level cache.
[0030] If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, then the data in the third-level cache is pulled and synchronized to the second-level cache.
[0031] Optionally, the step of obtaining the business application interface request count table may include:
[0032] Based on the preset multi-level caching architecture, obtain the first-level cache, second-level cache, and third-level cache;
[0033] Delete the original application interface data in the first-level cache;
[0034] Based on the secondary cache, preset core business application interface data is pushed to the primary cache through a preset transmission mode;
[0035] Based on the core application interface data, analysis is performed using preset filters;
[0036] If the analysis result indicates that the core business application interface exists in the preset filter, then the core business application interface data is saved to the first-level cache to generate the first business scenario.
[0037] Based on the secondary cache, a second business scenario is generated through the core business application interface and the preset important business application interfaces;
[0038] Based on the three-level cache, a third business scenario is generated through the core business application programming interface, the important business application programming interface, and the preset ordinary business application programming interface.
[0039] Optionally, the step of generating a hybrid caching strategy based on the request count table and a preset initial caching strategy further includes:
[0040] Write the interfaces of the first business scenario, the second business scenario, and the third business scenario into the configuration to generate configuration file one, configuration file two, and configuration file three.
[0041] Based on configuration files 1, 2, and 3, preset filters are written to generate initial cache processing strategy 1, initial cache processing strategy 2, and initial cache processing strategy 3.
[0042] This invention also proposes a hybrid caching processing device, which includes:
[0043] The acquisition module is used to obtain a table of the number of requests to the business application interface.
[0044] The generation module is used to generate a hybrid caching strategy based on the request count table and the preset initial caching strategy.
[0045] The calculation module is used to obtain the percentage of total application interface traffic in the system's maximum traffic using a sliding window algorithm;
[0046] The selection module is used to select the corresponding hybrid caching processing strategy based on the traffic ratio.
[0047] This invention also proposes a terminal device, which includes a memory, a processor, and a hybrid cache processing program stored in the memory and executable on the processor. When the hybrid cache processing program is executed by the processor, it implements the steps of the hybrid cache processing method described above.
[0048] This invention also proposes a computer-readable storage medium storing a hybrid cache processing program, which, when executed by a processor, implements the steps of the hybrid cache processing method described above.
[0049] This invention proposes a hybrid caching processing method, apparatus, terminal device, and storage medium. The method involves obtaining a request count table for business application interfaces; generating a hybrid caching strategy based on the request count table and a preset initial caching strategy; obtaining the traffic percentage of the total application interface traffic within the system's maximum traffic using a sliding window algorithm; and selecting a corresponding hybrid caching processing strategy based on the traffic percentage. By combining the initial caching strategy with the generated hybrid caching strategy and using this strategy for business processing, the invention achieves a balance between core business and high-traffic functions, solves the problem of inflexibly adjusting local cache usage strategies, and improves caching processing efficiency. Attached Figure Description
[0050] Figure 1 This is a schematic diagram of the functional modules of the terminal device to which the hybrid caching processing device of the present invention belongs;
[0051] Figure 2 This is a flowchart illustrating an exemplary embodiment of the hybrid caching processing method of the present invention;
[0052] Figure 3 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention;
[0053] Figure 4 This is a schematic diagram illustrating the addition of filters to high-frequency access services in the hybrid caching processing method of the present invention;
[0054] Figure 5 This is a schematic diagram illustrating the generation of a hybrid caching strategy in the hybrid caching processing method of the present invention;
[0055] Figure 6 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention;
[0056] Figure 7 This is a schematic diagram illustrating the selection of a hybrid caching strategy in the hybrid caching processing method of the present invention;
[0057] Figure 8 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention;
[0058] Figure 9 This is a schematic diagram illustrating the hybrid caching processing method of the present invention, which involves obtaining the application interface that uses the first-level cache.
[0059] Figure 10 This is a schematic flowchart of another exemplary embodiment of the hybrid caching processing method of the present invention;
[0060] Figure 11 This is a schematic diagram illustrating the data synchronization involving three cache levels in the hybrid caching processing method of the present invention;
[0061] Figure 12 This is a schematic diagram illustrating the data synchronization process involved in the hybrid caching method of the present invention;
[0062] Figure 13 This is a schematic diagram illustrating the data synchronization between the second-level cache and the third-level cache in the hybrid caching processing method of the present invention;
[0063] Figure 14 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention;
[0064] Figure 15 This is a schematic diagram illustrating the multi-level caching architecture involved in the caching processing method of the present invention;
[0065] Figure 16 This is a schematic diagram of the transmission model involved in the caching processing method of the present invention;
[0066] Figure 17 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention;
[0067] Figure 18 This is a schematic diagram illustrating the generation of a cache processing strategy in the cache processing method of the present invention.
[0068] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0069] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0070] The main solution of this invention is as follows: The request frequency table is filtered according to a preset ratio to obtain high-frequency request application interfaces; a hybrid caching strategy one is generated according to a preset initial caching strategy one; the high-frequency request application interfaces are written into a preset filter and combined with a preset initial caching strategy two to generate a hybrid caching strategy two; the high-frequency request application interfaces are written into a preset filter and combined with a preset initial caching strategy three to generate a hybrid caching strategy three. Based on the traffic ratio, a comparison is made using a preset first rate limiting threshold and a preset second rate limiting threshold to obtain a comparison result; if the traffic ratio is less than the preset first rate limiting threshold, hybrid caching strategy three is selected; if the traffic ratio is above the first rate limiting threshold and less than the preset second rate limiting threshold, hybrid caching strategy two is selected; if the traffic ratio is greater than the second rate limiting threshold, hybrid caching strategy one is selected. According to the hybrid caching strategy, a query is performed through the application interface using a preset filter to obtain a query result; based on the query result, the application interface using the preset first-level cache is obtained. A preset monitoring mechanism monitors data in a preset data source. When data in the data source changes, the changed data is synchronized to a preset third-level cache. The changed data is then synchronized to a preset second-level cache via the third-level cache. Based on the second-level cache, the changed data is synchronized to a preset first-level cache using a preset transmission mode. The preset monitoring mechanism also monitors the preset second-level cache and the third-level cache. If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, data is retrieved from the third-level cache and synchronized to the second-level cache. Based on a preset multi-level caching architecture, first-level cache, second-level cache, and third-level cache are obtained; existing application interface data in the first-level cache is deleted; based on the second-level cache, preset core business application interface data is pushed to the first-level cache through a preset transmission mode; based on the core application interface data, it is analyzed through a preset filter; if the analysis result shows that the core business application interface exists in the preset filter, the core business application interface data is saved to the first-level cache to generate a first business scenario; based on the second-level cache, a second business scenario is generated through the core business application interface and preset important business application interfaces; based on the third-level cache, a third business scenario is generated through the core business application interface, important business application interfaces, and preset ordinary business application interfaces.The interfaces for the first, second, and third business scenarios are written into the configuration, generating configuration file one, configuration file two, and configuration file three. Based on configuration file one, configuration file two, and configuration file three, preset filters are written to generate initial cache processing strategy one, initial cache processing strategy two, and initial cache processing strategy three. This solves the problem of not being able to flexibly adjust the local cache usage strategy, achieves performance that balances core business and high-traffic functions, and improves cache processing efficiency.
[0071] Based on the solution of this invention, starting from the problem that the local cache usage strategy cannot be flexibly adjusted in real-world cache processing, a hybrid cache processing method is designed by combining a hybrid cache processing strategy. The effectiveness of the hybrid cache processing method of this invention is verified in actual cache processing. Finally, the efficiency of cache processing using the method of this invention is significantly improved.
[0072] Technical terms involved in the embodiments of this invention:
[0073] Caffeine: Caffeine is a high-performance local caching framework based on Java 8. It adopts the W-TinyLFU algorithm (combining the advantages of LUR and LFU) to achieve high cache hit rate and low memory consumption. Its cache performance is close to the theoretical optimum, making it an enhanced version of Guava Cache. Caffeine achieves optimal performance in concurrent read, concurrent write, and concurrent read / write scenarios.
[0074] Redis: Redis is a high-performance key-value database that is completely open-source and free. It's a NoSQL database designed to address issues such as high concurrency, high scalability, and large data storage. While it's a non-relational database, it cannot replace relational databases; it can only serve as an extension in specific environments. Redis is a key-value storage database structure server that supports data structures including strings, lists, hash tables, sets, and sorted sets (Zsets). To ensure efficient read operations, Redis stores data objects in memory. It supports periodically writing updated data to disk files and provides intersection and union operations, as well as various sorting methods.
[0075] ES: ElasticSearch is a search server based on Lucene. As a highly scalable open-source full-text search and analysis engine, ElasticSearch can be used to quickly store, search, and analyze big data. ElasticSearch is developed based on Java and released as open source under the Apache License. It is a popular enterprise-level search engine.
[0076] MongoDB is an open-source database system written in C++ based on distributed file storage. Under high load, adding more nodes can ensure server performance. MongoDB aims to provide scalable, high-performance data storage solutions for web applications. MongoDB stores data as documents, and the data structure consists of key-value pairs. MongoDB documents are similar to JSON objects, and field values can contain other documents, arrays, and arrays of documents.
[0077] Bloom Filter: A Bloom filter is a space-efficient deduplication data structure used to quickly determine whether an element is in a set. It is commonly used for deduplication and filtering spam data. A Bloom filter consists of a long array of binary bits and a set of hash functions. To determine if an element is in a set, the element is first hashed using the hash functions, and then the corresponding position in the binary bit array is checked for a 1 based on the hash result. Bloom filters have a false positive rate; that is, if an element is not in the set, the Bloom filter may consider it to be in the set. Therefore, a Bloom filter is not a 100% accurate deduplication data structure. However, it is superior to other data structures in terms of both space and time efficiency, and thus it is widely used in many practical applications.
[0078] Sliding window algorithm: The sliding window algorithm is a commonly used algorithm to solve substring or subsequence problems of strings or arrays. Its basic idea is to maintain a window, the size of which can be adjusted according to the requirements of the problem, and then perform operations within the window until a solution that meets the requirements is found, or the window slides to the last position. In the sliding window algorithm, each time the window is moved, only the left and right boundaries of the window need to be changed, which can avoid repeated calculations and enumerations and improve the efficiency of the algorithm. Common applications include problems such as minimum subarray, maximum subarray, and longest substring without repeating characters.
[0079] Pub / sub pattern: Pub / sub pattern is a type of message communication that is similar to message queues to some extent. Pub / sub pattern decouples two interdependent modules through a publish-subscribe pattern. The message sender sends messages to a specific topic, rather than to a specific subscriber. Similarly, the subscriber subscribes to topics of interest and receives messages from those topics. By decoupling the two modules from each other through an intermediary topic, the two tightly coupled modules do not need to care whether the other end has subscribed or whether the subscription relationship has been modified.
[0080] Watchdog: A watchdog is a hardware or software mechanism used to monitor the operating status of a system so that it can restart, recover, or trigger an alarm when a system failure or error occurs. It typically consists of a timer and a counter. The timer sends a signal to the counter periodically. If the counter fails to respond within a specified time, it indicates that a system failure or error has occurred, and the watchdog will trigger operations such as restarting or alarming to ensure the stability and reliability of the system. Watchdogs can be applied to various embedded systems, servers, network devices, and other scenarios, and are a commonly used system protection mechanism.
[0081] The embodiments of the present invention take into account that when related technologies perform caching, they cannot prioritize the performance and stability of core businesses in high-traffic scenarios. When facing high-traffic scenarios, caching can only guarantee high-traffic scenarios and cannot take into account the caching needs of core businesses.
[0082] Therefore, this invention addresses the problem of inflexible local cache usage strategies in real-world caching processes. By combining a hybrid caching strategy, a hybrid caching method is designed, and its effectiveness is verified in actual caching processes. Finally, the caching efficiency is significantly improved by the method of this invention.
[0083] Specifically, refer to Figure 1 , Figure 1 This is a schematic diagram of the functional modules of the terminal device to which the hybrid caching processing device of the present invention belongs. The hybrid caching processing device can be a device capable of caching processing, independent of the terminal device, and can be implemented on the terminal device in hardware or software form. The terminal device can be a smart mobile device with data processing capabilities, such as a mobile phone or tablet computer, or a fixed terminal device or server with data processing capabilities.
[0084] In this embodiment, the terminal device to which the security protection device belongs includes at least an output module 110, a processor 120, a memory 130, and a communication module 140.
[0085] The memory 130 stores the operating system and a hybrid caching processing program. The hybrid caching processing device can obtain a table of request counts for business application interfaces; generate a hybrid caching strategy based on the request count table and a preset initial caching strategy; obtain the traffic percentage of the total application interface in the system's maximum traffic using a sliding window algorithm; and select the corresponding hybrid caching processing strategy based on the traffic percentage. The hybrid caching processing device processes the data, and the resulting caching information is stored in the memory 130. The output module 110 can be a display screen, etc. The communication module 140 can include a WIFI module, a mobile communication module, and a Bluetooth module, etc., and communicates with external devices or servers through the communication module 140.
[0086] When the hybrid cache handler in memory 130 is executed by the processor, it performs the following steps:
[0087] Retrieve the table of request counts for the business application's API;
[0088] Based on the request count table and the preset initial caching strategy, a hybrid caching strategy is generated;
[0089] The sliding window algorithm is used to obtain the percentage of total application interface traffic in the system's maximum traffic.
[0090] Based on the traffic percentage, select the corresponding hybrid caching strategy.
[0091] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0092] The request count table is filtered according to a preset ratio to obtain high-frequency request business application interfaces.
[0093] Based on the preset initial caching strategy one, generate hybrid caching strategy one;
[0094] The high-frequency request business application interface is written into a preset filter, and combined with the preset initial caching strategy two, a hybrid caching strategy two is generated;
[0095] The high-frequency request business application interface is written into a preset filter, and combined with the preset initial caching strategy three, a hybrid caching strategy three is generated.
[0096] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0097] Based on the traffic ratio, a comparison is made using a preset first traffic limiting threshold and a second traffic limiting threshold to obtain a comparison result;
[0098] If the traffic percentage is less than the preset first rate limiting threshold, then the hybrid caching processing strategy three is selected;
[0099] If the traffic percentage is above the first rate limiting threshold and below the preset second rate limiting threshold, then the hybrid caching processing strategy two is selected.
[0100] If the traffic percentage is greater than the second rate limiting threshold, then the first hybrid caching strategy is selected.
[0101] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0102] According to the hybrid caching strategy, queries are performed by inputting a preset filter through the business application interface to obtain query results;
[0103] Based on the query results, obtain the business application interface that uses the preset first-level cache.
[0104] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0105] The system monitors data from preset data sources using a pre-defined monitoring mechanism.
[0106] When the data in the data source changes, the changed data is synchronized to the preset three-level cache;
[0107] The changed data is synchronized to the preset second-level cache through the three-level cache;
[0108] According to the second-level cache, the changed data is synchronized to the preset first-level cache through a preset transmission mode.
[0109] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0110] The preset monitoring mechanism monitors the preset second-level cache and the third-level cache.
[0111] If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, then the data in the third-level cache is pulled and synchronized to the second-level cache.
[0112] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0113] Based on the preset multi-level caching architecture, obtain the first-level cache, second-level cache, and third-level cache;
[0114] Delete the original application interface data in the first-level cache;
[0115] Based on the secondary cache, preset core business application interface data is pushed to the primary cache through a preset transmission mode;
[0116] Based on the core application interface data, analysis is performed using preset filters;
[0117] If the analysis result indicates that the core business application interface exists in the preset filter, then the core business application interface data is saved to the first-level cache to generate the first business scenario.
[0118] Based on the secondary cache, a second business scenario is generated through the core business application interface and the preset important business application interfaces;
[0119] Based on the three-level cache, a third business scenario is generated through the core business application programming interface, the important business application programming interface, and the preset ordinary business application programming interface.
[0120] Furthermore, when the hybrid cache handler in memory 130 is executed by the processor, it also performs the following steps:
[0121] Write the interfaces of the first business scenario, the second business scenario, and the third business scenario into the configuration to generate configuration file one, configuration file two, and configuration file three.
[0122] Based on configuration files 1, 2, and 3, preset filters are written to generate initial cache processing strategy 1, initial cache processing strategy 2, and initial cache processing strategy 3.
[0123] This embodiment, through the above scheme, specifically obtains a table of request counts for the business application interface; generates a hybrid caching strategy based on the request count table and a preset initial caching strategy; obtains the traffic percentage of the total application interface in the system's maximum traffic using a sliding window algorithm; and selects the corresponding hybrid caching processing strategy based on the traffic percentage.
[0124] A hybrid caching strategy can solve the problem of inflexible local cache usage. Based on this invention, addressing the issue of inflexible local cache usage in real-world caching, a hybrid caching method is designed and its effectiveness is verified in practical caching scenarios. Finally, the efficiency of caching using this method is significantly improved.
[0125] Based on, but not limited to, the terminal device architecture described above, embodiments of the method of the present invention are proposed.
[0126] Reference Figure 2 , Figure 2 This is a flowchart illustrating an exemplary embodiment of the hybrid caching processing method of the present invention. The hybrid caching processing method includes:
[0127] Step S08: Obtain the business application interface request count table;
[0128] The execution subject of the method in this embodiment can be a hybrid cache processing device, a hybrid cache processing terminal device, or a server. This embodiment takes a hybrid cache processing device as an example, which can be integrated into a terminal device with data processing function.
[0129] To obtain commonly used business functions in the system, the following steps are taken:
[0130] First, using a sliding window algorithm, the number of times the application interfaces currently providing business services are accessed within a certain period of time is counted. Here, the application interfaces mentioned refer to the data transmitted in the system by the applications used during business operations. In this embodiment, obtaining the access count of the applications can help determine which services are frequently used applications.
[0131] Finally, the access counts of the application interfaces are sorted to obtain a table of application interface request counts.
[0132] Step S11: Generate a hybrid caching strategy based on the request count table and the preset initial caching strategy;
[0133] To obtain a hybrid caching strategy for caching, the following steps are taken:
[0134] First, the allowed application interface admission ratio for the first-level cache is determined based on local resources and quantity. The reason for determining the local resources and quantity is that the system cache size and application bandwidth requirements will vary depending on each device and project.
[0135] Finally, the application interface and initial caching strategy in the admission ratio are selected and added to the Bloom filter to generate the corresponding hybrid caching strategy.
[0136] Step S12: Obtain the percentage of total application interface traffic in the system's maximum traffic using the sliding window algorithm;
[0137] After obtaining the hybrid caching strategy, the following steps are taken to determine the traffic scenario:
[0138] First, the sliding window algorithm is used to count the traffic used by the application interface currently processing business. The sliding window algorithm is a commonly used algorithm to solve some substring or subsequence problems of strings or arrays. Common applications include minimum subarray, maximum subarray, and longest substring without repeating characters.
[0139] Then, the maximum concurrent traffic capacity is determined through stress testing;
[0140] Finally, the application's usage traffic value is compared with the maximum traffic value to obtain the percentage of the application interface traffic currently processing business within the system's maximum traffic.
[0141] Step S13: Select the corresponding hybrid caching processing strategy based on the traffic ratio.
[0142] After obtaining the traffic percentage, the following steps are taken to select the appropriate hybrid caching strategy:
[0143] First, the traffic percentage is compared with the rate limiting threshold to obtain the comparison results. The rate limiting threshold is set according to the user and can be adjusted according to business needs or the popularity of the current business.
[0144] Then, based on the obtained comparison results, the corresponding caching strategy is selected to process the current business. In high-traffic scenarios, priority is given to ensuring the processing of core businesses; in moderate-traffic scenarios, priority is given to ensuring the processing of core businesses, important businesses, and high-frequency businesses; and in low-traffic scenarios, priority is given to ensuring the processing of high-frequency businesses.
[0145] This embodiment, through the above-described scheme, specifically obtains a table of request counts for the business application interface; generates a hybrid caching strategy based on the request count table and a preset initial caching strategy; obtains the traffic percentage of the total application interface within the system's maximum traffic using a sliding window algorithm; and selects the corresponding hybrid caching processing strategy based on the traffic percentage. This achieves a balance between core business and high-traffic functions, solves the problem of inflexibly adjusting local caching usage strategies, and improves caching processing efficiency.
[0146] Reference Figure 3 , Figure 3 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention.
[0147] Based on the above Figure 2 In the embodiment shown, step S11, which involves generating a hybrid caching strategy based on the request count table and a preset initial caching strategy, includes:
[0148] Step S111: Filter the request count table according to a preset ratio to obtain high-frequency request business application interfaces.
[0149] Step S112: Generate hybrid caching strategy one according to the preset initial caching strategy one;
[0150] Step S113: Write the high-frequency request business application interface into a preset filter, and combine it with the preset initial caching strategy two to generate a hybrid caching strategy two.
[0151] Step S114: Write the high-frequency request business application interface into a preset filter, and combine it with the preset initial caching strategy three to generate a hybrid caching strategy three.
[0152] Specifically, to obtain the hybrid caching strategy, the following steps are taken:
[0153] First, the allowed application interface admission ratio for the first-level cache is determined based on local resources and data volume. This ratio can be adjusted by the user and the actual cache size of the device.
[0154] Then, while maintaining the original initial caching strategy one, a hybrid caching strategy is generated. The initial caching strategy one refers to ensuring the use of core business. In high-traffic scenarios, the use of core business is prioritized, while high-frequency access business, important business, and ordinary business are processed using caching with lower caching levels.
[0155] Then, the frequently accessed business application interfaces are written into the Bloom filter as the judgment condition for using the first-level cache. On this basis, the initial cache strategy two is added to generate the hybrid cache strategy two. The initial cache strategy two refers to ensuring the use of core business and important business, while the addition of high-frequency access business makes the hybrid cache strategy ensure the use of core business, important business and high-frequency access business when facing moderate traffic scenarios.
[0156] Finally, the frequently accessed business application interfaces are written into the Bloom filter. Then, the initial caching strategy three is added to generate the hybrid caching strategy three. The initial caching strategy three means that in the scenario where the current traffic usage is low, all businesses can use the first-level cache for business processing. After adding the frequently accessed business, the hybrid caching strategy three means that in the scenario where the current traffic usage is low, the high-frequency access business is given priority.
[0157] More specifically, refer to Figure 4 , Figure 4This diagram illustrates the addition of filters to high-frequency access services in the hybrid caching method of this invention. First, the number of requests to the current API (i.e., application programming interface) is counted. Then, the application programming interfaces are sorted, and a certain proportion of them are added to the Bloom filter. Finally, [the process is described in the original text]. Figure 5 , Figure 5 This is a schematic diagram illustrating the generation of a hybrid caching strategy in the hybrid caching processing method of the present invention. First, an initial caching strategy one is used to generate a hybrid caching strategy one. Then, frequently accessed application interfaces are combined with an initial caching strategy two and added to a Bloom filter to generate a hybrid caching strategy two. Finally, frequently accessed application interfaces are combined with an initial caching strategy three and added to a Bloom filter to generate a hybrid caching strategy three.
[0158] This embodiment, through the above-described scheme, specifically filters the request frequency table according to a preset ratio to obtain high-frequency request application interfaces; generates a hybrid caching strategy one based on a preset initial caching strategy one; writes the high-frequency request application interfaces into a preset filter and combines it with a preset initial caching strategy two to generate a hybrid caching strategy two; writes the high-frequency request application interfaces into a preset filter and combines it with a preset initial caching strategy three to generate a hybrid caching strategy three. This achieves a balance between the performance of core business and high-traffic functions, solves the problem of not being able to flexibly adjust the local caching usage strategy, and improves the efficiency of caching processing.
[0159] Reference Figure 6 , Figure 6 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention.
[0160] Based on the above Figure 2 In the embodiment shown, step S13, which involves selecting a corresponding hybrid caching strategy based on the traffic ratio, includes:
[0161] Step S131: Based on the traffic ratio, compare the results using a preset first traffic limiting threshold and a second traffic limiting threshold to obtain a comparison result;
[0162] Step S132: If the traffic ratio is less than the preset first rate limiting threshold, then the hybrid caching processing strategy three is selected.
[0163] Step S133: If the traffic ratio is above the first rate limiting threshold and less than the preset second rate limiting threshold, then the hybrid caching processing strategy two is selected.
[0164] Step S134: If the traffic ratio is greater than the second rate limiting threshold, then the first hybrid caching strategy is selected.
[0165] Specifically, to select a hybrid caching strategy, the following steps are taken:
[0166] First, based on the pre-obtained traffic percentage, a comparison is made between the first and second rate limiting thresholds to obtain a comparison result. The size of the traffic percentage is determined by the currently running application and the hybrid caching strategy is selected dynamically based on changes in the actual traffic percentage. The first and second rate limiting thresholds can also be adjusted by the user. In this embodiment, the first rate limiting threshold is less than the second rate limiting threshold; in other embodiments, the opposite may be true.
[0167] Then, if the comparison result shows that the traffic percentage is less than the first rate limiting threshold, the current traffic is considered to be a low traffic scenario, and the hybrid caching processing strategy three is used for caching processing, that is, the first-level cache is used to prioritize the processing of high-frequency access services.
[0168] Then, if the comparison result shows that the traffic percentage is greater than or equal to the first rate limiting threshold and less than the second rate limiting threshold, then the current traffic is considered to be a moderate traffic scenario, and the hybrid caching processing strategy two is used for caching processing, that is, the first-level cache ensures the processing of core business, important business and high-frequency access business.
[0169] Finally, if the comparison result shows that the traffic percentage is greater than or equal to the second rate limiting threshold, then the current traffic is considered to be a high-traffic scenario, and the hybrid caching processing strategy one is used for caching processing, that is, the first-level cache only guarantees the processing of core business.
[0170] More specifically, such as Figure 7 As shown, Figure 7 This is a schematic diagram illustrating the selection of a hybrid caching strategy in the hybrid caching processing method of the present invention. First, the current system's TPS (transactions per second) is calculated using a sliding window, which can also be understood as traffic. Then, the proportion of traffic in the maximum system traffic is calculated using the traffic. If the traffic threshold A (i.e., the aforementioned traffic threshold 1) is not reached, hybrid strategy three is executed. If the traffic threshold A is reached, the traffic proportion is compared with the traffic threshold B (i.e., the aforementioned traffic threshold 2). If the traffic threshold B is not reached, hybrid strategy two is executed. If the traffic threshold B is reached, hybrid strategy one is executed.
[0171] This embodiment, through the above-described scheme, specifically compares the traffic percentage with preset first and second rate-limiting thresholds to obtain a comparison result. If the traffic percentage is less than the preset first rate-limiting threshold, the hybrid caching processing strategy three is selected; if the traffic percentage is above the first rate-limiting threshold but less than the preset second rate-limiting threshold, the hybrid caching processing strategy two is selected; if the traffic percentage is greater than the second rate-limiting threshold, the hybrid caching processing strategy one is selected. This achieves a balance between the performance of core business and high-access business, solves the problem of not being able to flexibly adjust the local cache usage strategy, and improves the efficiency of cache processing.
[0172] Reference Figure 8 , Figure 8 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention.
[0173] Based on the above Figure 2 In the embodiment shown, after step S13, which involves selecting a corresponding hybrid caching processing strategy based on the traffic ratio, the hybrid caching processing method further includes:
[0174] Step S14: According to the hybrid caching processing strategy, query the results by inputting a preset filter through the business application interface.
[0175] Step S15: Based on the query results, obtain the business application interface that uses the preset first-level cache.
[0176] Specifically, to obtain the business currently using the first-level cache, the following steps are taken:
[0177] First, based on the selected hybrid caching strategy, the query application interface is determined and the query results are obtained. The query application interface uses a Bloom filter, which is a space-efficient deduplication data structure. Its function is to quickly determine whether an element is in a set. It is usually used for deduplication, filtering of garbage data, and other scenarios.
[0178] Finally, based on the results of the Bloom filter, the application interface currently using the first-level cache can be obtained.
[0179] More specifically, such as Figure 9 As shown, Figure 9 This is a schematic diagram illustrating the hybrid caching processing method of the present invention, which involves obtaining the application interface that uses the first-level cache.
[0180] First, the application interface is entered into a Bloom filter for querying. If it does not exist, it is entered into Redis (i.e., the second-level cache) for querying. If it exists, it is entered into Caddeine (i.e., the first-level cache) for querying.
[0181] Then, if the query result in Caffeine exists, it is returned, that is, the output result is the application using the first-level cache; if the query result does not exist, it is input to Redis for querying.
[0182] Then, if the query result in Redis does not exist, it continues to query ES (i.e., the third-level cache). If it exists, it is pushed to the first-level cache and the Bloom filter is used to query again.
[0183] Then, if the query result in ES does not exist, it is returned, that is, the output result is that the application interface does not use the first-level cache. If the query result exists, the data is stored in Redis and pushed to the first-level cache, and then the Bloom filter is used to query again.
[0184] Finally, Caffenine is verified again using the Bloom filter. If the data transmission from Redis to Caffenine is normal, the verification result is that the application interface exists. The application interface is then stored in Caffenine and returned, with the output result indicating that the application uses the first-level cache. If the data transmission is abnormal and the Bloom filter cannot verify it, the result is returned, with the output result indicating that the application does not use the first-level cache.
[0185] This embodiment, through the above-described scheme, specifically by querying the business application interface using a preset filter according to the hybrid caching processing strategy, obtains the query results; based on the query results, it retrieves the business application interface that uses the preset first-level cache. This achieves a balance between the performance of core business and high-access business, solves the problem of not being able to flexibly adjust the local cache usage strategy, and improves the efficiency of cache processing.
[0186] Reference Figure 10 , Figure 10 This is a schematic flowchart of another exemplary embodiment of the hybrid caching processing method of the present invention.
[0187] Based on the above Figure 8 In the illustrated embodiment, after step S15, which involves obtaining the business application interface using the preset first-level cache based on the query result, the hybrid caching processing method further includes:
[0188] Step S16: Monitor data in a preset data source through a preset monitoring mechanism;
[0189] Step S17: When the data in the data source changes, the changed data is synchronized to the preset three-level cache;
[0190] Step S18: Synchronize the changed data to the preset second-level cache through the three-level cache;
[0191] Step S19: Based on the secondary cache, synchronize the changed data to the preset primary cache through a preset transmission mode.
[0192] Specifically, to achieve synchronization of the three-level cache data, the following steps are taken:
[0193] First, monitor the data in the data source to obtain information about data changes;
[0194] Then, if a data change notification is received, the changed data will be synchronized to the level 3 cache.
[0195] Then, the second-level cache obtains the changed data in the third-level cache by listening and pulls it into the second-level cache;
[0196] Finally, the second-level cache synchronizes updated data to the first-level cache using a pub / sub pattern.
[0197] More specifically, such as Figure 11 As shown, Figure 11 This is a schematic diagram illustrating the data synchronization involving three cache levels in the hybrid caching processing method of the present invention.
[0198] First, in this embodiment, there are two data synchronization schemes: full synchronization, which means that the data is fully synchronized to the third-level cache at a fixed time every day, and then synchronized from the third-level cache to the second-level cache; and incremental update, which means that changes to the data in the data source MongoDB are monitored through a monitoring strategy, and if there are changes, the second-level cache and the third-level cache are synchronized accordingly.
[0199] Alternatively, a combination of the two methods can be used, namely... Figure 11 As shown, the data from the data source is synchronized to the third-level cache every day at midnight, and then synchronized from the third-level cache to the second-level cache.
[0200] Finally, monitor for data changes in the data source. If there are no changes, continue monitoring. If data changes occur, synchronize the data in the data source to the third-level cache, and then synchronize it from the third-level cache to the second-level cache. The time for full synchronization can be changed by the user.
[0201] This embodiment, through the above-described scheme, specifically monitors data in a preset data source using a preset monitoring mechanism. When the data in the data source changes, the changed data is synchronized to a preset three-level cache. Through the three-level cache, the changed data is synchronized to a preset two-level cache. Based on the two-level cache, the changed data is synchronized to a preset first-level cache using a preset transmission mode. This achieves multi-level cache data synchronization, solves the problem of data discrepancies during cache processing, and improves cache processing efficiency.
[0202] Reference Figure 12 , Figure 12 This is a schematic diagram illustrating the data synchronization process involved in the hybrid caching method of the present invention.
[0203] Based on the above Figure 10 In the embodiment shown, step S18, which involves synchronizing the changed data to a preset second-level cache through the three-level cache, includes:
[0204] Step S181: Monitor the preset second-level cache and the third-level cache through a preset monitoring mechanism;
[0205] Step S182: If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, then pull the data from the third-level cache and synchronize it to the second-level cache.
[0206] Specifically, to synchronize data from the L3 cache to the L2 cache, the following steps are taken:
[0207] First, the watchdog task monitors whether the number of keys in the L2 and L3 caches are the same. A watchdog is a hardware or software mechanism used to monitor the operating status of a system so that it can restart, recover, or alarm when a system failure or error occurs. It usually consists of a timer and a counter. The timer sends a signal to the counter periodically. If the counter fails to respond within a specified time, it indicates that a system failure or error has occurred, and the watchdog will trigger a restart or alarm to ensure the stability and reliability of the system. Watchdogs can be applied to various embedded systems, servers, network devices, and other scenarios, and are a commonly used system protection mechanism.
[0208] Finally, when the number of keys in the L3 cache and the L2 cache are different, the L2 cache issues a data synchronization request and actively pulls data from Elasticsearch to synchronize it into the L2 cache.
[0209] More specifically, such as Figure 13 As shown, Figure 13This is a schematic diagram illustrating the data synchronization between the second-level cache and the third-level cache in the hybrid caching processing method of the present invention. A watchdog task monitors the data in the second-level cache and the third-level cache. If the data has not changed, the monitoring continues; if the data has changed, data synchronization is performed.
[0210] This embodiment, through the above-described scheme, specifically uses a preset monitoring mechanism to monitor the preset second-level cache and the third-level cache. If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, data is retrieved from the third-level cache and synchronized to the second-level cache. This achieves multi-level cache data synchronization, solves the problem of data discrepancies during cache processing, and improves cache processing efficiency.
[0211] Reference Figure 14 , Figure 14 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention.
[0212] Based on the above Figure 2 In the embodiment shown, before step S08, which involves obtaining the business application interface request count table, the hybrid caching method further includes:
[0213] Step S01: Obtain the first-level cache, second-level cache, and third-level cache according to the preset multi-level cache architecture;
[0214] Step S02: Delete the original application interface data in the first-level cache;
[0215] Step S03: Based on the secondary cache, push the preset core business application interface data to the primary cache through a preset transmission mode;
[0216] Step S04: Analyze the core application interface data using a preset filter;
[0217] Step S05: If the analysis result indicates that the core business application interface exists in the preset filter, then the core business application interface data is saved to the first-level cache to generate the first business scenario.
[0218] Step S06: Based on the secondary cache, generate a second business scenario through the core business application interface and the preset important business application interface;
[0219] Step S07: Based on the three-level cache, a third business scenario is generated through the core business application interface, the important business application interface, and the preset ordinary business application interface.
[0220] Specifically, to ensure that the cache has corresponding processing scenarios, the following steps are taken:
[0221] First, based on the system's multi-level caching architecture, the first-level cache, second-level cache, and third-level cache are obtained, such as... Figure 15 As shown, Figure 15 This is a schematic diagram of the multi-level caching architecture involved in the caching processing method of the present invention. MongoDB is used as the database system. Under high load, adding more nodes can ensure server performance. The third-level cache refers to Elasticsearch, which can quickly store, search and analyze big data. The second-level cache refers to Redis, a NoSQL database that can solve a series of problems such as high concurrency, high scalability and big data storage. The first-level cache can also be called the local cache. In this embodiment, it refers to Caffeine, which achieves high cache hit rate and low memory consumption. Its cache performance is close to the theoretical optimal, and its performance is optimal in the three scenarios of concurrent read, concurrent write and concurrent read and write.
[0222] Then, the existing application interface data in the first-level cache is deleted. Based on the business adjustments, some business data is deleted from the first-level cache to facilitate the addition of application interfaces for core businesses in the future.
[0223] Then, through the second-level cache, the core business application interface data to be added to the first-level cache is pushed to the first-level cache, using a pub / sub pattern, such as... Figure 16 As shown, Figure 16 This is a schematic diagram of the transmission model involved in the caching processing method of the present invention. The pub / sub mode is a type of message communication, which is similar to message queues to some extent. The pub / sub mode decouples two interdependent modules through the subscription and publish pattern. The message sender sends messages to a specific topic, rather than to a specific subscriber. Similarly, the subscriber receives messages from topics of interest by subscribing to topics of interest.
[0224] Then, the application interface data received from the first-level cache is analyzed by a Bloom filter. If the result shows that the application interface exists in the Bloom filter, the core business application interface data is saved to the first-level cache and an expiration time is set, thus generating the first business scenario. When the application interface does not exist in the Bloom filter, the data change is ignored.
[0225] Then, the core business application interfaces and important business application interfaces are saved to the second-level cache to generate the second business scenario;
[0226] Finally, the core business application programming interfaces (APIs), important business APIs, and ordinary business APIs are all saved to a three-level cache to generate a third business scenario.
[0227] This embodiment, through the above-described scheme, specifically obtains a first-level cache, a second-level cache, and a third-level cache according to a preset multi-level caching architecture; deletes the original application interface data in the first-level cache; pushes preset core business application interface data to the first-level cache according to the second-level cache using a preset transmission mode; analyzes the core application interface data through a preset filter; if the analysis result shows that the core business application interface exists in the preset filter, the core business application interface data is saved to the first-level cache, generating a first business scenario; based on the second-level cache, a second business scenario is generated through the core business application interface and preset important business application interfaces; and based on the third-level cache, a third business scenario is generated through the core business application interface, important business application interfaces, and preset ordinary business application interfaces. This achieves the acquisition of multi-level caches, facilitates the generation of subsequent hybrid caching strategies, solves the problem of inflexible adjustment of local cache usage strategies, and improves cache processing efficiency.
[0228] Reference Figure 17 , Figure 17 This is a flowchart illustrating another exemplary embodiment of the hybrid caching processing method of the present invention.
[0229] Based on the above Figure 2 In the embodiment shown, before step S11, which generates a hybrid caching strategy based on the request count table and a preset initial caching strategy, the hybrid caching method further includes:
[0230] Step S09: Write the interfaces of the first business scenario, the second business scenario, and the third business scenario into the configuration to generate configuration file one, configuration file two, and configuration file three.
[0231] Step S10: Based on the configuration file 1, configuration file 2 and configuration file 3, write the preset filters respectively to generate the initial cache processing strategy 1, initial cache processing strategy 2 and initial cache processing strategy 3.
[0232] Specifically, to obtain the initial cache processing strategy, the following steps are taken:
[0233] First, the interfaces for the first, second, and third business scenarios are written into configuration files, generating Configuration File 1, Configuration File 2, and Configuration File 3. The first business scenario stores core business application interfaces, the second business scenario stores core business application interfaces and important business application interfaces, and the third business scenario stores core business application interfaces, important business application interfaces, and ordinary business application interfaces. By writing these configurations, the business scenarios aggregate the application interfaces, reducing resource waste.
[0234] Finally, configuration files 1, 2, and 3 are written into the Bloom filter to generate initial cache processing strategies 1, 2, and 3.
[0235] More specifically, such as Figure 18 As shown, Figure 18 This is a schematic diagram of the cache processing method of the present invention involving the generation of cache processing strategies. After the business scenario is classified, the first-level scenario is added to the Bloom filter by configuration to generate the initial cache processing strategy one. The second-level scenario is added to the Bloom filter by configuration to generate the initial cache processing strategy two. The third-level scenario is added to the Bloom filter by configuration to generate the initial cache processing strategy three.
[0236] This embodiment, through the above-described scheme, specifically generates configuration files one, two, and three by writing the interfaces of the first, second, and third business scenarios into the configuration. Based on configuration files one, two, and three, preset filters are written to generate initial cache processing strategy one, initial cache processing strategy two, and initial cache processing strategy three, respectively. This achieves the acquisition of the initial cache processing strategy, facilitating the generation of subsequent hybrid cache strategies, solving the problem of inflexible adjustment of local cache usage strategies, and improving cache processing efficiency.
[0237] Furthermore, embodiments of the present invention also propose a hybrid caching processing device, the hybrid caching processing device comprising:
[0238] The acquisition module is used to obtain a table of the number of requests to the business application interface.
[0239] The generation module is used to generate a hybrid caching strategy based on the request count table and the preset initial caching strategy.
[0240] The calculation module is used to obtain the percentage of total application interface traffic in the system's maximum traffic using a sliding window algorithm;
[0241] The selection module is used to select the corresponding hybrid caching processing strategy based on the traffic ratio.
[0242] Furthermore, this embodiment of the invention also proposes a terminal device, which includes a memory, a processor, and a hybrid cache processing program stored in the memory and executable on the processor. When the hybrid cache processing program is executed by the processor, it implements the steps of the hybrid cache processing method described above.
[0243] Since this hybrid cache processing program employs all the technical solutions of all the foregoing embodiments when executed by the processor, it has at least all the beneficial effects brought about by all the technical solutions of all the foregoing embodiments, which will not be elaborated here.
[0244] Furthermore, embodiments of the present invention also propose a computer-readable storage medium storing a hybrid cache processing program, which, when executed by a processor, implements the steps of the hybrid cache processing method described above.
[0245] Since this hybrid cache processing program employs all the technical solutions of all the foregoing embodiments when executed by the processor, it has at least all the beneficial effects brought about by all the technical solutions of all the foregoing embodiments, which will not be elaborated here.
[0246] Compared to existing technologies, the hybrid caching processing method, apparatus, terminal device, and storage medium proposed in this invention obtain a request count table for business application interfaces; generate a hybrid caching processing strategy based on the request count table and a preset initial caching processing strategy; obtain the traffic percentage of the total application interfaces in the system's maximum traffic using a sliding window algorithm; and select the corresponding hybrid caching processing strategy based on the traffic percentage. This solves the problem of inflexibly adjusting the local cache usage strategy, achieving performance that balances core business and high-traffic functions. Based on this invention, starting from the problem of inflexible adjustment of local cache usage strategies in real-world caching processing, a hybrid caching processing method is designed in conjunction with a hybrid caching processing strategy. The effectiveness of the hybrid caching processing method of this invention is verified in actual caching processing, and the caching efficiency is significantly improved by the method of this invention.
[0247] Compared with existing technologies, the solutions of the embodiments of the present invention have the following advantages:
[0248] 1. Dynamically update the access control function based on traffic volume; high-traffic functions will prioritize using the cache.
[0249] 2. The business scenarios for dynamically scaling local caching: low traffic allows for widespread use, while high traffic restricts its use to core business scenarios.
[0250] 3. Balance the performance requirements of high traffic and core business operations, and improve cache hit rate.
[0251] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0252] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0253] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, controlled terminal, or network device, etc.) to execute the methods of each embodiment of the present invention.
[0254] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A hybrid caching processing method, characterized in that, The hybrid caching processing method includes the following steps: Retrieve the table of request counts for the business application's API; Based on the request count table and the preset initial cache processing strategy, a hybrid cache processing strategy is generated; The step of generating a hybrid caching strategy based on the request count table and a preset initial caching strategy includes: The request count table is filtered according to a preset ratio to obtain high-frequency request business application interfaces; Based on the preset initial cache processing strategy one, generate hybrid cache processing strategy one; The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy two, a hybrid cache processing strategy two is generated. The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy three, a hybrid cache processing strategy three is generated. The sliding window algorithm is used to obtain the percentage of total application interface traffic in the system's maximum traffic. Based on the traffic percentage, select the corresponding hybrid caching strategy.
2. The hybrid caching processing method according to claim 1, characterized in that, The step of selecting the corresponding hybrid caching strategy based on the traffic ratio includes: The traffic percentage is compared using a preset first and second traffic limiting thresholds to obtain a comparison result; If the comparison result shows that the traffic percentage is less than the preset first rate limiting threshold, then the hybrid caching processing strategy three is selected; If the comparison result is that the traffic percentage is above the first rate limiting threshold and less than the preset second rate limiting threshold, then the hybrid caching processing strategy two is selected; If the comparison result shows that the traffic percentage is greater than the second rate limiting threshold, then the first hybrid caching strategy is selected.
3. The hybrid caching processing method according to claim 2, characterized in that, The step of selecting the corresponding hybrid caching strategy based on the traffic ratio further includes: According to the hybrid caching strategy, queries are performed by inputting a preset filter through the business application interface to obtain query results; Based on the query results, obtain the business application interface that uses the preset first-level cache.
4. The hybrid caching processing method according to claim 3, characterized in that, After the step of obtaining the business application interface using the preset first-level cache based on the query result, the method further includes: The system monitors data from preset data sources using a pre-defined monitoring mechanism. When the data in the data source changes, the changed data is synchronized to the preset three-level cache; The changed data is synchronized to the preset second-level cache through the three-level cache; According to the second-level cache, the changed data is synchronized to the preset first-level cache through a preset transmission mode.
5. The hybrid caching processing method according to claim 4, characterized in that, The step of synchronizing the changed data to the preset second-level cache through the three-level cache includes: The preset monitoring mechanism monitors the preset second-level cache and the third-level cache. If the number of keys in the second-level cache is not equal to the number of keys in the third-level cache, then the data in the third-level cache is pulled and synchronized to the second-level cache.
6. The hybrid caching processing method according to claim 1, characterized in that, The step of obtaining the business application interface request count table includes the following: Based on the preset multi-level caching architecture, obtain the first-level cache, second-level cache, and third-level cache; Delete the original application interface data in the first-level cache; Based on the secondary cache, preset core business application interface data is pushed to the primary cache through a preset transmission mode; Based on the core application interface data, analysis is performed using preset filters; If the analysis result indicates that the core business application interface exists in the preset filter, then the core business application interface data is saved to the first-level cache to generate the first business scenario. Based on the secondary cache, a second business scenario is generated through the core business application interface and the preset important business application interfaces; Based on the three-level cache, a third business scenario is generated through the core business application programming interface, the important business application programming interface, and the preset ordinary business application programming interface.
7. The hybrid caching processing method according to claim 6, characterized in that, Before the step of generating a hybrid caching strategy based on the request count table and the preset initial caching strategy, the following steps are also included: Write the interfaces of the first business scenario, the second business scenario, and the third business scenario into the configuration to generate configuration file one, configuration file two, and configuration file three. Based on configuration files 1, 2, and 3, preset filters are written to generate initial cache processing strategy 1, initial cache processing strategy 2, and initial cache processing strategy 3.
8. A hybrid caching processing apparatus, characterized in that, The hybrid cache processing device includes: The acquisition module is used to obtain a table of the number of requests to the business application interface. The generation module is used to generate a hybrid caching strategy based on the request count table and the preset initial caching strategy. The generation module is also used to filter the request count table according to a preset ratio to obtain high-frequency request business application interfaces. Based on the preset initial cache processing strategy one, generate hybrid cache processing strategy one; The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy two, a hybrid cache processing strategy two is generated. The high-frequency request business application interface is written into a preset filter, and combined with the preset initial cache processing strategy three, a hybrid cache processing strategy three is generated. The calculation module is used to obtain the percentage of total application interface traffic in the system's maximum traffic using a sliding window algorithm; The selection module is used to select the corresponding hybrid caching processing strategy based on the traffic ratio.
9. A terminal device, characterized in that, The terminal device includes a memory, a processor, and a hybrid cache processing program stored in the memory and executable on the processor. When executed by the processor, the hybrid cache processing program implements the steps of the hybrid cache processing method as described in any one of claims 1-7.
10. A calculator-readable storage medium, characterized in that, The computer-readable storage medium stores a hybrid cache processing program, which, when executed by a processor, implements the steps of the hybrid cache processing method as described in any one of claims 1-7.
Citation Information
Patent Citations
Cache strategy determination method and device, computer equipment and readable storage medium
CN112527749A
Data caching method and device, equipment and storage medium
CN115687423A