Cache optimization method and device based on different cache strategies, intelligent terminal
By employing asynchronous refresh and preheating methods in smart terminals, combined with a multi-level caching strategy, the problem of sudden traffic surges during peak periods in smart terminals was solved, improving cache hit rate and response efficiency, reducing server pressure, and avoiding latency, lag, and crashes.
Patent Information
- Application Number
- CN202310159199.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2043-02-14
AI Technical Summary
In existing technologies, sudden surges in traffic from smart terminals during peak periods can lead to a sharp increase in server pressure, resulting in latency, lag, or crashes. Furthermore, caching strategies cannot effectively address issues related to cache duration and information updates.
By employing asynchronous cache refresh and cache preheating, we can improve cache hit rate and response speed by pre-caching hot data during off-peak hours and asynchronously refreshing the cache during peak hours, combined with a multi-level caching strategy.
It effectively solves the problems of cache refresh and sudden traffic, improves cache hit rate and response time, reduces server pressure, and avoids latency, lag and crashes.
Smart Images

Figure CN116127222B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart terminal technology, and in particular to a cache optimization method, apparatus, smart terminal, and storage medium based on different caching strategies. Background Technology
[0002] With the development of technology and the continuous improvement of people's living standards, the use of various smart terminals such as smart TVs and smartphones is becoming more and more widespread. Smart terminals have become an indispensable entertainment and leisure tool in people's lives.
[0003] Peak viewing times for smart TVs typically coincide with a single period, causing a sudden surge in traffic to the TV and putting immense pressure on servers. This can lead to various delays and stutters, and in severe cases, even system crashes. To address these sudden traffic spikes, a common approach in current technology is to add caching services to improve response times and reduce pressure on backend servers. However, the cache duration of existing technologies can affect information updates. A cache that is too short will not provide the desired improvement in response times or reduce backend server load, while a cache that is too long will result in accessing outdated information.
[0004] Therefore, existing technologies still need improvement and development. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a cache optimization method, device, smart terminal and storage medium based on different caching strategies, which addresses the above-mentioned deficiencies of the prior art. The present invention can effectively solve the problems of cache refresh and sudden traffic by means of a cache asynchronous refresh, cache preheating and multi-level caching scheme.
[0006] The technical solution adopted by this invention to solve the problem is as follows: This invention provides a cache optimization method based on different caching strategies, wherein the method includes: By using a pre-configured cache preheating module, hot data is preheated and cached during periods of low access activity, and then stored as cached data. When an access request is received, the controller sends an access request to the server and checks the cached data to see if there is cached response data corresponding to the access request. If cached response data exists corresponding to the access request, the system will directly return the response data; when the request ends, the system will asynchronously request the server to retrieve the response data and asynchronously refresh the cache. If no cached response data exists for the access request, a synchronous request is made to the server to retrieve the response data. The request ends, and the cache is refreshed asynchronously.
[0007] The cache optimization method based on different caching strategies, wherein the step of pre-warming and caching hot data during the idle access period using a pre-set cache pre-warming module and storing it as cache data includes: A cache server for caching data is pre-configured between the terminal and the server, and the cache server is connected to a cache preheating module. The cache preheating module is used to pre-cache access data in the cache server before the peak access period.
[0008] The cache optimization method based on different caching strategies, wherein the step of pre-warming and caching hot data during the idle access period using a pre-set cache pre-warming module and storing it as cache data includes: Control the startup of the pre-configured cache preheating module; By pre-setting a cache preheating module on the cache module between the terminal and the server, hot data is pre-cached during off-peak access periods and cached in advance in the cache module.
[0009] The cache optimization method based on different caching strategies, wherein the asynchronous cache refresh includes: Asynchronous cache refresh extends the cache expiration time, thus prolonging the data caching period. If the requested content is in the cache, the cache is read immediately to retrieve the requested data, and the cache is refreshed asynchronously at the same time.
[0010] The cache optimization method based on different caching strategies, wherein the step of pre-warming and caching hot data during the idle access period using a pre-set cache pre-warming module and storing it as cache data further includes: An interface caching module for caching data is pre-configured between the terminal and the server, and the interface caching module is connected to an interface caching preheating module for preheating and caching hot data during periods of low access.
[0011] The cache optimization method based on different caching strategies, wherein the step of pre-warming and caching hot data during the idle access period using a pre-set cache pre-warming module and storing it as cache data further includes: In addition, a data caching module is set up between the server and the data storage end to cache data, and the data caching module is connected to a data caching preheating module for preheating and caching hot data during the access leisure period.
[0012] The cache optimization method based on different caching strategies, wherein the steps of directly returning the response data when a cached response data corresponding to the access request exists, and asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache upon request completion, include: The system first queries the interface cache module. If the interface cache module contains cached response data corresponding to the access request, the system directly returns the response data. When the request ends, the system asynchronously refreshes the interface cache module.
[0013] The cache optimization method based on different caching strategies, wherein the steps of directly returning the response data when a cached response data corresponding to the access request exists, and asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache upon request completion, further include: If the interface caching module does not have cached response data corresponding to the access request, then first check if the data caching module has cached response data corresponding to the access request. If the data caching module has cached response data corresponding to the access request, then control the data caching module to return the response data.
[0014] A cache optimization apparatus based on different caching strategies, wherein the apparatus includes: The first pre-setting module is used to pre-set a cache server for caching data between the terminal and the server, and to set the cache server to be connected to a cache preheating module. The cache preheating module is used to pre-cache the access data to the cache server before the peak access period arrives. The preheating cache module is used to preheat and cache hot data during the idle period of access by using a pre-configured cache preheating module, and store it as cache data. The access request module is used to control the sending of an access request to the server when an access request is received, and to query the cached data to see if there is cached response data corresponding to the access request. The first access control module is used to control the direct return of response data when there is cached response data corresponding to the access request; when the request ends, it asynchronously requests the server to obtain response data and asynchronously refreshes the cache. The second access control module is used to synchronously request the server to obtain the response data when the access request control module does not have cached response data corresponding to the access request, then the request ends and the cache is refreshed asynchronously.
[0015] A smart terminal includes a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs including methods for performing as described above.
[0016] The beneficial effects of this invention are as follows: This invention discloses a cache optimization method, apparatus, smart terminal, and storage medium based on different caching strategies. The method includes: pre-warming and caching hot data during periods of low access activity using a pre-set cache preheating module, storing the data as cached data; when an access request is received, controlling the system to initiate an access request to the server, and querying the cached data to see if there is cached response data corresponding to the access request; if cached response data corresponding to the access request exists, controlling the system to directly return the response data; when the request ends, simultaneously asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache; when no cached response data corresponding to the access request exists, synchronously requesting the server to obtain the response data, ending the request, and asynchronously refreshing the cache. This invention provides a cache optimization scheme based on asynchronous refresh, preheating, and multi-level caching, which can effectively solve the problems of cache refresh and sudden traffic surges. This invention improves the hit rate and real-time performance, ultimately improving response time. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of a terminal-server connection scheme that does not use caching in the existing technology.
[0019] Figure 2 This is a schematic diagram of a terminal-server connection scheme that uses caching in existing technology.
[0020] Figure 3 This is a flowchart illustrating the cache optimization method based on different caching strategies provided in Embodiment 1 of the present invention.
[0021] Figure 4 This is a schematic diagram showing the connection of various parts in the implementation of the cache optimization method based on different caching strategies provided in Embodiment 1 of the present invention.
[0022] Figure 5 This is a flowchart illustrating the cache optimization method based on different caching strategies provided in Embodiment 2 of the present invention.
[0023] Figure 6 This is a schematic diagram showing the connection of various parts in the implementation of the cache optimization method based on different caching strategies provided in Embodiment 2 of the present invention.
[0024] Figure 7 This is a schematic diagram of a cache optimization device based on different caching strategies provided in an embodiment of the present invention.
[0025] Figure 8 This is a block diagram illustrating the internal structure of a smart terminal provided in an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0027] It should be noted that if the embodiments of the present invention involve directional indicators (such as up, down, left, right, front, back, etc.), the directional indicators are only used to explain the relative positional relationship and movement of the components in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicators will also change accordingly.
[0028] Currently, caching is not used in solutions such as Figure 1 As shown, the terminal connects directly to the server, and all requests from the terminal go directly to the server, which responds directly. Without caching, all traffic from the terminal goes directly to the server. If there is a sudden surge in traffic, the server will also be affected, leading to longer service response times or even server crashes. This solution cannot handle high-volume access.
[0029] Existing traditional caching solutions, such as Figure 2 As shown, the traditional caching scheme in existing technology involves adding a caching service between the terminal and the server, that is, adding a caching server in front of the backend server. 1. All terminal requests first go to the caching server, so the terminal accesses the cache first. 2. Only if the cache is not hit does the terminal access the backend server. 3. Then the data is written to the cache, 4. and finally the response is returned. This caching strategy can alleviate the pressure on the backend server to a certain extent. However, it has the following drawbacks: 1. Cache time and update issues; If the cache time is too short, it will not have the effect of caching, and most of the traffic will still be requested to the server. If the cache time is too long, the cache will be refreshed slowly, resulting in access to a large amount of old data.
[0030] 2. Sudden traffic spikes; For devices like televisions where power-on and playback times are concentrated, caching cannot solve this problem. Because no cache is generated before users turn on their devices in a concentrated period, all traffic ultimately ends up on the server.
[0031] To address the problems of existing technologies, this invention provides a cache optimization method based on different caching strategies. In the embodiments of the invention, asynchronous refresh combined with cache preheating can effectively solve the problems of cache refresh and sudden traffic.
[0032] Exemplary methods like Figure 1 As shown in the figure, Embodiment 1 of the present invention provides a cache optimization method based on different caching strategies. This cache optimization method can be applied to smart terminals such as Android devices, smart TVs, and smartphones, and is mainly used for smart terminal access traffic control. In the cache optimization scheme of Embodiment 1 of the present invention, which is an asynchronous refresh plus preheating cache, the method includes the following steps: Step S100: Through the pre-set cache preheating module, hot data is preheated and cached during the access leisure period and stored as cache data; In the specific implementation of this embodiment, as follows: Figure 4 As shown, a cache server (also called a cache module) is pre-configured between the terminal and the server to cache data. This cache server (caching module) is connected to a cache preheating module, which pre-caches access data into the cache server before peak access periods. Specifically, in this embodiment, the main function of the cache preheating module is to pre-cache recent hot data (such as recent trending news data, recent trending movie viewing data, etc.) into the cache server before peak access periods (sudden traffic surges). In other words, the cache preheating of this invention typically involves caching recent hot data, such as recent trending news data and recent trending movie viewing data, in advance during off-peak access periods, utilizing idle time. This ensures that the cache already exists when peak periods arrive, preventing excessive pressure on the server. This improves server responsiveness and solves the problem of sudden traffic surges.
[0033] Thus, in this embodiment of the invention, a pre-set cache preheating module can be used to preheat and cache hot data during periods of leisure access, and store it as cache data.
[0034] Specifically, when the terminal starts, it controls the start of a pre-configured cache preheating module; by pre-configuring the cache preheating module on the cache module between the terminal and the server, hot data is pre-cached during off-peak access periods and cached in advance in the cache module.
[0035] Step S200: When an access request is received, the system sends an access request to the server and queries the cached data to see if there is cached response data corresponding to the access request. Thus, in Embodiment 1 of the present invention, when an access request is obtained, the system controls the initiation of an access request to the server and queries the cached data to see if there is cached response data corresponding to the access request; that is, it first searches the hot data that has been pre-cached to the cache server by the cache preheating module to see if there is cached response data corresponding to the access request. If there is, it proceeds to step S300, and if there is no such data, it proceeds to step S400.
[0036] Step S300: If there is cached response data corresponding to the access request, the control will directly return the response data; the request ends, and at the same time, the server is asynchronously requested to obtain the response data and the cache is asynchronously refreshed. In this embodiment of the invention, when the hot data pre-cached in the cache server by the cache preheating module contains cached response data corresponding to the access request, the response data is returned directly; when the request ends, the server is asynchronously requested to obtain the response data and the cache is asynchronously refreshed.
[0037] The asynchronous cache refresh includes: extending the cache time setting to prolong the data caching; when the requested content is in the cache, the cache is immediately read to obtain the requested data, and the cache is refreshed asynchronously at the same time.
[0038] In this embodiment of the invention, asynchronous cache refresh sets the cache time to be as long as possible, thus increasing the probability of a cache hit. When a cache hit occurs, the hit data is returned immediately, and the cache is refreshed asynchronously. The frequency of asynchronous cache refresh can be defined according to the real-time requirements of the cache, and the length of the refresh time does not affect the interface response time. This improves response stability and cache real-time performance. A cache hit means that the content required by the request is in the cache, and the requested data can be retrieved by reading the cache. If the cache is not hit, the server has to process the request, which slows down the response.
[0039] Step S400: If there is no cached response data corresponding to the access request, then synchronously request the server to obtain the response data, the request ends, and the cache is refreshed asynchronously.
[0040] In this embodiment of the invention, when the hot data pre-cached in the cache server by the cache preheating module does not contain cached response data corresponding to the access request, i.e., there is no cached response data corresponding to the access request, the server is synchronously requested to obtain the response data, the request ends, and the cache is asynchronously refreshed.
[0041] That is, in the embodiments of the present invention, as follows Figure 4 As shown, when an access request is received, 1. All requests are first cached on the cache server; if the cache server's pre-warmed data does not contain the data, proceed to step 2, and then access the backend server; 3. Write to the cache; 4. Response, implemented as follows: Step 1: Start the preheating module. The preheating module will cache hot data. Figure 4 (Cache preheating module).
[0042] Step 2: The user sends a request to the server, which first checks the cache to see if the response data exists. A. If cached data exists, return the response data directly, the request ends, and simultaneously, asynchronously request the server to retrieve the response data and asynchronously refresh the cache. Figure 4 Steps 2 and 3).
[0043] B. If no cached data is found and the response data is returned directly, then synchronously request the server to retrieve the response data, end the request, and asynchronously refresh the cache. For example... Figure 4 The dashed lines shown are all asynchronous and will not affect the overall response time.
[0044] As can be seen from Example 1 above, the present invention adopts an asynchronous refresh plus cache preheating scheme ( Figure 4 ) and traditional caching solutions ( Figure 2 The main differences are as follows: 1. Traditional caching solutions will never hit the cache on the first request. However, the asynchronous refresh plus cache preheating solution involves cache preheating, which means the first request may hit the cache, thus improving cache response efficiency.
[0045] 2. Traditional caching solutions all use synchronous refresh, meaning the entire process waits for the cache to finish before returning a response. Furthermore, there's a risk of a large number of caches expiring simultaneously within a short period, leading to a surge of requests to the server. In contrast, the asynchronous refresh plus cache preheating solution of this invention primarily refreshes the cache asynchronously. Cache updates do not block the response, and the cache expiration refresh time can be more effectively controlled, preventing a large number of caches from expiring simultaneously within a short timeframe.
[0046] Example 2, like Figure 5 As shown, Embodiment 2 of the present invention provides a cache optimization method based on different caching strategies, specifically a multi-level caching scheme, such as... Figure 5 As shown in Embodiment 2 of the present invention, a cache optimization method based on different caching strategies includes the following steps: Step S10: First, set up an interface caching module for caching data between the terminal and the server, and set up an interface caching preheating module for preheating and caching hot data during the leisure period; and set up a data caching module for caching data between the server and the data storage end, and set up a data caching module for preheating and caching hot data during the leisure period.
[0047] like Figure 6 As shown in the figure, the cache optimization method based on different caching strategies provided in Embodiment 2 of the present invention adopts multi-level caching. Multi-level caching can stagger the caching time of each stage, thereby further improving cache hit rate and improving server performance.
[0048] As above Figure 6 As shown, server-side data is typically stored in databases or other data storage services, which is also a performance bottleneck for servers. This invention addresses this by implementing a multi-level caching service scheme. An interface caching module is set up between the terminal and the server to cache data, and this interface caching module is connected to an interface cache preheating module for preheating and caching hot data during periods of low access. A data caching module is also set up between the server and the data storage end to cache data, and this data caching module is connected to a data cache preheating module for preheating and caching hot data during periods of low access. Embodiment 2 of this invention adds another layer of caching between the server and the data storage end, and also incorporates a preheating function. The caching strategies at the interface end and the data end are often different, and the caching times are staggered, preventing simultaneous cache blank periods and thus improving the cache hit rate and interface performance.
[0049] Step S20: Preheat and cache hot data during the access idle period through the pre-set interface cache preheating module, and store it as interface cache data; In this embodiment of the invention, an interface cache preheating module is connected to the interface cache module between the terminal and the server. This module can cache the most recent hot data in advance during off-peak access periods for convenient access. Simultaneously, a data cache module is set up between the server and the data storage end, and the data cache preheating module is connected to this data cache module to cache the most recent hot data in advance during off-peak access periods.
[0050] Then, the preheating module is activated, which caches hot data (i.e., Figure 6 (The interface cache warm-up module and the data cache warm-up module are located in the middle).
[0051] Step S30: Upon receiving an access request, the system initiates an access request to the server and queries the interface cache data to determine if there is cached response data corresponding to the access request. When an access request is received, the controller sends an access request to the server and queries the interface cache data to see if there is cached response data corresponding to the access request, and then proceeds to step S40.
[0052] Step S40: First, control the interface cache module to query. If the interface cache module has cached response data corresponding to the access request, control the interface cache module to directly return the response data. When the request ends, the interface cache module is refreshed asynchronously.
[0053] Step S50: If the interface caching module does not have cached response data corresponding to the access request, then first query the data caching module to see if it has cached response data corresponding to the access request. Step S60: If the data caching module has cached response data corresponding to the access request, control the data caching module to return the response data.
[0054] Step S70: If there is no cached response data corresponding to the access request, then synchronously request the server to obtain the response data, the request ends, and the cache is refreshed asynchronously.
[0055] That is, in the embodiments of the present invention, such as Figure 6 As shown, when a user terminal sends a request to the server: it first enters process A, which checks the interface cache. If the interface cache exists, it returns response data, the request ends, and the interface cache is asynchronously refreshed. If the interface cache does not exist, it enters process B. Process B: it first checks the data cache. If the data cache exists, it returns the data cache, returns response data, the request ends, and simultaneously, the data cache and the asynchronously cached response data are asynchronously refreshed into the interface cache. Figure 6 The dashed lines shown are all asynchronous and will not affect the overall response time.
[0056] Thus, this invention, through a multi-level caching scheme of asynchronous refresh and cache preheating, can effectively solve the problems of cache refresh and sudden traffic.
[0057] Compared to the asynchronous refresh plus cache preheating scheme of Embodiment 1, the multi-level caching scheme of Embodiment 2 adopts a multi-level caching strategy, adding caches on both the interface side and the data side, and using an asynchronous plus cache preheating scheme in both cases. This further improves cache hit rate, thereby improving server response time.
[0058] Exemplary device like Figure 7 As shown in the figure, an embodiment of the present invention provides a cache optimization device based on different caching strategies, the device comprising: The first pre-setting module 710 is used to pre-set a cache server for caching data between the terminal and the server, and to set the cache server to be connected to a cache preheating module. The cache preheating module is used to pre-cache the access data into the cache server before the peak access period arrives. The preheating cache module 720 is used to preheat and cache hot data during the idle period of access by using a pre-set cache preheating module, and store it as cache data. The access request module 730 is used to control the sending of an access request to the server when an access request is received, and to query whether there is cached response data corresponding to the access request through cached data. The first access control module 740 is used to control the direct return of response data when there is cached response data corresponding to the access request; when the request ends, it asynchronously requests the server to obtain response data and asynchronously refreshes the cache. The second access control module 750 is used to synchronously request the server to obtain the response data when the access request control module does not have cached response data corresponding to the access request, the request ends, and the cache is refreshed asynchronously, as described above.
[0059] Based on the above embodiments, the present invention also provides a smart terminal, the principle block diagram of which can be as follows: Figure 8 As shown, the smart terminal includes a processor, memory, network interface, and display screen connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a cache optimization method based on different caching strategies. The display screen can be an LCD screen or an e-ink screen, and the camera is pre-installed within the smart terminal.
[0060] Those skilled in the art will understand that Figure 8 The block diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the smart terminal to which the present invention is applied. A specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0061] In one embodiment, a smart terminal is provided, including a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors. The one or more programs include instructions for performing the following operations: By using a pre-configured cache preheating module, hot data is preheated and cached during periods of low access activity, and then stored as cached data. When an access request is received, the controller sends an access request to the server and checks the cached data to see if there is cached response data corresponding to the access request. If cached response data exists corresponding to the access request, the system will directly return the response data; when the request ends, the system will asynchronously request the server to retrieve the response data and asynchronously refresh the cache. If no cached response data exists for the access request, a synchronous request is made to the server to obtain the response data. The request ends, and the cache is refreshed asynchronously, as described above.
[0062] The step of preheating and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data includes the following: A cache server for caching data is pre-configured between the terminal and the server, and the cache server is connected to a cache preheating module. The cache preheating module is used to pre-cache access data in the cache server before the peak access period.
[0063] The step of pre-warming and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data includes: Control the startup of the pre-configured cache preheating module; By pre-setting a cache preheating module on the cache module between the terminal and the server, hot data is pre-cached during off-peak access periods and cached in advance in the cache module.
[0064] The cache optimization method based on different caching strategies, wherein the asynchronous cache refresh includes: Asynchronous cache refresh extends the cache expiration time, thus prolonging the data caching period. If the requested content is in the cache, the cache is read immediately to retrieve the requested data, and the cache is refreshed asynchronously at the same time.
[0065] The step of preheating and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data further includes: An interface caching module for caching data is pre-configured between the terminal and the server, and the interface caching module is connected to an interface caching preheating module for preheating and caching hot data during periods of low access.
[0066] The step of preheating and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data further includes: In addition, a data caching module is set up between the server and the data storage end to cache data, and the data caching module is connected to a data caching preheating module for preheating and caching hot data during the access leisure period.
[0067] The steps of directly returning the response data when a cached response data corresponding to the access request exists, and asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache upon request completion include: The system first queries the interface cache module. If the interface cache module contains cached response data corresponding to the access request, the system directly returns the response data. When the request ends, the system asynchronously refreshes the interface cache module.
[0068] The steps of directly returning the response data when a cached response data corresponding to the access request exists, and asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache upon request completion, further include: If the interface caching module does not have cached response data corresponding to the access request, then first check if the data caching module has cached response data corresponding to the access request. If the data caching module contains cached response data corresponding to the access request, then the data caching module is controlled to return the response data.
[0069] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0070] In summary, this invention discloses a cache optimization method, apparatus, smart terminal, and storage medium based on different caching strategies. The method includes: pre-warming and caching hot data during periods of low access activity using a pre-set cache preheating module, storing the data as cached data; upon receiving an access request, controlling the initiation of an access request to the server, and querying the cached data to determine if there is cached response data corresponding to the access request; if cached response data corresponding to the access request exists, controlling the direct return of the response data; upon request termination, simultaneously asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache; if no cached response data corresponding to the access request exists, synchronously requesting the server to obtain the response data, terminating the request, and asynchronously refreshing the cache. This invention provides a cache optimization scheme based on asynchronous refresh, preheating, and multi-level caching, which effectively solves the problems of cache refresh and sudden traffic surges. This invention improves hit rate and real-time performance, ultimately improving response time.
[0071] It should be understood that the application of this invention is not limited to the examples described above. Those skilled in the art can make improvements or modifications based on the above description, such as using the average or weighted frame rate of the forward reference time as a reference factor for threshold determination, or using the minimum interval time as the trigger condition for frame rate adjustment instead of determining the adaptive threshold. All such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A cache optimization method based on different caching strategies, characterized in that, The method includes: An interface caching module for caching data is pre-configured between the terminal and the server, and the interface caching module is connected to an interface caching preheating module for preheating and caching hot data during periods of low access. And set up a data caching module between the server and the data storage end to cache data, and set up a data caching preheating module to connect the data caching module to a data caching preheating module for preheating and caching hot data during the access leisure period; The interface cache preheating module and the data cache preheating module have different caching strategies and their caching times are staggered. By using a pre-configured cache preheating module, hot data is preheated and cached during periods of low access activity, and then stored as cached data. When an access request is received, the controller sends an access request to the server and checks the cached data to see if there is cached response data corresponding to the access request. If cached response data exists corresponding to the access request, the system will directly return the response data; when the request ends, the system will asynchronously request the server to retrieve the response data and asynchronously refresh the cache. If no cached response data exists for the access request, a synchronous request is made to the server to obtain the response data, the request ends, and the cache is refreshed asynchronously. The steps of directly returning the response data when a cached response data corresponding to the access request exists, and asynchronously requesting the server to obtain the response data and asynchronously refreshing the cache upon completion of the request, include: The system first queries the interface cache module. If the interface cache module contains cached response data corresponding to the access request, the system directly returns the response data. When the request ends, the system asynchronously refreshes the interface cache module. If the interface caching module does not have cached response data corresponding to the access request, then first check if the data caching module has cached response data corresponding to the access request. If the data caching module has cached response data corresponding to the access request, then control the data caching module to return the response data; The asynchronous refresh cache includes: Asynchronous cache refresh extends the cache expiration time, thus prolonging the data caching period. If the requested content is in the cache, the cache is read immediately to retrieve the requested data, and the cache is refreshed asynchronously at the same time. The cache hit is returned immediately; whereby the cache hit is defined as: the requested content is in the cache, and the cache is read to obtain the requested data.
2. The cache optimization method based on different caching strategies according to claim 1, characterized in that, Before the step of preheating and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data, the following steps are included: A cache server for caching data is pre-configured between the terminal and the server, and the cache server is connected to a cache preheating module. The cache preheating module is used to pre-cache access data in the cache server before the peak access period.
3. The cache optimization method based on different caching strategies according to claim 1, characterized in that, The step of pre-warming and caching hot data during the leisure period using a pre-set cache preheating module and storing it as cached data includes: Control the startup of the pre-configured cache preheating module; By pre-setting a cache preheating module on the cache module between the terminal and the server, hot data is pre-cached during off-peak access periods and cached in advance in the cache module.
4. A cache optimization apparatus based on different caching strategies, used to execute the cache optimization method based on different caching strategies as described in any one of claims 1-3, characterized in that, The device includes: The first pre-setting module is used to pre-set a cache server for caching data between the terminal and the server, and to set the cache server to be connected to a cache preheating module. The cache preheating module is used to pre-cache the access data to the cache server before the peak access period arrives. The preheating cache module is used to preheat and cache hot data during the idle period of access by using a pre-configured cache preheating module, and store it as cache data. The access request module is used to control the sending of an access request to the server when an access request is received, and to query the cached data to see if there is cached response data corresponding to the access request. The first access control module is used to control the direct return of response data when there is cached response data corresponding to the access request; when the request ends, it asynchronously requests the server to obtain response data and asynchronously refreshes the cache. The second access control module is used to synchronously request the server to obtain the response data when the access request control module does not have cached response data corresponding to the access request, then the request ends and the cache is refreshed asynchronously.
5. A smart terminal, characterized in that, It includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, wherein the one or more programs include methods for performing any one of claims 1-3.
Citation Information
Patent Citations
Processing method and system of data access
CN103177005A
