Cache management method and device, equipment, medium and product

By dynamically adjusting the cache lifetime by combining data access events and business attribute information in cache management, the problem that existing caching strategies cannot meet the needs of high-frequency data access is solved, and more efficient cache management and memory utilization are achieved.

CN121880397APending Publication Date: 2026-04-17JINGDONG TECH HLDG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINGDONG TECH HLDG CO LTD
Filing Date
2025-12-29
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing caching strategies are unable to meet the response requirements of high-frequency data access as business scales up and data dynamism increases, resulting in a mismatch between static rules and dynamic requirements, which affects access efficiency.

Method used

By responding to data requests, identifying data access events, updating data access popularity based on the business attribute information of data items, and dynamically adjusting cache lifetime based on data access popularity and cache space memory usage, more precise cache management can be achieved.

Benefits of technology

It provides a dynamic expiration and eviction policy that matches the data request scenario, meets the dynamic changes in data requirements in the data caching scenario, and improves the efficiency of cache management and memory utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121880397A_ABST
    Figure CN121880397A_ABST
Patent Text Reader

Abstract

The invention discloses a cache management method and device, equipment, a medium and a product, and the method comprises the steps: determining a data access event for a first data item in response to a data request; updating the data access popularity of the first data item according to the data access event and the service attribute information of the first data item; according to the data access popularity and the memory utilization rate of a first cache space where the first data item is located, the cache survival time of the first data item in the cache space is determined; and performing cache management on the first data item according to the cache survival time. According to the technical scheme, the problem that an existing cache data elimination strategy does not meet the service scene of high-frequency request data is solved, the data expiration elimination strategy matched with the data request scene can be provided, and the dynamic change of the data cache scene for the data requirement is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a cache management method, apparatus, device, medium, and product. Background Technology

[0002] During the operation of a service system, caching technology can reduce database load and shorten data access latency, supporting high-concurrency scenarios. Cached data expiration strategies mainly include uniformly set time-to-live (TTL) expiration policies, Least Recently Used (LRU) algorithms, and Least Frequently Used (LFU) algorithms. However, in implementing this invention, it was found that existing technologies have at least the following technical problems: as business scale expands and data dynamism increases, the static rules in traditional caching strategies do not match dynamic requirements, and are not user-friendly for frequently accessed data. Summary of the Invention

[0003] This invention provides a cache management method, apparatus, device, medium, and product.

[0004] In a first aspect, embodiments of the present invention provide a cache management method, the method comprising:

[0005] In response to a data request, determine the data access event for the first data item;

[0006] Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item;

[0007] The cache lifetime of the first data item in the cache space is determined based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0008] The first data item is cached based on its cache lifetime.

[0009] Secondly, embodiments of the present invention also provide a cache management device, the device comprising:

[0010] The data request processing module is used to respond to a data request and determine the data access event for the first data item;

[0011] The cached data popularity update module is used to update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item.

[0012] The cached data lifetime adjustment module is used to determine the cache lifetime of the first data item in the cache space based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0013] The cache data management module is used to manage the cache of the first data item based on its cache lifetime.

[0014] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a cache management method as described in any of the embodiments of the present invention.

[0015] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the cache management method as described in any of the embodiments of the present invention.

[0016] Fifthly, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the cache management method as described in any of the embodiments of the present invention.

[0017] In this embodiment of the invention, a data access event for a first data item is determined in response to a data request; the data access popularity of the first data item is updated based on the data access event and the business attribute information of the first data item; the cache lifetime of the first data item in the cache space is determined based on the data access popularity and the memory usage rate of the first cache space where the first data item resides; and cache management of the first data item is performed based on the cache lifetime. The technical solution of this embodiment of the invention solves the problem that existing cached data eviction strategies do not meet the needs of business scenarios with high-frequency data requests, and can provide a data expiration eviction strategy that matches the data request scenario, satisfying the dynamic changes in data requirements of the data caching scenario. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A flowchart of a cache management method provided in an embodiment of the present invention;

[0020] Figure 2 A flowchart illustrating yet another cache management method provided in this embodiment of the invention;

[0021] Figure 3 A flowchart illustrating yet another cache management method provided in an embodiment of the present invention;

[0022] Figure 4 A timing diagram illustrating an application example of a cache management method provided in an embodiment of the present invention;

[0023] Figure 5 This is a schematic diagram of the structure of a cache management device provided in an embodiment of the present invention;

[0024] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0025] The present invention will now be described in further detail 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 not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0026] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. The acquisition, storage, use, and processing of data in the technical solutions of this application all comply with the relevant provisions of national laws and regulations.

[0027] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the relevant content of the solution.

[0028] Figure 1 This is a flowchart illustrating a cache management method provided in an embodiment of the present invention. This embodiment is applicable to scenarios where cached data is managed during the operation of a business system. The method can be executed by a cache management device, which can be implemented in software and / or hardware and integrated into a computer device.

[0029] like Figure 1 As shown, the cache management method includes the following steps:

[0030] S110. In response to a data request, determine a data access event for the first data item.

[0031] In this context, a data request can be a data request initiated by the client to the server in any business scenario; it can also be a data request initiated by one party with data needs to another party when different service providers are exchanging data.

[0032] To reduce duplicate requests to the database, lower service load, and improve data request response speed, data providers typically cache some data in a data cache space. This allows them to directly retrieve the corresponding response data from the cache space and send it back to the requesting party.

[0033] The data in the data cache space can be frequently accessed static data, frequently personalized user data, hot data in high-concurrency scenarios, or data that will be reused in weak network or offline scenarios. The data cache space can be used in business scenarios where there is high-concurrency data access.

[0034] The first data item can be a cached data item in the data cache space, and is the data item requested by the data request. Each time a data request for the first data item is obtained, a data access event for the first data item can be recorded. The information corresponding to the data access event includes the request time of the data request, that is, the time when the data access event occurred, and the cumulative access count of the first data item can be incremented by one.

[0035] S120. Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item.

[0036] Among them, data access popularity is an indicator that measures how frequently data is accessed. It can be used to distinguish between "hot data" and "cold data" so that this parameter can be used to guide the optimization and allocation of resources such as caching and storage.

[0037] The number of times a data item is accessed is positively correlated with its access popularity. In other words, the more times a data item is accessed, the higher its access popularity.

[0038] One data access event corresponds to one data access. The accumulated data access events of the first data item over a preset time period can be counted as one of the parameters for determining the data access popularity of the first data item.

[0039] In this embodiment, in addition to the number of data accesses, the business attribute information of the first data item is also considered in determining its access popularity. Business attribute information can be attribute values ​​assigned to data based on core business objectives in multi-dimensional popularity calculations. This allows popularity calculations to not solely rely on access frequency but also adjust the importance ranking of data based on business priorities. For example, business attribute information could be the business scenario in which the first data item is used; business data in different business scenarios have different business weights, and different data access popularity impact values ​​can be set. Business attribute information could also be the users associated with the first data item; different user levels can also correspond to different business weights, setting different data access popularity impact values. Business attribute information could also be the data timeliness requirement level corresponding to the first data item.

[0040] A mapping relationship between data access events and business attribute information and data access popularity can be pre-built, and the updated data access popularity of the first data item can be calculated based on this mapping relationship.

[0041] In one optional implementation, the process of updating the data access popularity of the first data item based on the data access event and the business attribute information of the first data item may include the following steps:

[0042] Step 1: Update the access frequency of the first data item within the preset time window based on the data access events.

[0043] The preset time window can correspond to a preset duration. Using the preset duration as the time unit, the data access events of the first data item are counted to determine the access frequency of the first data item within the preset time window.

[0044] When calculating access frequency, a sliding window statistical method can be used, where the width of the sliding window is the duration of the preset time window.

[0045] Step 2: Determine the time decay factor of the data access event based on the timestamp of the data access event.

[0046] The occurrence time of a data access event can be determined based on its timestamp. Then, a time decay factor can be determined based on the time difference between the event's occurrence and the time used to calculate access popularity. This means assigning weights based on time proximity, preventing historical data from excessively influencing current decisions. This ensures that recent access events contribute more to the current popularity of the first data item than older access events, thus more accurately reflecting the real-time access value of the data.

[0047] Step 3: Perform a weighted calculation on the information values ​​of access frequency, time decay factor, and business attribute information to obtain the updated data access popularity of the first data item.

[0048] Data access popularity can be used Indicates. Specifically, The calculation process can be represented as:

[0049] .in, , and Access frequency Business attribute information and time decay factor Configurable weighting coefficients. , and The default value can be obtained through optimization algorithms such as gradient descent, or it can be the result of empirical configuration. This is a configurable decay rate parameter. The average time decay factor of all data access events within a preset time window can be determined. Assume the event decay factor for each data access event within the preset time window can be expressed as... , Indicates the timestamp of the corresponding data access event. Time since data access popularity was calculated The time difference between them. It can then be expressed as .

[0050] In this embodiment, the cache management device maintains a sliding event window to statistically calculate the access frequency of cross-data items for each cached data item.

[0051] S130. Determine the cache lifetime of the first data item in the cache space based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0052] The first cache space can be a data cache space in the heap memory. The memory utilization rate of the first data item in the first cache space reflects the proportion of currently used heap memory to the total available heap memory.

[0053] When memory utilization reaches a high level, garbage collection of cached data can usually alleviate memory pressure. For example, a uniform TTL (time to live) can be set for cached data to reclaim expired data. However, a uniform TTL does not distinguish between hot and cold data. High-frequency hot data (such as flash sale items) may cause cache penetration due to premature expiration, while low-frequency cold data (such as historical orders) may occupy memory for a long time, resulting in memory waste and low memory utilization.

[0054] In this embodiment, a cache lifetime matching the access frequency can be determined for each first data item from the perspective of cached data items. The goal is to give frequently accessed hot data a relatively long lifetime and infrequently accessed cold data a relatively short cache lifetime.

[0055] A lifetime adjustment factor can be determined based on the access frequency of the first data item and the memory usage of the first cache space containing the first data item. This factor is used to adjust the cache lifetime of the first data item. The determining factors for the lifetime adjustment factor are the access frequency and memory usage. In the numerical relationship between the access frequency and memory usage and the lifetime adjustment factor, the higher the access frequency, the larger the lifetime adjustment factor; conversely, the higher the memory usage, the smaller the lifetime adjustment factor. Any function or mapping method that satisfies this numerical relationship is acceptable.

[0056] In one optional implementation, the cache lifetime of the first data item in the cache space is determined based on the data access frequency and the memory usage rate of the first cache space where the first data item resides. This can be achieved by first determining the first memory pressure value corresponding to the memory usage rate of the cache space where the first data item resides, based on the mapping relationship between memory usage rate and memory pressure value. Then, a lifetime adjustment coefficient value is determined based on the natural logarithm of the data access frequency and the first memory pressure value. Finally, the preset data cache lifetime of the first data item is adjusted using the lifetime adjustment coefficient value to determine the cache lifetime of the first data item in the cache space. This can be expressed by the formula: .

[0057] in, The basic lifespan preset for the business, that is, the preset uniform lifespan. This indicates that the natural logarithm (or common logarithm, if specified) of the popularity value is taken to smooth out the impact of high popularity values ​​and prevent the TTL from increasing indefinitely. MemoryPressure is a normalized memory pressure value (range 0~1), obtained by real-time monitoring of JVM heap memory usage (or other operating system memory metrics). The larger the MemoryPressure (closer to 1), the more strained the memory is, and the shorter the calculated TTL will be, prompting low-value data to be evicted more quickly. The calculated TTL will be limited to a preset minimum value. and maximum value between.

[0058] S140. Perform cache management on the first data item based on the cache lifetime.

[0059] When the cache lifetime of the first data item expires, the first data item will be cleared from the first cache space.

[0060] It is understandable that the cache lifetime of the first data item can be dynamically updated as its corresponding data access event occurs.

[0061] The technical solution of this invention, in response to a data request, determines a data access event for a first data item; updates the data access popularity of the first data item based on the data access event and the business attribute information of the first data item; determines the cache lifetime of the first data item in the cache space based on the data access popularity and the memory usage rate of the first cache space where the first data item resides; and performs cache management on the first data item based on the cache lifetime. This technical solution addresses the problem that existing cached data eviction policies do not meet the needs of business scenarios with high-frequency data requests, and can provide a data expiration eviction policy that matches the data request scenario, satisfying the dynamic changes in data requirements of the data caching scenario.

[0062] Figure 2 This is a flowchart illustrating a cache management method provided in an embodiment of the present invention. This embodiment is applicable to scenarios involving the management of cached data, and further describes the process of responding to data requests and providing data lookup feedback, based on the above embodiment. This method can be executed by a cache management device, implemented in software and / or hardware, and integrated into a computer device.

[0063] like Figure 2 As shown, the cache management method includes the following steps:

[0064] S210. In response to the data request, search for the first data item in the first cache space.

[0065] After receiving the data request, the system will look up the corresponding value based on the key of the data object requested in the data request, and then return the data to the requester.

[0066] The first cache space can be the data cache space in the heap memory, such as the Caffeine implementation, which can quickly respond to data requests and is suitable for high-frequency, small-data, low-latency scenarios.

[0067] S220. In response to the first data item not being found in the first cache space, the first data item is searched in the second cache space.

[0068] In this embodiment, a multi-level cache space can be set up. The second cache space can be the cache space corresponding to off-heap memory and / or the cache space corresponding to disk memory. Of course, the cache space corresponding to disk memory can also be used as the third cache space.

[0069] If the first data item is not found in the first cache space, it can be searched in the second cache space.

[0070] S230. In response to finding the first data item in the second cache space, the first data item is migrated to the first cache space based on the updated data access popularity of the first data item and the memory usage rate of the first cache space.

[0071] The updated access popularity of the first data item can be calculated using the access popularity calculation method provided in the above embodiments. When the updated access popularity of the first data item is greater than a preset access popularity threshold and the memory utilization rate of the first cache space is within a preset safe utilization rate range, the first data item can be migrated to the first cache space. A new TTL, determined based on its updated data access popularity and the memory utilization rate of the first cache space, can also be set for the first data item migrated to the first cache space.

[0072] In addition, if the first data item is not found in the second cache space, the data can be loaded from the corresponding database (external data source), and the newly loaded data can be placed into the first cache space, with an initial dynamic TTL set for it.

[0073] S240, Determine the data access event for the first data item.

[0074] S250. Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item.

[0075] S260. Determine the cache lifetime of the first data item in the cache space based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0076] S270. Perform cache management on the first data item based on the cache lifetime.

[0077] The technical solution of this invention, in response to a data request, searches for a first data item in a first cache space; if the first data item is not found in the first cache space, searches for the first data item in a second cache space; if the first data item is found in the second cache space, the first data item is migrated to the first cache space based on its updated data access popularity and the memory usage of the first cache space; a data access event for the first data item is determined; the data access popularity of the first data item is updated based on the data access event and the business attribute information of the first data item; the cache lifetime of the first data item in the cache space is determined based on the data access popularity and the memory usage of the first cache space where the first data item is located; and cache management of the first data item is performed based on the cache lifetime. This technical solution solves the problem that existing cached data eviction strategies do not meet the needs of business scenarios with high-frequency data requests, and can provide a data expiration eviction strategy that matches the data request scenario, satisfying the dynamic changes in data requirements of the data caching scenario.

[0078] Figure 3 This is a flowchart illustrating a cache management method provided in an embodiment of the present invention. Based on the above embodiments, this embodiment further describes a cache management strategy based on memory pressure. This method can be executed by a cache management device, implemented in software and / or hardware, and integrated into a computer device.

[0079] like Figure 3 As shown, the cache management method includes the following steps:

[0080] S310. In response to a data request, determine a data access event for the first data item.

[0081] S320. Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item.

[0082] S330. Determine the cache lifetime of the first data item in the cache space based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0083] S340. Perform cache management on the first data item based on the cache lifetime.

[0084] S350, in response to the memory usage rate in the first usage rate range, manage the cached data items in the first cache space using the least recently used strategy; and / or, calculate the data access heat of each cached data item in the first cache space, and migrate the cached data items whose data access heat is less than the first heat threshold to the second cache space.

[0085] The first utilization range can be a memory utilization range where the memory pressure is relatively high but does not affect normal operation, such as a memory utilization range of 70%-90%. It can also be other values ​​corresponding to the 70%-90% range, or a utilization range that includes the 70%-90% range.

[0086] When the memory usage of the first cache space enters the first usage range, the pressure relief mode can be activated. A least recently used strategy is employed to manage cached data items in the first cache space; if a cached data item has not been accessed recently, its probability of being accessed in the future is also low, and it is prioritized for eviction.

[0087] It can also calculate the data access popularity of cached data items in the first cache space according to a preset period, and migrate cached data items whose data access popularity is less than the first popularity threshold to the second cache space, that is, actively perform data degradation caching to reduce the garbage collection pressure of JVM (Java Virtual Machine).

[0088] S360, in response to the memory usage rate being greater than the upper limit threshold of the first usage rate range, delete cached data items in the first cache space whose data access popularity is less than the second popularity threshold.

[0089] If memory usage exceeds the upper threshold of the first usage range, it indicates that the cache pressure on the first cache space is at a high level, triggering an emergency release mode to alleviate the pressure on the first cache space. This means that cached data items in the first cache space with access frequency below a second access frequency threshold (where the second access frequency threshold is higher than the first access frequency threshold) can be forcibly evicted. Asynchronous log alerts can also be triggered to notify operations and maintenance personnel.

[0090] The technical solution of this invention, in response to a data request, determines a data access event for a first data item; updates the data access popularity of the first data item based on the data access event and the business attribute information of the first data item; determines the cache lifetime of the first data item in the cache space based on the data access popularity and the memory usage rate of the first cache space where the first data item is located; performs cache management on the first data item based on the cache lifetime; manages the cached data items in the first cache space using a least recently used strategy in response to the memory usage rate being in a first usage rate range; and / or calculates the data access popularity of each cached data item in the first cache space, and migrates cached data items with a data access popularity less than a first popularity threshold to a second cache space. This technical solution solves the problem that existing cached data eviction strategies do not meet the needs of business scenarios with high-frequency data requests. It can provide a data expiration eviction strategy that matches the data request scenario, meeting the dynamic changes in data demand in the data caching scenario. Based on the real-time access popularity and memory pressure of the cached data items, it dynamically upgrades or downgrades the cache in the first and second cache spaces.

[0091] Furthermore, Figure 4 A sequence diagram is shown for an application example of a cache management method.

[0092] Specifically, in Figure 4 In this framework, L1 cache and L2 cache refer to the first cache space and the second cache space, respectively. The L1 cache (Level 1 Cache) can be built based on a high-performance on-heap cache (such as Caffeine implementation) and is used to store frequently accessed data. The L2 cache (Level 2 Cache) can be built based on off-heap memory or disk cache (such as MapDB implementation) and is used to store moderately accessed data or data degraded from L1, aiming to reduce JVM garbage collection (GC) pressure. The adaptive caching SDK can be a toolkit that implements the cache management methods described above.

[0093] When a client sends a data query request to the server, the adaptive caching SDK responds by first accessing the L1 cache. If the L1 cache finds the target data item, it updates the access frequency of that data item and returns the result. If the L1 cache misses, it queries the L2 cache. If the L2 cache hits, it updates the access frequency of that data item. Based on the updated access frequency and the memory state of the corresponding L1 cache, the found data item may be upgraded back to the L1 cache (with a new dynamic TTL set), and the result is returned to the client. If the L2 cache also misses, it loads data from an external data source (such as a database). The newly loaded data is placed into the L1 cache (with an initial dynamic TTL set). The result is then returned.

[0094] In addition, a scheduled task can be configured, i.e., a periodic background task, to recalculate the dynamic TTL of all (or sampled) cached data items based on the latest Heat(t) and MemoryPressure, and update the cache accordingly. Under memory pressure, a degradation migration of low-hot data from L1 to L2 can be performed. When updating cached data items in the cache space, the L1 cache can be updated first (if the L1 cache utilization is at an normal operating level), and its TTL can be reset. Depending on the configuration policy, the L2 cache can also be updated synchronously or asynchronously.

[0095] Figure 5 This is a schematic diagram of the cache management device provided in an embodiment of the present invention, showing the applicable scenarios. The device can be implemented in software and / or hardware and integrated into a computer device.

[0096] like Figure 5 As shown, the cache management device includes: a data request processing module 510, a cache data hot update module 520, a cache data lifespan adjustment module 530, and a cache data management module 540.

[0097] The data request processing module 510 is used to respond to a data request and determine a data access event for the first data item; the cached data popularity update module 520 is used to update the data access popularity of the first data item according to the data access event and the business attribute information of the first data item; the cached data lifetime adjustment module 530 is used to determine the cache lifetime of the first data item in the cache space according to the data access popularity and the memory usage rate of the first cache space where the first data item is located; and the cached data management module 540 is used to perform cache management on the first data item according to the cache lifetime.

[0098] The technical solution of this invention, in response to a data request, determines a data access event for a first data item; updates the data access popularity of the first data item based on the data access event and the business attribute information of the first data item; determines the cache lifetime of the first data item in the cache space based on the data access popularity and the memory usage rate of the first cache space where the first data item resides; and performs cache management on the first data item based on the cache lifetime. This technical solution addresses the problem that existing cached data eviction policies do not meet the needs of business scenarios with high-frequency data requests, and can provide a data expiration eviction policy that matches the data request scenario, satisfying the dynamic changes in data requirements of the data caching scenario.

[0099] In one optional implementation, the cached data popularity update module 520 is specifically used for:

[0100] Update the access frequency of the first data item within a preset time window based on data access events;

[0101] Determine the time decay factor of the data access event based on the timestamp of the data access event;

[0102] The updated data access popularity of the first data item is obtained by weighting the access frequency, time decay factor and business attribute information values.

[0103] In one optional implementation, the cached data lifetime adjustment module 530 is specifically used for:

[0104] Based on the mapping relationship between memory utilization and memory pressure value, determine the first memory pressure value corresponding to the memory utilization of the cache space where the first data item is located;

[0105] The lifetime adjustment factor is determined based on the natural logarithm of data access popularity and the first memory pressure value.

[0106] The preset data cache lifetime of the first data item is adjusted by adjusting the lifetime adjustment coefficient value to determine the cache lifetime of the first data item in the cache space.

[0107] In an optional implementation, the data request processing module 510 may also be used to:

[0108] In response to a data request, locate the first data item in the first cache space;

[0109] In response to the first data item not being found in the first cache space, the first data item is searched in the second cache space;

[0110] In response to finding the first data item in the second cache space, the first data item is migrated to the first cache space based on the updated data access frequency of the first data item and the memory usage of the first cache space.

[0111] In one optional implementation, the first cache space is the cache space corresponding to the heap memory, and the second cache space is the cache space corresponding to the off-heap memory and / or the cache space corresponding to the disk memory.

[0112] In an alternative implementation, the cache data management module 540 can also be used for:

[0113] In response to a memory usage rate within a first usage range, a least recently used strategy is employed to manage cached data items in the first cache space; and / or,

[0114] Calculate the data access popularity of each cached data item in the first cache space, and migrate cached data items whose data access popularity is less than the first popularity threshold to the second cache space.

[0115] In an alternative implementation, the cache data management module 540 can also be used for:

[0116] In response to a memory usage rate exceeding the upper limit of the first usage rate range, cached data items in the first cache space whose data access frequency is less than the second access frequency threshold are deleted.

[0117] The second popularity threshold is greater than the first popularity threshold.

[0118] The cache management device provided in the embodiments of the present invention can execute the cache management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0119] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 6 A block diagram of an exemplary computer device 12 suitable for implementing embodiments of the present invention is shown. Figure 6 The computer device 12 shown is merely an example and should not be construed as limiting the functionality or scope of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capabilities, such as intelligent controllers and servers, mobile phones, and other terminal devices.

[0120] like Figure 6 As shown, the computer device 12 is represented in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0121] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0122] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0123] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 6 Not shown; usually referred to as a "hard drive"). Although Figure 6 As not shown, disk drives for reading and writing to removable non-volatile disks (e.g., "floppy disks") and optical disc drives for reading and writing to removable non-volatile optical discs (e.g., CD-ROMs, DVD-ROMs, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0124] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0125] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the computer device 12, and / or with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that, although... Figure 6 As not shown, it can be used in conjunction with computer device 12 with other hardware and / or software modules, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0126] Processing unit 16 executes various functional applications and data processing by running programs stored in system memory 28, such as implementing the cache management method provided in this embodiment, which includes:

[0127] In response to a data request, determine the data access event for the first data item;

[0128] Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item;

[0129] The cache lifetime of the first data item in the cache space is determined based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0130] The first data item is cached based on its cache lifetime.

[0131] This embodiment provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the program implements the cache management method provided in any embodiment of the present invention, the method comprising:

[0132] In response to a data request, determine the data access event for the first data item;

[0133] Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item;

[0134] The cache lifetime of the first data item in the cache space is determined based on the data access frequency and the memory usage rate of the first data item in the first cache space.

[0135] The first data item is cached based on its cache lifetime.

[0136] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0137] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0138] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0139] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0140] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0141] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the methods provided in any embodiment of this application.

[0142] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0143] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

[0144] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A cache management method characterized by, include: In response to a data request, determine the data access event for the first data item; Update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item; The cache lifetime of the first data item in the cache space is determined based on the data access popularity and the memory usage rate of the first data item in the first cache space. The first data item is cached based on the cache lifetime.

2. The method of claim 1, wherein, The step of updating the data access popularity of the first data item based on the data access event and the business attribute information of the first data item includes: Based on the data access events, update the access frequency of the first data item within a preset time window; The time decay factor of the data access event is determined based on the timestamp of the data access event. The updated data access popularity of the first data item is obtained by weighting the access frequency, the time decay factor, and the information value of the business attribute information.

3. The method according to claim 1, characterized in that, Determining the cache lifetime of the first data item in the cache space based on the data access popularity and the memory usage rate of the first data item in the first cache space includes: Based on the mapping relationship between memory utilization and memory pressure value, determine the first memory pressure value corresponding to the memory utilization of the cache space where the first data item is located; The survival time adjustment coefficient value is determined based on the natural logarithm of the data access popularity and the first memory pressure value; The preset data cache lifetime of the first data item is adjusted by the lifetime adjustment coefficient value to determine the cache lifetime of the first data item in the cache space.

4. The method according to claim 1, characterized in that, Also includes: In response to a data request, the first data item is located in the first cache space; In response to the first data item not being found in the first cache space, the first data item is searched in the second cache space; In response to finding the first data item in the second cache space, the first data item is migrated to the first cache space based on the updated data access popularity of the first data item and the memory usage of the first cache space.

5. The method according to claim 4, characterized in that, The first cache space is the cache space corresponding to the heap memory, and the second cache space is the cache space corresponding to the off-heap memory and / or the cache space corresponding to the disk memory.

6. The method according to any one of claims 1-5, characterized in that, Also includes: In response to the memory usage rate in the first usage range, a least recently used strategy is adopted to manage the cached data items in the first cache space; And / or, Calculate the data access popularity of each cached data item in the first cache space, and migrate cached data items with data access popularity less than the first popularity threshold to the second cache space.

7. The method according to claim 6, characterized in that, Also includes: In response to the memory usage rate being greater than the upper limit threshold of the first usage rate range, cached data items in the first cache space whose data access popularity is less than the second popularity threshold are deleted; Wherein, the second heat threshold is greater than the first heat threshold.

8. A cache management device, characterized in that, include: The data request processing module is used to respond to a data request and determine the data access event for the first data item; The cached data popularity update module is used to update the data access popularity of the first data item based on the data access event and the business attribute information of the first data item. The cache data lifetime adjustment module is used to determine the cache lifetime of the first data item in the cache space based on the data access popularity and the memory usage rate of the first data item in the first cache space. The cache data management module is used to manage the cache of the first data item according to the cache lifetime.

9. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the cache management method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the cache management method as described in any one of claims 1-7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the cache management method as described in any one of claims 1-7.