A cache management method, apparatus, device, medium and computer program product
By setting up access history queues and cache queues in cache management, calculating the heat value based on the access frequency and time characteristics of data items, and dynamically adjusting the threshold K, the problem of lack of flexibility in existing cache management methods is solved, achieving more efficient cache management and system performance improvement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2025-06-18
- Publication Date
- 2026-06-05
AI Technical Summary
Existing cache management methods lack flexibility, are only applicable to simple access patterns, and cannot effectively cope with complex and ever-changing access requirements.
A cache management method is adopted, which optimizes cache allocation and management by setting up access history queues and cache queues, calculating the heat value based on the access frequency and time characteristics of data items, dynamically adjusting the threshold K, and setting weight coefficients in combination with system categories.
It improves cache hit rate and system performance, enabling it to flexibly handle the complex and ever-changing access needs of various systems and improve resource utilization efficiency.
Smart Images

Figure CN120803978B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, specifically to a cache management method, apparatus, device, medium, and computer program product. Background Technology
[0002] A cache is a small-capacity memory located between the Central Processing Unit (CPU) and main memory. It has a faster access speed than main memory and can quickly provide instructions and data to the CPU, improving program execution speed. Cache technology is an important technique adopted to resolve the mismatch between CPU processing speed and main memory read / write speed.
[0003] To utilize caches more efficiently, cache management is necessary. Current cache management technologies typically employ the Least Recently Used (LRU) eviction policy, whose core idea is to prioritize removing data that has not been accessed for the longest time. When cache space is insufficient, the LRU algorithm implements the eviction mechanism by maintaining an ordered queue. Specifically, whenever data is accessed, it is moved to the head of the queue (indicating most recently used), and when data needs to be evicted, it is removed from the tail of the queue (indicating least recently used). This cache management method lacks flexibility and is only suitable for simple access patterns. Summary of the Invention
[0004] At least one embodiment of this application provides a cache management method, apparatus, device, medium, and computer program product to address the problem that existing cache management methods lack flexibility and can only be applied to simple access patterns.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a cache management method, including:
[0007] When a data item is accessed for the first time, the data item is loaded into the access history queue;
[0008] When the number of times the data item is accessed in the access history queue is greater than or equal to the threshold K, the data item is loaded into the cache queue.
[0009] Optional,
[0010] When the cache eviction condition is met, the popularity value of each data item in the cache queue is determined. The popularity value of each data item is determined according to its system category. The system categories include: all-time access-restricted systems, part-time access-restricted systems, and unrestricted access systems.
[0011] The data items to be evicted are determined based on the popularity value of each data item in the cache queue;
[0012] Remove the data item to be evicted from the cache queue.
[0013] Optional,
[0014] Determine the popularity value of each data item in the cache queue, including:
[0015] When the system to which the data item belongs is the all-time access-restricted system, the popularity value of the data item is calculated according to the following formula: Popularity value = All-time access-restricted system access frequency * frequency weight + γ * time weight * 1 / (current time - most recent access time), where γ is a positive number less than 1;
[0016] If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within an unrestricted period, the popularity value of the data item is calculated according to the following formula:
[0017] Popularity score = Access frequency of restricted systems during certain periods * Frequency weight + 1 / (Current time - Last access time) * Time weight;
[0018] If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within a restricted period, the popularity value of the data item is calculated according to the following formula:
[0019] Popularity value = Access frequency of restricted system during certain periods * frequency weight + δ(t) * time weight * 1 / (current time - most recent access time), where δ(t) is a time function, 0 ≤ t ≤ T, T is the restricted duration, and δ(0) > γ;
[0020] If the system to which the data item belongs is the unrestricted system, the heat value of the data item is calculated according to the following formula:
[0021] Popularity score = Unrestricted system access frequency * Frequency weight + 1 / (Current time - Last access time) * Time weight;
[0022] The sum of the frequency weight and the time weight is 1.
[0023] Optional,
[0024] Obtain the access parameters of each category of systems within the current statistical period, and calculate the average value of the access parameters over historical statistical periods; wherein, the access parameters are the access frequency of each category of systems or the proportion of the number of accesses of each category of systems to all categories of systems;
[0025] If the increase in the access parameter relative to the average value of the access parameter in the all-time access-restricted system is greater than a first threshold, the value of K is reduced.
[0026] If the increase in the access parameter of the unrestricted system relative to the average value of the access parameter is greater than a second threshold, the value of K is increased.
[0027] If, during a certain period of access restriction, the increase in the access parameter relative to the average value of the access parameter is greater than a third threshold, the value of K is reduced.
[0028] If, during a period of restricted access, the increase in the access parameter relative to the average value of the access parameter during an unrestricted access period exceeds a fourth threshold, the value of K is increased.
[0029] Optionally, the percentage of visits to each system category out of all systems category is calculated as follows:
[0030] Get the number of visits to each category of systems within the current statistical period;
[0031] Based on the number of visits to each type of system within the current statistical period, calculate the total number of visits to all types of systems within the current statistical period;
[0032] The percentage of visits to each category of systems is calculated based on the ratio of the number of visits to each category of systems to the total number of visits to all categories of systems within the current statistical period.
[0033] Optionally, the first threshold is calculated based on a third preset ratio of the average value of the access parameters;
[0034] The second threshold is calculated based on a fourth preset ratio of the average value of the access parameters;
[0035] The third threshold is calculated based on a fifth preset ratio of the average value of the access parameters.
[0036] Optionally, increasing the value of K includes at least one of the following:
[0037] The value of K is increased according to a preset first fixed step size;
[0038] Add the current value of K to ΔK1, where ΔK1 is the smaller of the product of the current value of K and the first preset ratio and the preset maximum increase.
[0039] The reduction of the value of K includes at least one of the following:
[0040] The value of K is decreased according to a preset second fixed step size;
[0041] Subtract the current value of K from ΔK2, where ΔK2 is the smaller of the product of the current value of K and the second preset ratio and the preset maximum reduction magnitude.
[0042] Optionally, the time interval between two consecutive K value adjustments shall not be less than a preset minimum time interval.
[0043] Secondly, embodiments of this application provide a caching device, including:
[0044] The first loading unit is used to load the data item into the access history queue when the data item is accessed for the first time.
[0045] The second loading unit is used to load the data item into the cache queue when the number of times the data item has been accessed in the access history queue is greater than or equal to a threshold K.
[0046] Thirdly, embodiments of this application provide an electronic device, which includes: a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the processor executes the program or instructions, the electronic device performs the cache management method provided in embodiments of this application.
[0047] Fourthly, embodiments of this application provide a computer-readable storage medium storing a program, which, when executed by a processor, implements the cache management method provided in the embodiments of the application.
[0048] Fifthly, embodiments of this application provide a computer program product, including computer instructions, which, when executed by a processor, implement the cache management method provided in the embodiments of the application.
[0049] Compared with existing technologies, the cache management method, apparatus, device, medium, and computer program product provided in this application reasonably classifies and categorizes various systems of the platform, and sets different weight coefficients for different types of systems. This can more accurately reflect the importance of different types of systems in the cache, optimize cache allocation and management, and control whether data items are moved to the cache queue by setting parameter K. This allows for a quick response to subsequent access requests, thereby improving system performance and resource utilization efficiency. At the same time, by dynamically adjusting the value of K, it can ensure that the data items in the cache queue are always synchronized with the current access mode, thereby improving the cache hit rate and system performance. This allows for flexible response to the complex and ever-changing access needs of various systems in the platform. Attached Figure Description
[0050] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0051] Figure 1 This is a flowchart illustrating a cache management method according to an embodiment of this application;
[0052] Figure 2 This is a flowchart illustrating another cache management method according to an embodiment of this application;
[0053] Figure 3 This is a structural block diagram of a cache management device according to an embodiment of this application;
[0054] Figure 4 This is a schematic diagram of a cache management electronic device according to an embodiment of this application. Detailed Implementation
[0055] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, without limiting the number of objects; for example, the first object can be one or more. Furthermore, "or" in this application indicates at least one of the connected objects. For example, "A or B" covers three scenarios: Scenario 1: including A but not B; Scenario 2: including B but not A; Scenario 3: including both A and B. The character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0056] The term "instruction" in this application can be either a direct instruction (or explicit instruction) or an indirect instruction (or implicit instruction). A direct instruction can be understood as one in which the sender explicitly informs the receiver of specific information, the operation to be performed, or the requested result, etc., in the instruction sent. An indirect instruction can be understood as one in which the receiver determines the corresponding information based on the instruction sent by the sender, or makes a judgment and determines the operation to be performed or the requested result, etc., based on the judgment result.
[0057] like Figure 1 The illustration shows an embodiment of a cache management method provided in this application, comprising the following steps:
[0058] Step 101: When a data item is accessed for the first time, add the data item to the access history queue.
[0059] This application embodiment sets up an access history queue. When a data item is accessed for the first time, it is loaded into the access history queue.
[0060] Step 102: When the number of times the data item is accessed in the access history queue is greater than or equal to the threshold K, the data item is loaded into the cache queue.
[0061] The system will monitor the number of times each data item in the access history queue is accessed. When a data item in the access history queue is accessed K times, it means that the probability of the data item being accessed again is relatively high. The data item will be moved to the cache queue to quickly respond to subsequent access requests.
[0062] This embodiment sets up an access history queue. Only when the number of times a data item in the access history queue is accessed reaches a threshold K will it be loaded into the cache queue. This filters out data items that are likely to be accessed again and loads them into the cache queue, achieving the technical effect of efficient cache utilization.
[0063] like Figure 2 The illustration shows an embodiment of another cache management method provided in this application, which includes the following steps:
[0064] Step 201: When a data item is accessed for the first time, add the data item to the access history queue.
[0065] Step 202: When the number of times the data item is accessed in the access history queue is greater than or equal to the threshold K, the data item is loaded into the cache queue.
[0066] The initial threshold for K can be set based on experience, such as the rounded value of the average number of visits to various systems on the platform, or the median number of visits. Alternatively, it can be calculated based on the access ratio of each system. In this embodiment, the platform includes three types of systems: systems with access restricted at all times, systems with access restricted at some times, and systems with unrestricted access. Assuming that the access frequencies of the three types of systems during a certain historical period are a1, a2, and a3, and the proportions of the number of visits to each type of system to the total number of visits to all systems are b1, b2, and b3, the initial value of K can be the rounded value calculated as follows: K = a1*b1 + a2*b2 + a3*b3.
[0067] Preferably, the embodiment of this application dynamically adjusts the K value, mainly including the following steps:
[0068] Obtain the access parameters of each category of systems within the current statistical period, and calculate the average value of the access parameters over historical statistical periods; wherein, the access parameters are the access frequency of each category of systems or the proportion of the number of accesses of each category of systems to all categories of systems;
[0069] If the increase in the access parameter relative to the average value of the access parameter in the all-time access-restricted system is greater than a first threshold, the value of K is reduced.
[0070] If the increase in the access parameter of the unrestricted system relative to the average value of the access parameter is greater than a second threshold, the value of K is increased.
[0071] If, during a certain period of access restriction, the increase in the access parameter relative to the average value of the access parameter is greater than a third threshold, the value of K is reduced.
[0072] If, during a period of restricted access, the increase in the access parameter relative to the average value of the access parameter during an unrestricted access period exceeds a fourth threshold, the value of K is increased.
[0073] Here, the percentage of visits to each system category compared to all systems of all categories is calculated as follows:
[0074] Get the number of visits to each category of systems within the current statistical period;
[0075] Based on the number of visits to each type of system within the current statistical period, calculate the total number of visits to all types of systems within the current statistical period;
[0076] The percentage of visits to each category of systems is calculated based on the ratio of the number of visits to each category of systems to the total number of visits to all categories of systems within the current statistical period.
[0077] The first threshold is calculated based on a third preset ratio of the average value of the access parameters;
[0078] The second threshold is calculated based on a fourth preset ratio of the average value of the access parameters;
[0079] The third threshold is calculated based on a fifth preset ratio of the average value of the access parameters.
[0080] The aforementioned third, fourth, and fifth preset ratios can be set according to the access parameters of various system categories. For example, they can be set to a value between 5% and 15%. The aforementioned third, fourth, and fifth preset ratios can be the same or different. Furthermore, the embodiments of this application can also appropriately adjust the aforementioned ratios based on the actual system operation results. The embodiments of this application do not impose specific limitations in this regard.
[0081] By monitoring the incremental changes of access parameters relative to the average value of access parameters over historical statistical periods and dynamically adjusting the K value, it is possible to ensure that the data items in the cache queue are always synchronized with the current access pattern, thereby improving the cache hit rate and system performance, and flexibly responding to the complex and ever-changing access needs of various systems in the platform.
[0082] To avoid the negative impact of frequent fluctuations in the K value on system performance, a fixed step size can be set to adjust the K value, or the K value can be adjusted according to the product of the current K value and a preset ratio. If the product of the current K value and the preset ratio is greater than the preset maximum adjustment range, the preset maximum adjustment range is used. Specifically, this includes:
[0083] Increasing the value of K includes at least one of the following:
[0084] The value of K is increased according to a preset first fixed step size;
[0085] Add the current value of K to ΔK1, where ΔK1 is the smaller of the product of the current value of K and a first preset ratio and a preset maximum increase.
[0086] Decreasing the value of K includes at least one of the following:
[0087] The value of K is decreased according to a preset second fixed step size;
[0088] Subtract the current value of K from ΔK2, where ΔK2 is the smaller of the product of the current value of K and the second preset ratio and the preset maximum reduction magnitude.
[0089] Here, the first fixed step size and the second fixed step size can be set according to a proportion between 1% and 5% of the number of times the data item is accessed in the access history queue. The first fixed step size and the second fixed step size can be equal or unequal. In addition, the embodiments of this application can also appropriately adjust the above proportions according to the actual system operation effect. For example, when the data item in the cache queue is frequently replaced, the first and second fixed step sizes can be increased to adjust them to a higher proportion of the number of times the data item is accessed in the access history queue.
[0090] To avoid the negative impact of frequent fluctuations in the K value on system performance, this embodiment of the application can also set a minimum interval for adjusting the K value. The time interval between two adjacent K value adjustments is not less than the preset minimum time interval. Typically, if the K value is adjusted within the current statistical period, it is usually necessary to wait for a minimum time interval before the K value can be adjusted again. The minimum time interval for K value adjustment is usually set to a value between 30 minutes and 1 hour. Of course, if the system's access volume changes very significantly, this minimum time interval can be adjusted adaptively.
[0091] Step 203: When the cache eviction condition is met, determine the popularity value of each data item in the cache queue. The popularity value of each data item is determined according to its system category. The system categories include: all-time access-restricted systems, part-time access-restricted systems, and unrestricted access systems.
[0092] When the cache space is insufficient, that is, when the cache eviction condition is met, the system will evict some data in the cache.
[0093] The current platform system is numerous and diverse. This embodiment divides the system access into three categories based on the restriction: systems with restricted access at all times, systems with restricted access during some times, and systems with unrestricted access. Based on the category to which each system belongs, the popularity value of the data items in that category is calculated, and the data items in the cache queue are sorted and managed accordingly.
[0094] Systems with restricted access around the clock typically include critical core business systems such as billing systems and user data management systems. Because these systems store sensitive or core business data, they require strict security controls and access restrictions to ensure data integrity and security. Therefore, these systems have access restrictions at all times, allowing only specific users or processes to access them under security policies.
[0095] Systems with restricted access during specific time periods typically include non-core business systems or auxiliary systems, such as log analysis systems and performance monitoring systems. These systems may experience higher access demands during specific time periods (such as working hours or peak business hours), but lower access volumes at other times. To balance system performance and resource utilization, access restrictions are set for these systems during specific time periods, such as working hours or peak business hours.
[0096] Unrestricted access systems are typically public, general-purpose systems or services, such as email systems and file-sharing systems. These systems provide basic service functions, and access demand is relatively stable, not fluctuating significantly due to changes in time of day or business scenarios. Therefore, these systems have no access restrictions at any time, allowing users to access the resources they need anytime, anywhere.
[0097] The formulas for calculating the popularity values of data items in the three categories of systems—systems with restricted access at all times, systems with restricted access for some times, and systems with unrestricted access—are as follows:
[0098] 1) If the system to which the data item belongs is the all-time access-restricted system, the popularity value of the data item shall be calculated according to the following formula: Popularity value = All-time access-restricted system access frequency * frequency weight + γ * time weight * 1 / (current time - most recent access time), where γ is a positive number less than 1.
[0099] 2) If the system to which the data item belongs is a system with restricted access during the specified time period, and the current time is within an unrestricted time period, the popularity value of the data item is calculated according to the following formula:
[0100] Popularity score = Access frequency of restricted systems during certain periods * Frequency weight + 1 / (Current time - Last access time) * Time weight;
[0101] If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within a restricted period, the popularity value of the data item is calculated according to the following formula:
[0102] Popularity value = Access frequency of restricted system during certain periods * frequency weight + δ(t) * time weight * 1 / (current time - most recent access time), where δ(t) is a time function, 0 ≤ t ≤ T, T is the restricted duration, and δ(0) > γ.
[0103] 3) If the system to which the data item belongs is the unrestricted system, calculate the popularity value of the data item according to the following formula:
[0104] Popularity value = Unrestricted system access frequency * Frequency weight + 1 / (Current time - Last access time) * Time weight.
[0105] The sum of the frequency weight and the time weight is 1.
[0106] Step 204: Determine the data items to be evicted based on the heat value of each data item in the cache queue.
[0107] For data items in the cache queue, they are sorted according to their popularity value. When it is necessary to delete data in the cache queue to free up space, data items with low popularity values are identified as data items to be evicted.
[0108] Step 205: Delete the data items to be evicted from the cache queue. This embodiment dynamically adjusts the K value by monitoring access changes of three types of systems in real time, thereby ensuring that the data items in the cache queue are always synchronized with the current access pattern, improving cache hit rate and system performance, and flexibly responding to the complex and ever-changing access needs of various systems in the platform. Moreover, this embodiment sets different weight coefficients according to the access restrictions of different types of systems to determine the data items to be evicted. By setting a lower weight coefficient for systems with restricted access at all times and a higher weight coefficient for systems with restricted access at some times and unrestricted access, it can ensure that the data items in the cache are more consistent with the actual access situation, effectively retaining data items in the cache queue that are highly likely to be accessed again in the future, significantly improving the cache hit rate of the resource evaluation system, and reducing the system performance degradation caused by cache misses.
[0109] The various methods of the embodiments of this application have been described above. Apparatus for implementing the above methods will now be provided.
[0110] like Figure 3 The image shows an embodiment of the cache management device of this application, comprising:
[0111] The first loading unit is used to load the data item into the access history queue when the data item is accessed for the first time.
[0112] The second loading unit is used to load the data item into the cache queue when the number of times the data item has been accessed in the access history queue is greater than or equal to a threshold K.
[0113] Furthermore, the device also includes:
[0114] The first determining unit is used to determine the popularity value of each data item in the cache queue when the cache eviction condition is met, wherein the popularity value of each data item is determined according to its system category; the system category includes: all-time access-restricted system, part-time access-restricted system, and access-unrestricted system;
[0115] The second determining unit is used to determine the data items to be evicted based on the heat value of each data item in the cache queue;
[0116] The deletion unit is used to delete the data items to be evicted from the cache queue.
[0117] Furthermore,
[0118] The first determining unit is further configured to:
[0119] If the system to which the data item belongs is the system with restricted access at all times, the popularity value of the data item is calculated according to the following formula:
[0120] Popularity score = Frequency of access to restricted systems throughout the day * Frequency weight + γ * Time weight * 1 / (Current time - Last access time), where γ is a positive number less than 1;
[0121] If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within an unrestricted period, the popularity value of the data item is calculated according to the following formula:
[0122] Popularity score = Access frequency of restricted systems during certain periods * Frequency weight + 1 / (Current time - Last access time) * Time weight;
[0123] If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within a restricted period, the popularity value of the data item is calculated according to the following formula:
[0124] Popularity value = Access frequency of restricted system during certain periods * frequency weight + δ(t) * time weight * 1 / (current time - most recent access time), where δ(t) is a time function, 0 ≤ t ≤ T, T is the restricted duration, and δ(0) > γ;
[0125] If the system to which the data item belongs is the unrestricted system, the heat value of the data item is calculated according to the following formula:
[0126] Popularity score = Unrestricted system access frequency * Frequency weight + 1 / (Current time - Last access time) * Time weight;
[0127] The sum of the frequency weight and the time weight is 1.
[0128] Furthermore, the device also includes:
[0129] The K-value adjustment unit is used to take the access parameters of each type of system in the current statistical period and calculate the average value of the access parameters in the historical statistical periods; wherein, the access parameters are the access frequency of each type of system or the proportion of the number of accesses of each type of system in all types of systems.
[0130] If the increase in the access parameter relative to the average value of the access parameter in the all-time access-restricted system is greater than a first threshold, the value of K is reduced.
[0131] If the increase in the access parameter of the unrestricted system relative to the average value of the access parameter is greater than a second threshold, the value of K is increased.
[0132] If, during a certain period of access restriction, the increase in the access parameter relative to the average value of the access parameter is greater than a third threshold, the value of K is reduced.
[0133] If, during a period of restricted access, the increase in the access parameter relative to the average value of the access parameter during an unrestricted access period exceeds a fourth threshold, the value of K is increased.
[0134] This application also provides an electronic device, such as... Figure 4 As shown, the electronic device includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the processor executes the program or instructions, the electronic device performs the cache management method provided in the embodiments of this application and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0135] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described cache management method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0136] This application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, they implement the various processes of the above-described cache management method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0137] 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 apparatus 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 apparatus. 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 apparatus that includes that element.
[0138] 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 this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0139] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A cache management method, characterized in that, The method includes: When a data item is accessed for the first time, the data item is loaded into the access history queue; When the number of times the data item is accessed in the access history queue is greater than or equal to the threshold K, the data item is loaded into the cache queue; The method further includes: When the cache eviction condition is met, the popularity value of each data item in the cache queue is determined. The popularity value of each data item is determined according to its system category. The system categories include: all-time access-restricted systems, part-time access-restricted systems, and unrestricted access systems. The data items to be evicted are determined based on the popularity value of each data item in the cache queue; Remove the data items to be evicted from the cache queue; Obtain the access parameters of each category of systems within the current statistical period, and calculate the average value of the access parameters over historical statistical periods; wherein, the access parameters are the access frequency of each category of systems or the proportion of the number of accesses of each category of systems to all categories of systems; If the increase in the access parameter relative to the average value of the access parameter in the all-time access-restricted system is greater than a first threshold, the value of K is reduced. If the increase in the access parameter of the unrestricted system relative to the average value of the access parameter is greater than a second threshold, the value of K is increased. If, during a certain period of access restriction, the increase in the access parameter relative to the average value of the access parameter is greater than a third threshold, the value of K is reduced. If, during a period of restricted access, the increase in the access parameter relative to the average value of the access parameter during an unrestricted access period exceeds a fourth threshold, the value of K is increased.
2. The method according to claim 1, characterized in that, Determining the popularity value of each data item in the cache queue includes: When the system to which the data item belongs is the all-time access-restricted system, the popularity value of the data item is calculated according to the following formula: Popularity value = All-time access-restricted system access frequency * Frequency weight + γ * Time weight * 1 / (Current time - Last access time), where γ is a positive number less than 1; If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within an unrestricted period, the popularity value of the data item is calculated according to the following formula: Popularity score = Access frequency of restricted systems during certain periods * Frequency weight + 1 / (Current time - Last access time) * Time weight; If the system to which the data item belongs is a system with restricted access during a certain period, and the current time is within a restricted period, the popularity value of the data item is calculated according to the following formula: Popularity value = Access frequency of restricted system during certain periods * Frequency weight + δ(t) * Time weight * 1 / (Current time - Last access time), where δ(t) is a time function, 0≤t≤T, T is the restricted duration, and δ(0)>γ; If the system to which the data item belongs is the unrestricted system, the heat value of the data item is calculated according to the following formula: Popularity score = Unrestricted system access frequency * Frequency weight + 1 / (Current time - Last access time) * Time weight; The sum of the frequency weight and the time weight is 1.
3. The method according to claim 1, characterized in that, The percentage of visits to each system category compared to all systems in all categories is calculated as follows: Get the number of visits to each category of systems within the current statistical period; Based on the number of visits to each type of system within the current statistical period, calculate the total number of visits to all types of systems within the current statistical period; The percentage of visits to each category of systems is calculated based on the ratio of the number of visits to each category of systems to the total number of visits to all categories of systems within the current statistical period.
4. The method according to claim 1, characterized in that, The first threshold is calculated based on a third preset ratio of the average value of the access parameters; The second threshold is calculated based on a fourth preset ratio of the average value of the access parameters; The third threshold is calculated based on a fifth preset ratio of the average value of the access parameters.
5. The method according to claim 1, characterized in that, The increase in the value of K includes at least one of the following: The value of K is increased according to a preset first fixed step size; Add the current value of K to ΔK1, where ΔK1 is the smaller of the product of the current value of K and the first preset ratio and the preset maximum increase. The reduction of the value of K includes at least one of the following: The value of K is decreased according to a preset second fixed step size; Subtract the current value of K from ΔK2, where ΔK2 is the smaller of the product of the current value of K and the second preset ratio and the preset maximum reduction magnitude.
6. The method according to claim 1, characterized in that, The time interval between two consecutive K value adjustments shall not be less than the preset minimum time interval.
7. A cache management device, characterized in that, The device includes: The first loading unit is used to load the data item into the access history queue when the data item is accessed for the first time. The second loading unit is used to load the data item into the cache queue when the number of times the data item has been accessed in the access history queue is greater than or equal to the threshold K. The first determining unit is used to determine the popularity value of each data item in the cache queue when the cache eviction condition is met, wherein the popularity value of each data item is determined according to its system category; the system category includes: all-time access-restricted system, part-time access-restricted system, and access-unrestricted system; The second determining unit is used to determine the data items to be evicted based on the heat value of each data item in the cache queue; A deletion unit is used to delete the data item to be evicted from the cache queue; The K-value adjustment unit is used to take the access parameters of each type of system in the current statistical period and calculate the average value of the access parameters in the historical statistical periods; wherein, the access parameters are the access frequency of each type of system or the proportion of the number of accesses of each type of system in all types of systems. If the increase in the access parameter relative to the average value of the access parameter in the all-time access-restricted system is greater than a first threshold, the value of K is reduced. If the increase in the access parameter of the unrestricted system relative to the average value of the access parameter is greater than a second threshold, the value of K is increased. If, during a certain period of access restriction, the increase in the access parameter relative to the average value of the access parameter is greater than a third threshold, the value of K is reduced. If, during a period of restricted access, the increase in the access parameter relative to the average value of the access parameter during an unrestricted access period exceeds a fourth threshold, the value of K is increased.
8. An electronic device, characterized in that, include: Processor, memory, and programs or instructions stored in said memory and executable on said processor; When the processor executes the program or instructions, it implements the steps of the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes computer instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1 to 6.