Cache management method, system and equipment and storage medium
By dynamically updating the weight value based on factors such as access frequency, timestamp and delay time in cache management, and performing elimination operations when the cache space usage is high, the problem of low cache management accuracy in the existing technology is solved and the cache data is improved access rate and management efficiency.
Patent Information
- Application Number
- CN202411466479.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-07
AI Technical Summary
When the existing cache management method handles heterogeneous data cache scenarios, the management accuracy is low and the periodic changes in the importance of cached data cannot be effectively handled, resulting in data with reduced importance not being eliminated, occupying memory, and reducing the importance to a higher degree of importance. access rate of cached data.
When receiving the elimination trigger instruction, various types of updates of weight values are performed based on the access frequency, access timestamp, read operation delay time and data volume of the library table, including frequency update, delay update and time aging update, and dynamically adjust the weights. and perform library table deletion operations based on the elimination score sort when cache space usage is greater than the threshold.
Improve the accuracy of cache management, ensure efficient management of cached data in different time periods, avoid the risk of declining cache hit rate caused by excessive changes in weight values, and improve the access rate of important data.
Smart Images

Figure CN119271714A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data cache technology, and in particular to a cache management method, system, device and storage medium. Background Art
[0002] As users' demand for data access speed increases, cache technology has been widely used. When the amount of cached data is too large, it will occupy the memory of the high-speed storage, resulting in a decrease in the access rate of the cached data. Therefore, it is necessary to manage the cached data to ensure the access rate of the cached data.
[0003] With the increase in heterogeneous data caching scenarios, the management accuracy of traditional cache data management methods based on access times or access intervals has decreased. Therefore, most existing cache management methods are based on traditional cache data management methods, and set fixed weights according to the importance of different structured data, thereby reducing the risk of cache data with higher weight values being eliminated and improving management accuracy. However, since the importance of cache data has a periodic characteristic, that is, cache data with higher importance in one time period will have lower importance in another time period, if cache data management is still based on fixed weights, the cache data with lower importance will not be eliminated, occupying memory, thereby reducing the access rate of cache data with higher importance. It can be seen that the existing cache management method still has the problem of low management accuracy. Summary of the invention
[0004] In view of the above problems, the present application provides a cache management method, system, device and storage medium to achieve the purpose of improving the accuracy of cache management. The specific scheme is as follows:
[0005] The first aspect of the present application provides a cache management method, comprising:
[0006] When an elimination trigger instruction is received, at least based on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table, an update operation is performed on the weight value of each library table to obtain the updated weight value of each library table, and each library table in the cache is managed based on the updated weight value, wherein the access timestamp is the timestamp of the last access to the library table within the monitoring period before the elimination trigger instruction is received.
[0007] In a possible implementation, the update operation includes: frequency update, delay update and time aging update, and the weight value of each library table is updated based on the access frequency, access timestamp, read operation delay time and library table data volume of each library table to obtain the updated weight value of each library table, including:
[0008] At least based on the library table data volume and the access frequency of the target library table, the weight value of the target library table is updated with the frequency, and the weight value of the target library table after the frequency update is obtained, wherein the target library table is any one of the library tables in the cache;
[0009] Performing the delayed update on the weight value after the frequency update at least based on the library table data volume of the target library table and the read operation delay duration, to obtain the weight value of the target library table after the delayed update;
[0010] The time aging update is performed on the weight value after the delayed update based at least on the library table data volume and the access timestamp of the target library table to obtain the updated weight value of the target library table.
[0011] In a possible implementation, before managing each of the library tables in the cache based on the updated weight value, the method further includes:
[0012] According to the updated weight value W of each library table i i (t), through the formula: Obtain the updated weight value W of each library table i after normalization processing i '(t),W i (t) Wherein, t is the time of receiving the elimination trigger instruction, and n is the total number of the library tables.
[0013] In a possible implementation, managing each of the library tables in the cache based on the updated weight value includes:
[0014] According to the updated weight value W after normalization of each library table i i '(t), the receiving time t and the access timestamp T(t), by the formula: Obtain the elimination score S of each library table i i (t), and when the cache space utilization rate is greater than a preset threshold, a library table deletion operation is performed based on the sorting of the elimination score and the amount of library table data, wherein the λ is a positive number used to eliminate time interference items, and the cache space utilization rate is the occupancy rate of the total amount of library table data to the memory.
[0015] In a possible implementation, the frequency updating of the weight value of the target library table based at least on the library table data volume and the access frequency of the target library table to obtain the weight value of the target library table after the frequency update includes:
[0016] According to the library table data volume S and the access frequency A(t), by formula: Obtain a weight value W'(t) after the frequency update, wherein α is a preset frequency growth factor, t is the reception time of the elimination trigger instruction, t-1 is a time before the reception time t, and W(t-1) is the weight value of the target library table that has not undergone the frequency update at time t-1.
[0017] In a possible implementation, performing the delayed update on the weight value after the frequency update based at least on the library table data volume and the read operation delay duration of the target library table to obtain the weight value of the target library table after the delayed update includes:
[0018] According to the library table data volume S and the read operation delay time D(t), the formula is: Obtain the weight value W'(t) after the delay update, wherein t is the reception time of the elimination trigger instruction, W(t) is the weight value after the frequency update, β is the preset time attenuation factor, and T delay is the preset delay time.
[0019] In a possible implementation, performing the time aging update on the weight value after the delayed update based at least on the library table data volume and the access timestamp of the target library table to obtain the updated weight value of the target library table includes:
[0020] According to the library table data volume S and the access timestamp T(t), by formula: Obtain the updated weight value W'(t), wherein t is the time when the elimination trigger instruction is received, W(t) is the weight value after the delay update, and T max is the preset maximum aging time, and γ is the preset aging factor.
[0021] A second aspect of the present application provides a cache management system, wherein the cache management system is configured to:
[0022] When an elimination trigger instruction is received, at least based on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table, an update operation is performed on the weight value of each library table to obtain the updated weight value of each library table, and each library table in the cache is managed based on the updated weight value, wherein the access timestamp is the timestamp of the last access to the library table within the monitoring period before the elimination trigger instruction is received.
[0023] In a possible implementation, the cache management system updates the weight value of each library table based on the access frequency, access timestamp, read operation delay time and library table data volume of each library table, and the updated weight value of each library table is set to:
[0024] The update operation includes: frequency update, delay update and time aging update;
[0025] At least based on the library table data volume and the access frequency of the target library table, the weight value of the target library table is updated with the frequency, and the weight value of the target library table after the frequency update is obtained, wherein the target library table is any one of the library tables in the cache;
[0026] Performing the delayed update on the weight value after the frequency update at least based on the library table data volume of the target library table and the read operation delay duration, to obtain the weight value of the target library table after the delayed update;
[0027] The time aging update is performed on the weight value after the delayed update based at least on the library table data volume and the access timestamp of the target library table to obtain the updated weight value of the target library table.
[0028] In a possible implementation, the cache management system is further configured to:
[0029] According to the updated weight value W of each library table i i (t), through the formula: Obtain the updated weight value W of each library table i after normalization processing i '(t),W i (t) Wherein, t is the time of receiving the elimination trigger instruction, and n is the total number of the library tables.
[0030] In a possible implementation, the cache management system is configured to manage each of the library tables in the cache based on the updated weight value as follows:
[0031] According to the updated weight value W after normalization of each library table i i '(t), the receiving time t and the access timestamp T(t), by the formula: Obtain the elimination score S of each library table i i(t), and when the cache space utilization rate is greater than a preset threshold, a library table deletion operation is performed based on the sorting of the elimination score and the amount of library table data, wherein the λ is a positive number used to eliminate time interference items, and the cache space utilization rate is the occupancy rate of the total amount of library table data to the memory.
[0032] In a possible implementation, the cache management system performs the frequency update on the weight value of the target library table based at least on the library table data volume and the access frequency of the target library table, and when obtaining the weight value of the target library table after the frequency update, is set to:
[0033] According to the library table data volume S and the access frequency A(t), by formula: Obtain a weight value W'(t) after the frequency update, wherein α is a preset frequency growth factor, t is the reception time of the elimination trigger instruction, t-1 is a time before the reception time t, and W(t-1) is the weight value of the target library table that has not undergone the frequency update at time t-1.
[0034] In a possible implementation, the cache management system performs the delayed update on the weight value updated at the frequency based at least on the library table data volume of the target library table and the read operation delay duration, and when obtaining the weight value of the target library table after the delayed update, is set to:
[0035] According to the library table data volume S and the read operation delay time D(t), the formula is: Obtain the weight value W'(t) after the delay update, wherein t is the reception time of the elimination trigger instruction, W(t) is the weight value after the frequency update, β is the preset time attenuation factor, and T delay is the preset delay time.
[0036] In a possible implementation, the cache management system performs the time aging update on the weight value after the delayed update based on at least the library table data volume and the access timestamp of the target library table, and is set to:
[0037] According to the library table data volume S and the access timestamp T(t), by formula: Obtain the updated weight value W'(t), wherein t is the time when the elimination trigger instruction is received, W(t) is the weight value after the delay update, and T max is the preset maximum aging time, and γ is the preset aging factor.
[0038] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0039] The memory is used to store computer programs;
[0040] The processor is used to execute the computer program so that the electronic device can implement the cache management method of the above-mentioned first aspect or any implementation manner of the first aspect.
[0041] A fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the cache management method of the first aspect or any implementation of the first aspect.
[0042] By means of the above technical scheme, the cache management method, system, device and storage medium provided by the present application are configured to perform various types of updates on the weight values of each library table based at least on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table when receiving an elimination trigger instruction. While avoiding the risk of a decrease in cache hit rate due to excessive changes in the weight values of the library tables, the updated weight values fully consider the impact of different time periods on the weight values, realize dynamic adjustment of the weight values of the library tables, and improve the setting accuracy of the weight values. Furthermore, by configuring the management of each library table in the cache based on the updated weight values of each library table, the accuracy of managing the cache in different time periods is improved. It can be seen that the present application improves the accuracy of cache management. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0044] Figure 1 A flowchart of a cache management method provided by this application;
[0045] Figure 2 A flowchart of a cache management method provided for a possible implementation of the present application;
[0046] Figure 3 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0047] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0048] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0049] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0050] The first aspect of the present application provides a cache management method, such as Figure 1 As shown, the cache management method includes:
[0051] S101. When receiving an elimination trigger instruction, at least based on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table, update the weight value of each library table to obtain the updated weight value of each library table, and manage each library table in the cache based on the updated weight value, wherein the access timestamp is the timestamp when the library table was last accessed during the monitoring period before the elimination trigger instruction is received.
[0052] It should be noted that, in actual application scenarios, the elimination trigger instruction may be an instruction to eliminate cache data sent by operation and maintenance personnel through a terminal, or may be an instruction periodically sent by a timer deployed on the terminal.
[0053] It should be noted that, in actual application scenarios, the above-mentioned library table is a data table for storing the relationship between a database and the cache data stored therein. When a user reads cache data, the cache data to be read and the database where it is located need to be determined through the library table.
[0054] It should be noted that in actual application scenarios, the above-mentioned access frequency, access timestamp, read operation delay time and library table data volume can be obtained by querying the access logs of each library table through log analysis tools deployed in the cache, such as ELK Stack, Splunk, Apache Hadoop, etc. Among them, the above-mentioned access frequency refers to the number of times the corresponding library table is accessed within a monitoring period, and can also be obtained through a counter associated with the corresponding library table. The above-mentioned access timestamp is the timestamp of the last access to the library table during the monitoring period before the elimination trigger instruction is received, which is used to characterize the access interval of the library table. The above-mentioned read operation delay time can be the average time from the start of the search to the hit when the user performs a read operation on the data corresponding to the library table.
[0055] It should be noted that in actual application scenarios, due to the periodic characteristics of the importance of cached data, that is, in a monitoring period, for a database storing cached data with a high degree of importance, the access frequency of its library table is high, and its access timestamp is close to the end of the monitoring period. When the importance of cached data decreases in another monitoring period, the access frequency of its library table will decrease, and the access timestamp will be far away from the end of the monitoring period. Therefore, the present application is configured to update the weight value of each library table based on the access efficiency and access timestamp of each library table when receiving the elimination trigger instruction, thereby realizing the dynamic update of the weight value of the library table, so that the updated weight value obtained fully considers the influence of different time periods on the weight value. At the same time, the present application is configured to update the weight value of the library table based on the delay time of the read operation and the amount of library table data, avoiding the risk of excessive change in the weight value of the library table due to the update of the weight based only on the access frequency and access timestamp, resulting in the elimination of a large amount of cached data in the subsequent cache management process and causing a decrease in the cache hit rate, thereby improving the cache management accuracy.
[0056] It should be noted that in actual application scenarios, for caches that are not put into actual operation, the weight value of each library table can be set according to the importance of the cache data stored in the library table. For caches that are put into actual operation, the weight value of the library table on which the above update operation is performed is the weight value generated during a monitoring period before receiving the above elimination trigger instruction.
[0057] It should be noted that in actual application scenarios, for application scenarios of heterogeneous data cache management, due to differences in the data structures stored in different library tables, there are differences in the amount of library table data in different library tables. When the difference in the amount of library table data is too large, the update operation based on the library table data with excessively large differences will cause the difference in the weight values of each library table after the update to further increase, thereby reducing the accuracy of the weight value. Therefore, before updating the weight values of each library table, each weight value can be normalized to reduce the degree of difference between the weight values. The above-mentioned method of normalizing each weight value can be:
[0058] According to the maximum value max(S) and minimum value min(S) of the data volume S of each library table, the formula is: Obtain the amount of data S of the normalized table i i ', where S i It is the amount of data in the i table that has not been normalized.
[0059] This application is configured to perform various types of updates to the weight values of each library table based at least on the access frequency, access timestamp, read operation delay and library table data volume of each library table when receiving an elimination trigger instruction. While avoiding the risk of a decrease in cache hit rate due to excessive changes in the library table weight value, the updated weight value fully considers the impact of different time periods on the weight value, realizes dynamic adjustment of the library table weight value, and improves the setting accuracy of the weight value. Furthermore, by configuring the management of each library table in the cache based on the updated weight value of each library table, the accuracy of managing the cache in different time periods is improved. It can be seen that this application improves the accuracy of cache management.
[0060] In a possible implementation, the above update operation includes: frequency update, delay update and time aging update. Based on the access frequency, access timestamp, read operation delay and database table data volume of each database table, the weight value of each database table is updated to obtain the updated weight value of each database table, including:
[0061] At least based on the library table data volume and access frequency of the target library table, the weight value of the target library table is frequently updated to obtain the weight value of the target library table after the frequency update, wherein the target library table is any library table in the cache.
[0062] The frequently updated weight value is delayed and updated at least based on the library table data volume and the read operation delay duration of the target library table to obtain the weight value of the target library table after the delayed update.
[0063] The delayed updated weight value is updated by time aging based on at least the library table data volume and access timestamp of the target library table to obtain the updated weight value of the target library table.
[0064] It should be noted that, in actual application scenarios, the R&D personnel of this application have found through a large number of experiments that the higher the access frequency of the library table, the higher the importance of the cached data in the library table, the longer the access interval of the library table, the lower the importance of the cached data in the library table, and the longer the access delay of the library table, the smaller the amount of cached data in the library table (for example, there is no cached data of the data type stored in the library table that the user wants to find in the current library table, and the user needs to continue to access the background to obtain the cached data), and the amount of cached data needs to be increased to shorten the access delay. Therefore, this application updates the weight value of the target library table by configuring at least the library table data volume and access frequency based on the target library table, so that the weight value updated by frequency fully considers the influence of the access frequency on the setting accuracy of the weight value. Subsequently, the weight value updated by frequency is delayed by configuring at least the library table data volume and the read operation delay duration based on the target library table, so that the weight value updated by delay considers the influence of the access cache data volume on the setting accuracy of the weight value. Finally, by configuring at least the amount of library table data and the access timestamp of the target library table to perform time aging update on the weight value after delayed update, the updated weight value finally obtained fully considers the impact of the access interval on the accuracy of weight value setting. It can be seen that the present application performs the above-mentioned frequency update, the above-mentioned delayed update and the above-mentioned time aging update on the weight of each library table by configuring the access frequency, access timestamp, read operation delay duration and library table data amount of each library table, so that the updated weight value obtained fully considers the parameters that affect the weight value in the previous monitoring period, improves the accuracy of the updated weight value, and thus improves the final cache management accuracy.
[0065] In a possible implementation, before managing each library table in the cache based on the updated weight value, the above Figure 1 The cache management method shown also includes:
[0066] According to the updated weight value W of each library table i i (t), through the formula: Obtain the updated weight value W of each library table i after normalization i '(t),W i (t) where t is the time when the elimination trigger instruction is received and n is the total number of library tables.
[0067] It should be noted that in actual application scenarios, the present application normalizes the updated weight values through the above formula before managing each library table in the cache based on the updated weight values, thereby avoiding the risk of unlimited growth or unlimited decrease of the updated weight values due to occasional factors, such as a large number of malicious accesses in a short period of time or high-frequency malicious accesses for a long time, thereby reducing the accuracy of subsequent cache management.
[0068] In a possible implementation, each library table in the cache is managed based on the updated weight value, including:
[0069] According to the updated weight value W after normalization of each library table i i '(t), receiving time t and access timestamp T(t), through the formula: Obtain the elimination score S of each table i i (t), and when the cache space usage is greater than the preset threshold, the library table deletion operation is performed based on the sorting of the elimination score and the amount of library table data, where λ is a positive number used to eliminate time interference items, and the cache space usage is the ratio of the total amount of library table data to the memory usage.
[0070] It should be noted that in actual application scenarios, when the occupancy rate of the cache space is not greater than the preset threshold, the access rate of the cache data will not drop significantly. At this time, if the library table deletion operation is performed, the cache hit rate will be reduced due to the reduction of cache data. Therefore, this application avoids the risk of a decrease in cache hit rate by configuring the order of the elimination score and the amount of library table data when the cache control usage rate is greater than the preset threshold. At the same time, by introducing a positive number λ for eliminating time interference items, the risk of reducing the accuracy of the updated weight due to the large time interference caused by the difference between the reception time of the elimination trigger instruction and the access timestamp is further reduced, thereby affecting the final cache management accuracy.
[0071] It should be noted that in actual application scenarios, there are many implementation methods for performing the library table deletion operation based on the sorting of elimination scores and the amount of library table data. Here, an exemplary implementation method is provided, which includes the following steps A1 to A2.
[0072] Step A1, according to the cache space usage rate and the preset threshold, determine the total amount of data to be eliminated, and trigger step A2.
[0073] Step A2, in order of elimination scores from small to large, starting from the smallest elimination score, sequentially superimpose the amounts of data in the library tables corresponding to the elimination scores, and after each superposition, determine whether the superposition result is not less than the total amount of data to be eliminated. If so, trigger step A3, if not, trigger step A2.
[0074] Step A3, executing the library table deletion operation: deleting the library tables corresponding to the superimposed library table data volumes from the memory.
[0075] In a possible implementation, in order to avoid a decrease in cache hit rate due to too many deleted tables, when the cache space usage is greater than a preset threshold, the cache hit rate within a preset period can be counted, and the statistical results can be used to determine whether to trigger the operation steps of performing the table deletion operation based on the sorting of elimination scores and the amount of table data. Specifically:
[0076] like Figure 2 The flowchart of a cache management method is shown, and the specific operation steps are as follows:
[0077] Step S201, recording the access frequency, access timestamp, read operation delay and data volume of each library table, and triggering step S202.
[0078] Step S202: When receiving the elimination trigger instruction, based on the access frequency, access timestamp, read operation delay and data volume of each library table, the weight value of each library table is updated to obtain the updated weight value of each library table, and step S203 is triggered.
[0079] Step S203: Generate elimination scores for each library table based on the updated weight values of each library table, and trigger step S204.
[0080] Step S204, determine whether the preset elimination condition is met: the cache space usage rate is greater than the preset threshold, and there is no cache data hit within the preset time period. If yes, step S205 is triggered, if not, step S201 is triggered.
[0081] In a possible implementation, the preset time length may be as follows: Figure 2 The execution completion time of step S203 is a preset time length of the start time, which can be set according to the actual application scenario and is less than the length of a monitoring period.
[0082] Step S205 , executing a library table deletion operation based on the sorting of elimination scores and the amount of library table data, and sending a new library table request to the disk.
[0083] In one possible implementation, the above Figure 2 The new library table request in step S205 is a request for applying for new cache data from the disk. After receiving the new cache data fed back by the disk based on the new library table request, the cache generates a new library table in response to the new library table operation of the operation and maintenance personnel, and triggers step S201 after setting the initial weight for the new library table.
[0084] In a possible implementation, at least based on the library table data volume and access frequency of the target library table, the weight value of the target library table is frequently updated to obtain the weight value of the target library table after the frequency update, including:
[0085] According to the database table data volume S and access frequency A(t), the formula is: Obtain the frequency-updated weight value W'(t), where α is the preset frequency growth factor, t is the reception time of the elimination trigger instruction, t-1 is a time before the reception time t, and W(t-1) is the weight value of the target library table that has not been frequency updated at time t-1.
[0086] In a possible implementation, delaying the updating of the frequently updated weight value based on at least the amount of library table data and the delay duration of the read operation of the target library table to obtain the weight value of the target library table after the delay update includes:
[0087] According to the amount of data S in the library table and the delay time of the read operation D(t), the formula is: Obtain the delayed updated weight value W'(t), where t is the time when the elimination trigger instruction is received, W(t) is the weight value after frequency update, β is the preset time attenuation factor, T delay is the preset delay time.
[0088] In a possible implementation, performing time aging update on the delayed updated weight value based on at least the library table data volume and access timestamp of the target library table to obtain the updated weight value of the target library table includes:
[0089] According to the database table data volume S and access timestamp T(t), the formula is: Get the updated weight value W'(t), where t is the time when the elimination trigger instruction is received, W(t) is the weight value after delayed update, and T max is the preset maximum aging time, and γ is the preset aging factor.
[0090] It should be noted that, in actual application scenarios, the preset frequency growth factor α, the preset time attenuation factor β and the preset aging factor γ can be set by operation and maintenance personnel after comprehensive analysis based on the importance of cached data in each library table.
[0091] A second aspect of the present application provides a cache management system, wherein the cache management system is configured to:
[0092] When an elimination trigger instruction is received, the weight value of each library table is updated based on at least the access frequency, access timestamp, read operation delay duration and library table data volume of each library table to obtain the updated weight value of each library table, and the library tables in the cache are managed based on the updated weight value, wherein the access timestamp is the timestamp when the library table was last accessed during the monitoring period before the elimination trigger instruction is received.
[0093] In a possible implementation, the cache management system updates the weight value of each library table based on the access frequency, access timestamp, read operation delay and library table data volume of each library table, and the updated weight value of each library table is set to:
[0094] Update operations include: frequency update, delay update and time aging update;
[0095] At least based on the library table data volume and access frequency of the target library table, the weight value of the target library table is frequently updated to obtain the weight value of the target library table after the frequency update, wherein the target library table is any library table in the cache;
[0096] Delay updating the frequently updated weight value based at least on the amount of library table data and the read operation delay duration of the target library table to obtain the weight value of the target library table after the delayed update;
[0097] The delayed updated weight value is updated by time aging based on at least the library table data volume and access timestamp of the target library table to obtain the updated weight value of the target library table.
[0098] In a possible implementation, before the cache management system manages each library table in the cache based on the updated weight value, it is further configured as follows:
[0099] According to the updated weight value W of each library table i i (t), through the formula: Obtain the updated weight value W of each library table i after normalization i '(t),W i (t) where t is the time when the elimination trigger instruction is received and n is the total number of library tables.
[0100] In a possible implementation, the cache management system is configured to manage each library table in the cache based on the updated weight value as follows:
[0101] According to the updated weight value W after normalization of each library table i i '(t), receiving time t and access timestamp T(t), through the formula: Obtain the elimination score S of each table i i (t), and when the cache space usage is greater than the preset threshold, the library table deletion operation is performed based on the sorting of the elimination score and the amount of library table data, where λ is a positive number used to eliminate time interference items, and the cache space usage is the ratio of the total amount of library table data to the memory usage.
[0102] In a possible implementation, the cache management system updates the weight value of the target library table at a frequency based on at least the library table data volume and access frequency of the target library table, and when obtaining the weight value of the target library table after the frequency update, it is set to:
[0103] According to the database table data volume S and access frequency A(t), the formula is: Obtain the frequency-updated weight value W'(t), where α is the preset frequency growth factor, t is the reception time of the elimination trigger instruction, t-1 is a time before the reception time t, and W(t-1) is the weight value of the target library table that has not been frequency updated at time t-1.
[0104] In a possible implementation, the cache management system delays updating the frequently updated weight value based on at least the amount of library table data and the read operation delay duration of the target library table, and when obtaining the weight value of the target library table after delayed update, it is set to:
[0105] According to the amount of data S in the library table and the delay time of the read operation D(t), the formula is: Obtain the delayed updated weight value W'(t), where t is the time when the elimination trigger instruction is received, W(t) is the weight value after frequency update, β is the preset time attenuation factor, T delay is the preset delay time.
[0106] In a possible implementation, the cache management system performs time aging update on the delayed updated weight value based on at least the library table data volume and access timestamp of the target library table, and when obtaining the updated weight value of the target library table, is set to:
[0107] According to the database table data volume S and access timestamp T(t), the formula is: Get the updated weight value W'(t), where t is the time when the elimination trigger instruction is received, W(t) is the weight value after delayed update, and T max is the preset maximum aging time, and γ is the preset aging factor.
[0108] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0109] The memory is used to store computer programs;
[0110] The processor is used to execute a computer program so that the electronic device can implement the cache management method of the first aspect or any implementation of the first aspect.
[0111] A structural schematic diagram of an electronic device provided in the third aspect of the present application is as follows Figure 3The electronic devices in the embodiments of the present application may include but are not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, and the like. Figure 3 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0112] like Figure 3 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 to a random access memory (RAM) 303. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 303. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0113] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a memory card, a hard disk, etc.; and communication devices 309. The communication device 309 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 3 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0114] A fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the cache management method of the first aspect or any implementation of the first aspect.
[0115] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0116] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0117] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0118] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A cache management method, characterized in that: include: When an elimination trigger instruction is received, at least based on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table, an update operation is performed on the weight value of each library table to obtain the updated weight value of each library table, and each library table in the cache is managed based on the updated weight value, wherein the access timestamp is the timestamp of the last access to the library table within the monitoring period before the elimination trigger instruction is received.
2. The cache management method according to claim 1, characterized in that: The update operation includes: frequency update, delay update and time aging update. Based on the access frequency, access timestamp, read operation delay duration and database table data volume of each database table, the weight value of each database table is updated to obtain the updated weight value of each database table, including: At least based on the library table data volume and the access frequency of the target library table, the weight value of the target library table is updated with the frequency, and the weight value of the target library table after the frequency update is obtained, wherein the target library table is any one of the library tables in the cache; Performing the delayed update on the weight value after the frequency update at least based on the library table data volume of the target library table and the read operation delay duration, to obtain the weight value of the target library table after the delayed update; The time aging update is performed on the weight value after the delayed update based at least on the library table data volume and the access timestamp of the target library table to obtain the updated weight value of the target library table.
3. The cache management method according to claim 1, characterized in that: Before managing each of the library tables in the cache based on the updated weight value, the method further includes: According to the updated weight value W of each library table i i (t), through the formula: Obtain the updated weight value W of each library table i after normalization processing i ’ (t), W i (t) Wherein, t is the time of receiving the elimination trigger instruction, and n is the total number of the library tables.
4. The cache management method according to claim 3, characterized in that: The managing each of the library tables in the cache based on the updated weight value includes: According to the updated weight value W after normalization of each library table i i ’ (t), the receiving time t and the access timestamp T(t), through the formula: Obtain the elimination score S of each library table i i (t), and when the cache space utilization rate is greater than a preset threshold, a library table deletion operation is performed based on the sorting of the elimination score and the amount of library table data, wherein the λ is a positive number used to eliminate time interference items, and the cache space utilization rate is the occupancy rate of the total amount of library table data to the memory.
5. The cache management method according to claim 2, characterized in that: The step of performing the frequency updating on the weight value of the target library table based at least on the library table data volume and the access frequency of the target library table to obtain the weight value of the target library table after the frequency update comprises: According to the library table data volume S and the access frequency A(t), by formula: Obtain the weight value W updated by the frequency ’ (t), wherein α is a preset frequency growth factor, t is the time when the elimination trigger instruction is received, t-1 is a time before the receiving time t, and W(t-1) is the weight value of the target library table that has not undergone the frequency update at time t-1.
6. The cache management method according to claim 2, characterized in that: The delaying updating the weight value after the frequency update based at least on the library table data volume and the read operation delay duration of the target library table to obtain the weight value of the target library table after the delay update includes: According to the amount of data S in the library table and the delay time D(t) of the read operation, the formula is: Obtain the weight value W after the delay update ’ (t), wherein t is the time when the elimination trigger instruction is received, W(t) is the weight value updated by the frequency, β is the preset time attenuation factor, and T delay is the preset delay time.
7. The cache management method according to claim 2, characterized in that: The step of performing the time aging update on the delayed updated weight value based at least on the library table data volume and the access timestamp of the target library table to obtain the updated weight value of the target library table includes: According to the library table data volume S and the access timestamp T(t), by formula: Get the updated weight value W ’ (t), wherein t is the time when the elimination trigger instruction is received, W(t) is the weight value after the delay update, and T max is the preset maximum aging time, and γ is the preset aging factor.
8. A cache management system, characterized in that: The cache management system is configured to: When an elimination trigger instruction is received, based on the access frequency, access timestamp, read operation delay duration and library table data volume of each library table, the weight value of each library table is updated to obtain the updated weight value of each library table, and the library tables in the cache are managed based on the updated weight value, wherein the access timestamp is the timestamp of the last access to the library table during the monitoring period before the elimination trigger instruction is received.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the cache management method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the cache management method as described in any one of claims 1 to 7.