A method, system, device and storage medium for clearing cache data
By calculating the storage priority of cached data and determining the clearable data based on the priority, the problem of inaccurate cached data clearing in the prior art is solved, and the effective use of cache hit rate and cache space is improved.
Patent Information
- Application Number
- CN202210640601.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2042-06-08
AI Technical Summary
In the prior art, when the cached data is cleared by LRU algorithm, some cached data are erroneously cleared due to frequent short-term access or long-term unreached, affecting the cache hit rate.
By determining the storage time of cached data and the number of accesses within that time, its storage priority is calculated, and when it is necessary to clear the data, the clearable cache data is determined according to the priority.
It effectively avoids the situation of avoiding clearing due to frequent short-term access, reduces the probability of error clearing, improves the cache hit rate, and uses the cache space reasonably and effectively.
Smart Images

Figure CN114880255B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a cache data clearing method, system, device and storage medium. Background Art
[0002] In order to ensure the storage performance of the device, it is necessary to regularly clear some cached data with low access popularity. In the prior art, in order to achieve the clearing of cached data, the LRU algorithm (Least Recently Used) is usually adopted. The main idea of the algorithm is: when a cached data is accessed, its storage position is changed to the first place in the storage queue to indicate that it has a higher access popularity. Therefore, when data cleaning is required, the cached data at the end of the storage position of each data at the current data cleaning moment will be cleared due to the low access popularity at the current data cleaning moment.
[0003] However, the above method has the following defects: there is a cache data that is located at the front storage position because it is frequently accessed in a short period of time, but it may not be accessed in the subsequent period, or there is a cache data that is located at the back storage position because it has not been accessed for a period of time, but it may be accessed in the subsequent cycle, but it has been cleared at the current data cleaning time, resulting in subsequent read failure. It can be seen that the cache data cleaning method relying on the LRU algorithm will affect the cache hit rate.
[0004] Therefore, how to effectively and reliably implement the clearing and updating of cache data and ensure the cache hit rate as much as possible is a problem that needs to be solved urgently. Summary of the invention
[0005] The purpose of the present invention is to provide a cache data clearing method, system, device and storage medium, which avoids the situation where a certain cache data is adjusted to the first place and avoids clearing because it is accessed once at the current judgment moment, and the probability of erroneously clearing a certain cache data is lower, and the clearing method is more reasonable and effective, which ensures the cache hit rate as much as possible and ensures the effective use of the cache space.
[0006] In order to solve the above technical problems, the present invention provides a cache data clearing method, comprising:
[0007] Determine the storage duration of the i-th cache data, where the storage duration = the current determination time - the initial time when the i-th cache data is stored in the cache space, 1≤i≤the total number of the cache data and i is an integer;
[0008] Determine the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the cache data is read during the storage duration;
[0009] When it is determined that there is a need to clear data from the cache space, the cache data that can be cleared is determined according to the need and the storage priority of each cache data.
[0010] Preferably, the cache space includes a priority storage space and a space to be cleared;
[0011] After determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the cache data is read within the storage duration, the method further includes:
[0012] Determine whether the storage priority of the i-th cache data is not less than a preset partition threshold;
[0013] If so, store the i-th cache data into the priority storage space;
[0014] If not, store the i-th cache data into the to-be-cleared space;
[0015] Determining cache data that can be cleared according to the requirements and the storage priority of each cache data includes:
[0016] The cache data that can be cleared is determined according to the demand and the data stored in the to-be-cleared space.
[0017] Preferably, when the requirement is the number of data to be cleared;
[0018] Determining cache data that can be cleared according to the demand and the data stored in the to-be-cleared space includes:
[0019] Determine whether the total number of cache data stored in the to-be-cleared space is less than the number of data to be cleared;
[0020] If so, determining that all data in the to-be-cleared space are cache data that can be cleared;
[0021] Sorting the cached data in the priority storage space in order from low to high according to the corresponding storage priority;
[0022] Determine M cache data starting from the cache data corresponding to the lowest storage priority as cache data that can be cleared, where M is the difference between the number of data to be cleared and the total number.
[0023] Preferably, it also includes:
[0024] When the cache data to be stored is received, the cache data to be stored is stored in the priority storage space.
[0025] Preferably, determining that there is a need to clear data from the cache space includes:
[0026] When a flag signal indicating data clearing sent by a user is received and / or a preset clearing time is reached, it is determined that there is a need to clear data from the cache space.
[0027] Preferably, after determining the cache data that can be cleared according to the demand and the data stored in the to-be-cleared space, the method further includes:
[0028] Determining the remaining storage capacity of the current cache space;
[0029] A display module in the control device displays the remaining storage capacity.
[0030] Preferably, determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times it is read and accessed within the storage duration includes:
[0031] For the i-th cache data, perform the following steps:
[0032] Determine the time priority corresponding to the storage duration of the i-th cache data based on the first preset relationship;
[0033] The first preset relationship is:
[0034]
[0035] in, is the time priority, ω1 is the preset time weight, T i is the storage duration of the i-th cache data, F i is the number of times the i-th cache data is read during the storage duration;
[0036] Determine the number priority corresponding to the number of accesses to the i-th cache data based on the second preset relationship;
[0037] The second preset relationship is:
[0038]
[0039] in, is the number priority, ω2 is the preset number weight and ω1+ω2=1;
[0040] Determine the storage priority of the i-th cache data at the current determination time based on a third preset relationship;
[0041] The third preset relationship is:
[0042]
[0043] Among them, P i is the storage priority, PN i The preset initial priority of the i-th cache data.
[0044] In order to solve the above technical problems, the present invention also provides a cache data clearing system, comprising:
[0045] A duration determination unit, used to determine the storage duration of the i-th cache data, wherein the storage duration = the current determination time - the initial time when the i-th cache data is stored in the cache space, 1≤i≤the total number of the cache data and i is an integer;
[0046] A storage priority determination unit, configured to determine the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the i-th cache data is accessed during the storage duration;
[0047] The clearing unit is used to determine the cache data that can be cleared according to the demand and the storage priority of each cache data when it is determined that there is a demand to clear data from the cache space.
[0048] In order to solve the above technical problems, the present invention also provides a cache data clearing device, comprising:
[0049] Memory for storing computer programs;
[0050] A processor is used to execute the steps of the cache data clearing method as described above.
[0051] In order to solve the above technical problems, the present invention further provides a computer-readable storage medium, comprising:
[0052] The computer readable medium stores a computer program, and when the computer program is executed by the processor, the steps of the cache data clearing method as described above are implemented.
[0053] The present invention provides a cache data clearing method, system, device and storage medium. For the i-th cache data, the storage duration from the initial storage time to the current judgment time is determined. Based on the storage duration and the number of access times of the cache data being read during the storage duration, the storage priority at the current judgment time is determined. Then, when it is determined that there is a need to clear data from the cache space, the cache data that can be cleared is determined according to the need and the storage priority of each cache data. Compared with the prior art, the present application simultaneously considers the storage duration and the number of access times of the cache data in the entire time period from the initial storage to the current judgment time, avoiding the situation where a certain cache data is adjusted to the first place because it is accessed once at the current judgment time and avoids clearing, and the probability of mistakenly clearing a certain cache data is lower, and the clearing method is more reasonable and effective, which guarantees the cache hit rate as much as possible and ensures the effective use of the cache space. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0055] Figure 1 A flow chart of a cache data clearing method provided by the present invention;
[0056] Figure 2 A schematic diagram of the structure of a cache data clearing system provided by the present invention;
[0057] Figure 3 A schematic structural diagram of a cache data clearing device provided by the present invention. DETAILED DESCRIPTION
[0058] The core of the present invention is to provide a cache data clearing method, system, device and storage medium, which avoids the situation where a certain cache data is adjusted to the first place and avoids clearing because it is accessed once at the current judgment moment, and the probability of erroneously clearing a certain cache data is lower, and the clearing method is more reasonable and effective, which guarantees the cache hit rate as much as possible and ensures the effective use of the cache space.
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Please refer to Figure 1 , Figure 1 The present invention provides a flow chart of a cache data clearing method.
[0061] In this embodiment, considering that the cleaning method for cache data in the prior art mainly relies on the LRU algorithm, in this algorithm, when a certain cache data is accessed, its storage position is changed to the first place in the storage queue to indicate that it has a higher access popularity, so that when facing the need for data cleaning, only the storage position of each cache data at the current data cleaning moment is used, and the cache data at the tail of the storage position will be cleared due to the low access popularity at the current data cleaning moment. However, this method has defects, which affects the read hit rate of cache data. In order to solve the above technical problems, the present application provides a cache data clearing method, which improves the read hit rate of cache data as much as possible.
[0062] The cache data clearing method includes:
[0063] S11: Determine the storage duration of the i-th cache data, where the storage duration = current determination time - initial time when the i-th cache data is stored in the cache space, 1≤i≤total number of cache data and i is an integer;
[0064] Specifically, the cache data clearing method can be applied to: including but not limited to various servers, clients and other computer devices, which are not particularly limited here; the cache space here includes but is not limited to a storage device for storing cache data with different access hotness, such as memory, etc.; therefore, at the initial moment when the i-th cache data is stored in the cache space, the initial moment is recorded for subsequent calculation of the storage duration; in addition, there is no special limitation on the specific setting of the current determination moment, and it can be set according to actual needs, such as periodically determining the storage priority of the i-th cache data.
[0065] It should also be noted that the specific storage form of the cache data in the cache space includes but is not limited to a storage queue form, a hash structure form or a tree structure form, which is not specifically limited here and is set according to actual needs.
[0066] S12: determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the i-th cache data is read during the storage duration;
[0067] Specifically, for the i-th cache data, each time it is read and accessed, the corresponding access count is increased by 1 and stored to prepare for the subsequent calculation of storage priority. And because both storage duration and access count are considered here, the rationality of storage priority determination is guaranteed.
[0068] S13: When it is determined that there is a need to clear data from the cache space, the cache data that can be cleared is determined according to the need and the storage priority of each cache data.
[0069] It should be noted that after determining the cache data that can be cleared, the deletion operation can be directly performed on the cache data that can be cleared. It can be seen that the present application can more reasonably evaluate the cache data that is suitable for elimination and clearing. It is understandable that the probability of clearing cache data with a high storage priority is smaller, and the probability of clearing cache data with a low storage priority is greater.
[0070] Specifically, the demand here can be the number of data to be cleared, or the percentage of data to be cleared (the percentage * the total number of cached data stored is the determined number of data to be cleared), and the present application does not make any special restrictions here. Assuming that the demand is the number of data to be cleared, sort each cached data in order of storage priority from low to high, and the S cached data starting from the cached data corresponding to the lowest storage priority are the clearable cached data, where S is the number of data to be cleared. This ensures that cached data with high storage priority will not be unreasonably eliminated.
[0071] In summary, the present application provides a cache data clearing method. Compared with the prior art, the present application simultaneously considers the storage duration and the number of accesses to the cache data from the initial storage to the current judgment moment, thereby avoiding the situation where a certain cache data is adjusted to the first place and avoids clearing because it is accessed once at the current judgment moment. The probability of erroneously clearing a certain cache data is lower, and the clearing method is more reasonable and effective, which maximizes the cache hit rate and ensures the effective use of the cache space.
[0072] Based on the above embodiments:
[0073] As a preferred embodiment, the cache space includes a priority storage space and a to-be-cleared space;
[0074] After determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the cache data is read within the storage duration, the method further includes:
[0075] Determine whether the storage priority of the i-th cache data is not less than a preset partition threshold;
[0076] If so, store the i-th cache data into the priority storage space;
[0077] If not, store the i-th cache data into the space to be cleared;
[0078] Determine the cache data that can be cleared based on the needs and storage priority of each cache data, including:
[0079] The cache data that can be cleared is determined based on demand and the data stored in the space to be cleared.
[0080] In this embodiment, the inventor further considers that the cache space can be further subdivided, and thus sets a preset partition threshold related to the storage priority value, which is used to distinguish the storage priority of each cache data to realize partition storage, and judges whether the storage priority of the i-th cache data is not less than the preset partition threshold. If so, it means that the access popularity of the cache data is relatively high, so it is stored in the priority storage space (it should be noted that the priority storage space here means that when it is determined that there is a data clearing requirement in the device, the data stored in the space to be cleared will give priority to responding to the data clearing requirement, and the priority storage space will respond only when the total number of cache data stored in the space to be cleared is insufficient) to ensure that it will not be unreasonably cleared in the future; if not, it means that the access popularity of the cache data is relatively low, so it is stored in the space to be cleared to ensure that it will respond to the clearing requirement first in the future.
[0081] It should be noted that the specific value of the preset partition threshold here can be set according to actual needs. The steps for determining the cache data that can be cleared according to the needs and the data stored in the space to be cleared can be: assuming that the demand is the number of data to be cleared, you can select any cache data of the number of data to be cleared in the space to be cleared as the cache data that can be cleared and delete it. Of course, you can also sort the cache data stored in the space to be cleared in order from low to high according to the storage priority of the cache data stored in the space to be cleared, and start from the cache data corresponding to the lowest storage priority to select the cache data of the number of data to be cleared as the cache data that can be cleared, and there is no special limitation here.
[0082] As a preferred embodiment, when the requirement is the number of data to be cleared;
[0083] Determine the cache data that can be cleared based on the needs and the data stored in the space to be cleared, including:
[0084] Determine whether the total number of cached data stored in the space to be cleared is less than the number of data to be cleared;
[0085] If so, determine that all data in the to-be-cleared space are cached data that can be cleared;
[0086] Sort each cache data in the priority storage space in order from low to high according to the corresponding storage priority;
[0087] It is determined that M cache data starting from the cache data corresponding to the lowest storage priority are cache data that can be cleared, where M is the difference between the number of data to be cleared and the total number of data.
[0088] In this embodiment, the inventor further considers that when the number of data to be cleared is large, the total number of cache data stored in the space to be cleared may be less than the number of data to be cleared, so this embodiment provides the execution logic in this case, which is described above and will not be repeated here. It can be seen that the setting of the above execution logic reliably ensures that the probability of clearing cache data with high storage priority is smaller, and the probability of clearing cache data with low storage priority is greater, avoiding the occurrence of unreasonable data clearing, thereby improving the data read hit rate.
[0089] As a preferred embodiment, it also includes:
[0090] When the cache data to be stored is received, the cache data to be stored is stored in the priority storage space.
[0091] In this embodiment, for the cache data to be stored that is placed into the cache space for the first time, it can be stored in the priority storage space first. In addition, it can be assigned a preset initial priority as its storage priority so that its storage priority can be re-determined when the judgment time is reached later to avoid it being deleted by mistake.
[0092] As a preferred embodiment, determining that there is a need to clear data from the cache space includes:
[0093] When a flag signal indicating data clearing sent by a user is received and / or a preset clearing time is reached, it is determined that there is a need to clear data from the cache space.
[0094] In this embodiment, the execution logic for determining whether there is a need to clear data from the cache space is provided, as described above, and will not be repeated here. It should be noted that when a flag signal representing data clearing sent by a user is received, a first flag information representing the amount of data clearing sent by the user can also be received, and the corresponding data clearing work can be performed according to the first flag information; when the preset clearing time is reached, the corresponding data clearing work can be performed according to the first flag information according to the default second flag information representing the amount of data clearing, and there is no special limitation on the specifics.
[0095] As a preferred embodiment, after determining the cache data that can be cleared according to the demand and the data stored in the space to be cleared, the method further includes:
[0096] Determine the remaining storage capacity of the current cache space;
[0097] The display module in the control device displays the remaining storage capacity.
[0098] In this embodiment, in order to more intuitively display the storage status of the cache space, after determining the cache data that can be cleared according to the demand and the data stored in the space to be cleared, the remaining storage capacity of the current cache space can be determined, and the display module can be controlled to display the remaining storage capacity for the user to understand. It should be noted that the display module here includes but is not limited to the display screen in the device. In addition, the voice prompt module in the device can also be controlled to broadcast and prompt the remaining storage capacity. This application does not make any special restrictions here, and it depends on actual needs.
[0099] As a preferred embodiment, the storage priority of the i-th cache data at the current determination time is determined based on the storage duration of the i-th cache data and the number of times it is read during the storage duration, including:
[0100] For the i-th cache data, perform the following steps:
[0101] Determine the time priority corresponding to the storage duration of the i-th cache data based on the first preset relationship;
[0102] The first preset relationship is:
[0103]
[0104] in, is the time priority, ω1 is the preset time weight, T i is the storage duration of the i-th cache data, F i is the number of times the i-th cache data is read during the storage duration;
[0105] Determine the number priority corresponding to the number of accesses to the i-th cache data based on the second preset relationship;
[0106] The second preset relationship is:
[0107]
[0108] in, is the priority of the number of times, ω2 is the preset number of times weight and ω1+ω2=1;
[0109] Determine the storage priority of the i-th cache data at the current determination time based on the third preset relationship;
[0110] The third preset relationship is:
[0111]
[0112] Among them, P i For storage priority, PN i The preset initial priority of the i-th cache data.
[0113] In this embodiment, the execution logic for determining the storage priority of the i-th cache data is given, which is specifically described above and will not be repeated here. It should be noted that there is no special limitation on the specific values of the preset time weight ω1 and the preset number of weights ω2, which can be configured by the user to meet the actual needs of the user, but it is necessary to satisfy ω1+ω2=1. By default, ω1 and ω2 can be 0.5. Moreover, for different cache data, it can correspond to different preset initial priorities, and can also correspond to different preset time weights ω1 and preset number of weights ω2, without special limitations.
[0114] In addition, it can be seen from the third preset relationship that for the i-th cache data, The value of may be positive or negative. When it is positive, it means that the cache data is accessed frequently, so the storage priority of the cache data will increase; when it is negative, it means that the cache data may not be accessed for a long time, so the storage priority of the cache data will decrease. Of course, assuming that the moment when it is determined that there is a need to clear data from the cache space is moment t1, the storage priority of the cache data is variable corresponding to each judgment moment before moment t1, that is, at a certain judgment moment before moment t1, if the cache data is accessed again, its corresponding storage priority may increase. Correspondingly, assuming that the cache space is divided into priority storage space and to-be-cleared space, at judgment moment t2 before moment t1, if the storage priority of the cache data is less than the preset partition threshold, it will be stored in the to-be-cleared space, and at judgment moment t3 after judgment moment t2 and before moment t1, if the storage priority of the cache data is greater than the preset partition threshold, it will be stored in the priority storage space again.
[0115] It should also be noted that various methods of determining the storage priority of cached data by taking into account both the storage duration and the number of accesses are within the scope of protection of this application. It can be seen that the storage priority of cached data can be simply and reliably determined through the above execution logic, laying the foundation for the subsequent determination of cached data that can be cleared.
[0116] Please refer to Figure 2 , Figure 2 A schematic diagram of the structure of a cache data clearing system provided by the present invention.
[0117] The cache data clearing system includes:
[0118] The duration determination unit 21 is used to determine the storage duration of the i-th cache data, where the storage duration = the current determination time - the initial time when the i-th cache data is stored in the cache space, 1≤i≤the total number of cache data and i is an integer;
[0119] A storage priority determination unit 22, configured to determine the storage priority of the i-th cache data at a current determination time based on the storage duration of the i-th cache data and the number of times the i-th cache data is accessed during the storage duration;
[0120] The clearing unit 23 is used to determine the cache data that can be cleared according to the demand and the storage priority of each cache data when it is determined that there is a demand to clear data from the cache space.
[0121] For an introduction to the cache data clearing system provided in the present invention, please refer to the above-mentioned embodiment of the cache data clearing method, which will not be described in detail here.
[0122] As a preferred embodiment, the cache space includes a priority storage space and a to-be-cleared space;
[0123] The cache data clearing system further includes:
[0124] A first judgment unit is used to judge whether the storage priority of the i-th cache data is not less than a preset partition threshold; if so, trigger the first processing unit; if not, trigger the second processing unit;
[0125] The first processing unit is used to store the i-th cache data into the priority storage space;
[0126] The second processing unit is used to store the i-th cache data into the to-be-cleared space;
[0127] The clearing unit 23 is specifically configured to trigger the third processing unit when it is determined that there is a need to clear data from the cache space;
[0128] The third processing unit is used to determine the cache data that can be cleared according to the demand and the data stored in the space to be cleared.
[0129] As a preferred embodiment, when the requirement is the number of data to be cleared;
[0130] The third processing unit comprises:
[0131] A second judging unit is used to judge whether the total number of cache data stored in the to-be-cleared space is less than the number of data to be cleared; if so, trigger the first determining unit;
[0132] The first determining unit is used to determine that all data in the to-be-cleared space are cache data that can be cleared;
[0133] A sorting unit, used to sort the cache data in the priority storage space in order from low to high according to the corresponding storage priority;
[0134] The second determining unit is used to determine that M cache data starting from the cache data corresponding to the lowest storage priority are cache data that can be cleared, wherein M is the difference between the number of the data to be cleared and the total number.
[0135] As a preferred embodiment, the cache data clearing system further includes:
[0136] The initial storage unit is used to store the cache data to be stored in the priority storage space when receiving the cache data to be stored.
[0137] As a preferred embodiment, the cache data clearing system further includes:
[0138] A capacity determination unit, used to determine the remaining storage capacity of the current cache space after the clearing unit 23;
[0139] A display control unit is used to control a display module in the device to display the remaining storage capacity.
[0140] As a preferred embodiment, the storage priority determination unit 22 includes:
[0141] a time priority determination unit, configured to determine the time priority corresponding to the storage duration of the i-th cache data based on a first preset relationship;
[0142] The first preset relationship is:
[0143]
[0144] in, is the time priority, ω1 is the preset time weight, T i is the storage duration of the i-th cache data, F i is the number of times the i-th cache data is read during the storage duration;
[0145] A number priority determination unit, configured to determine a number priority corresponding to the number of accesses to the i-th cache data based on a second preset relationship;
[0146] The second preset relationship is:
[0147]
[0148] in, is the number priority, ω2 is the preset number weight and ω1+ω2=1;
[0149] a comprehensive determination unit, configured to determine the storage priority of the i-th cache data at the current determination moment based on a third preset relationship;
[0150] The third preset relationship is:
[0151]
[0152] Among them, P i is the storage priority, PN i The preset initial priority of the i-th cache data.
[0153] Please refer to Figure 3 , Figure 3 A schematic structural diagram of a cache data clearing device provided by the present invention.
[0154] The cache data clearing device comprises:
[0155] A memory 31, used for storing computer programs;
[0156] The processor 32 is used to execute the steps of the cache data clearing method as described above.
[0157] For an introduction to the cache data clearing device provided in the present invention, please refer to the above-mentioned embodiment of the cache data clearing method, which will not be described in detail here.
[0158] The present invention also provides a computer-readable storage medium, comprising:
[0159] The computer readable medium stores a computer program, and when the computer program is executed by the processor, the steps of the cache data clearing method as described above are implemented.
[0160] For an introduction to the computer-readable storage medium provided in the present invention, please refer to the above-mentioned embodiment of the cache data clearing method, which will not be described in detail here.
[0161] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0162] Relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
[0163] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A cache data clearing method, characterized in that: include: Determine the storage duration of the i-th cache data, where the storage duration = the current determination time - the initial time when the i-th cache data is stored in the cache space, 1≤i≤the total number of the cache data and i is an integer; Determine the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the cache data is read during the storage duration; When it is determined that there is a need to clear data from the cache space, determining cache data that can be cleared according to the need and the storage priority of each cache data; Determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the i-th cache data is read during the storage duration includes: For the i-th cache data, perform the following steps: Determine the time priority corresponding to the storage duration of the i-th cache data based on the first preset relationship; The first preset relationship is: in, is the time priority, ω1 is the preset time weight, T i is the storage duration of the i-th cache data, F i is the number of times the i-th cache data is read during the storage duration; Determine the number priority corresponding to the number of accesses to the i-th cache data based on the second preset relationship; The second preset relationship is: in, is the number priority, ω2 is the preset number weight and ω1+ω2=1; Determine the storage priority of the i-th cache data at the current determination time based on a third preset relationship; The third preset relationship is: Among them, P i is the storage priority, PN i The preset initial priority of the i-th cache data.
2. The cache data clearing method according to claim 1, characterized in that: The cache space includes a priority storage space and a space to be cleared; After determining the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the cache data is read within the storage duration, the method further includes: Determine whether the storage priority of the i-th cache data is not less than a preset partition threshold; If so, store the i-th cache data into the priority storage space; If not, store the i-th cache data into the space to be cleared; Determining cache data that can be cleared according to the requirements and the storage priority of each cache data includes: The cache data that can be cleared is determined according to the demand and the data stored in the to-be-cleared space.
3. The cache data clearing method according to claim 2, characterized in that: When the requirement is the number of data to be cleared; Determining cache data that can be cleared according to the demand and the data stored in the to-be-cleared space includes: Determine whether the total number of cache data stored in the to-be-cleared space is less than the number of data to be cleared; If so, determining that all data in the to-be-cleared space are cache data that can be cleared; Sorting the cached data in the priority storage space in order from low to high according to the corresponding storage priority; Determine M cache data starting from the cache data corresponding to the lowest storage priority as cache data that can be cleared, where M is the difference between the number of data to be cleared and the total number.
4. The cache data clearing method according to claim 2, characterized in that: Also includes: When the cache data to be stored is received, the cache data to be stored is stored in the priority storage space.
5. The cache data clearing method according to claim 1, characterized in that: Determining that there is a need to clear data from the cache space includes: When a flag signal indicating data clearing sent by a user is received and / or a preset clearing time is reached, it is determined that there is a need to clear data from the cache space.
6. The cache data clearing method according to claim 2, characterized in that: After determining the cache data that can be cleared according to the demand and the data stored in the to-be-cleared space, the method further includes: Determining the remaining storage capacity of the current cache space; A display module in the control device displays the remaining storage capacity.
7. A cache data clearing system, characterized in that: include: A duration determination unit, used to determine the storage duration of the i-th cache data, wherein the storage duration = the current determination time - the initial time when the i-th cache data is stored in the cache space, 1≤i≤the total number of the cache data and i is an integer; A storage priority determination unit, configured to determine the storage priority of the i-th cache data at the current determination time based on the storage duration of the i-th cache data and the number of times the i-th cache data is accessed during the storage duration; a clearing unit, configured to determine cache data that can be cleared according to the demand and the storage priority of each cache data when it is determined that there is a demand for clearing data from the cache space; The storage priority determination unit is specifically used for: For the i-th cache data, perform the following steps: Determine the time priority corresponding to the storage duration of the i-th cache data based on the first preset relationship; The first preset relationship is: in, is the time priority, ω1 is the preset time weight, T i is the storage duration of the i-th cache data, F i is the number of times the i-th cache data is read during the storage duration; Determine the number priority corresponding to the number of accesses to the i-th cache data based on the second preset relationship; The second preset relationship is: in, is the number priority, ω2 is the preset number weight and ω1+ω2=1; Determine the storage priority of the i-th cache data at the current determination time based on a third preset relationship; The third preset relationship is: Among them, P i is the storage priority, PN i The preset initial priority of the i-th cache data.
8. A cache data clearing device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the steps of the cache data clearing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: include: The computer readable medium stores a computer program, and when the computer program is executed by a processor, the steps of the cache data clearing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Cache data processing method and device, computer storage medium and electronic equipment
CN110837480A