CN110569261B - Method and device for updating resources stored in cache region - Google Patents

Method and device for updating resources stored in cache region Download PDF

Info

Publication number
CN110569261B
CN110569261B CN201910735316.8A CN201910735316A CN110569261B CN 110569261 B CN110569261 B CN 110569261B CN 201910735316 A CN201910735316 A CN 201910735316A CN 110569261 B CN110569261 B CN 110569261B
Authority
CN
China
Prior art keywords
resource
accessed
resources
cache region
stored
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910735316.8A
Other languages
Chinese (zh)
Other versions
CN110569261A (en
Inventor
海鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN201910735316.8A priority Critical patent/CN110569261B/en
Publication of CN110569261A publication Critical patent/CN110569261A/en
Application granted granted Critical
Publication of CN110569261B publication Critical patent/CN110569261B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/248Presentation of query results

Abstract

A method for updating resources stored in a cache region is disclosed. The method comprises the following steps: when traversing the resource pool to search the storage position of the resource to be accessed in the server, according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, performing the least recent elimination algorithm sorting on each resource, so as to update the resource stored in the cache region according to the sorting result. When a hot resource which is always in a burst state is accessed in a window period, the number of times that the resource is accessed in a specified time and the time that the resource is accessed last time can be sorted by means of the count and the timestamp of the counter corresponding to each resource which are updated after the resource is accessed each time, the resources stored in the cache region and the sorting of the resources are updated, and the robustness of the window minimum elimination algorithm is enhanced. Corresponding apparatus for updating resources stored in a cache region are also disclosed.

Description

Method and device for updating resources stored in cache region
Technical Field
The present invention relates to cache area technology, and more particularly, to a method and apparatus for updating resources stored in a cache area.
Background
The Window Least recent obsolete (WLFU) algorithm is a modified version of the Least recent obsolete (LFU) algorithm that records only a limited number of recent access histories of the cache area, such as only the past W accesses of the cache area. And when the resources in the cache region need to be eliminated, sequencing according to the access records of the past W accesses and eliminating according to the LFU algorithm. The window minimum elimination algorithm only records a part of the latest access history, and has lower memory consumption and sequencing consumption compared with the traditional minimum elimination algorithm.
However, the window minimum elimination algorithm still has a fatal defect, because the access history record is of a limited length, when a sudden hot spot resource is encountered, the recorded access histories are the same resource when the window minimum elimination algorithm is adopted, the sorted result list only has the resource, normally, the number of the types of the resource in the sorted result list is greater than the number of the resource which can be stored in the cache region, the sorted result is intercepted according to the number of the resource which can be stored in the cache region, whether a new resource is stored or not is determined by checking whether the intercepted sorted result has a new resource enclosure, if only one resource is in the sorted result, namely the types of the resource in the sorted result are less than the number of the resource which can be stored in the cache region, whether other resources accessed last time need to be stored in the cache region or not is known, even if the resource is to be placed in the cache region, based on the ordering result, we do not know which resource stored in the cache region needs to be eliminated, because we only know that the first-ranked resource in the cache region is the hot resource. Therefore, when the existing window least-recently-eliminated algorithm is adopted and meets a sudden hot resource, the resources cannot be sequenced because the same resource is accessed in a historical record, and the eliminated algorithm cannot work.
Disclosure of Invention
In order to solve the technical problem, the present invention provides a method and an apparatus for updating resources stored in a cache region, which can update the resources stored in the cache region and the ordering of the resources when a hot spot resource which is always burst in a window period is accessed.
To achieve the object of the present invention, the present invention provides a method for updating a resource stored in a cache region, the method comprising:
when traversing the resource pool to search the storage position of the resource to be accessed in the server, performing the minimum-recent elimination algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, so as to update the resource stored in the cache region according to the sorting result;
when a first resource in each resource is accessed, recording the first resource in a resource list of a resource pool and updating the count and the timestamp of a counter corresponding to the first resource; and the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time.
In an optional embodiment, when traversing the resource pool to find a storage location of a resource to be accessed in the server, according to a count and a timestamp of a counter corresponding to each resource recorded in a resource list of the resource pool, performing a window-minimum-of-recent-elimination algorithm sorting on each resource recorded in the resource list, so as to update the resource stored in the cache region according to a sorting result, the step includes:
when a resource access request is received, judging whether a resource to be accessed is stored in a cache region;
traversing the resource pool and updating a count and a timestamp of a counter corresponding to each resource among all resources recorded in a resource list of the resource pool if the resource to be accessed is not stored in the cache region;
and according to the count and the timestamp of the counter corresponding to each resource in all the resources recorded in the resource list of the resource pool, performing window minimum elimination algorithm sorting on all the resources recorded in the resource list of the resource pool so as to update the resources stored in the cache region.
In an optional embodiment, the method further comprises:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
In an alternative embodiment, the step of traversing the resource pool and updating the count and the timestamp of the counter corresponding to each resource among all the resources recorded in the resource list of the resource pool comprises:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time at present according to the timestamp corresponding to each resource in all the resources recorded in the resource list;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
In an alternative embodiment, the step of performing a window-least-recently-eliminated algorithm sorting on each resource recorded in the resource list to update the resources stored in the cache region according to the sorting result includes:
when performing the sorting of the minimum least recent elimination algorithm of the window on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the timestamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after the count and the time stamp of the counter corresponding to the resource to be accessed are updated in the resource list;
and if the resource to be accessed is not stored in the cache region, updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list after the resource to be accessed is accessed in the server.
To achieve the object of the present invention, an embodiment of the present invention provides an apparatus for updating resources stored in a cache region, the apparatus including a processor and a memory;
the memory is to store computer readable instructions;
the processor is configured to execute the computer-readable instructions to perform operations comprising:
when traversing the resource pool to search the storage position of the resource to be accessed in the server, performing the minimum-recent elimination algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, so as to update the resource stored in the cache region according to the sorting result;
when a first resource in each resource is accessed, recording the first resource in a resource list of a resource pool and updating the count and the timestamp of a counter corresponding to the first resource; and the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time.
In an optional embodiment, when traversing the resource pool to find a storage location of a resource to be accessed in the server, according to a count and a timestamp of a counter corresponding to each resource recorded in a resource list of the resource pool, performing a window least-recent-elimination algorithm sorting on each resource recorded in the resource list, so as to update the resource stored in the cache region according to a sorting result, the operation includes:
when a resource access request is received, judging whether a resource to be accessed is stored in a cache region;
traversing the resource pool and updating a count and a timestamp of a counter corresponding to each resource among all resources recorded in a resource list of the resource pool if the resource to be accessed is not stored in the cache region;
and according to the count and the timestamp of the counter corresponding to each resource in all the resources recorded in the resource list of the resource pool, performing window minimum elimination algorithm sorting on all the resources recorded in the resource list of the resource pool so as to update the resources stored in the cache region.
In an alternative embodiment, the processor further performs the following:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
In an alternative embodiment, the operation of traversing the resource pool and updating the count and the timestamp of the counter corresponding to each resource among all the resources recorded in the resource list of the resource pool comprises:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time or not according to the timestamp which is recorded in the resource list and corresponds to each resource in all the resources;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
In an alternative embodiment, the operation of performing a window-least-recently-eliminated algorithm sorting on each resource recorded in the resource list to update the resources stored in the cache region according to the sorting result includes:
when performing the sorting of the minimum least recent elimination algorithm of the window on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the timestamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after the count and the time stamp of the counter corresponding to the resource to be accessed are updated in the resource list;
and if the resource to be accessed is not stored in the cache region, updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list after the resource to be accessed is accessed in the server.
The embodiment of the invention has the beneficial effects that: when a hot resource which is always in a burst state in a window period is accessed, the number of times that the resource is accessed in a specified time and the time that the resource is accessed last time can be sorted out by means of the count and the time stamp of the counter corresponding to each resource which are continuously updated after the resource is accessed every time, so that the resources stored in the cache region and the sorting of the resources are updated, and the robustness of the window minimum-recent elimination algorithm is enhanced.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
FIGS. 1-4 are schematic diagrams of a process for updating resources stored in a cache region using an existing window-least-recently-eviction algorithm;
FIG. 5 is a flowchart of a method for updating resources stored in a cache region according to an embodiment of the present invention;
fig. 6 is a flowchart of sub-steps of step S101 in fig. 5;
fig. 7 is a block diagram of an apparatus for updating resources stored in a cache region according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
The Window Least recent obsolete (WLFU) algorithm is a modified version of the Least recent obsolete (LFU) algorithm that records only a limited number of recent access histories of the cache area, such as only the past W accesses of the cache area. And when the resources in the cache region need to be eliminated, sequencing according to the access records of the past W accesses according to an LFU algorithm and eliminating. As shown in fig. 1, assuming that the history access record length (W) is 9, the number of resources that the cache region can store is 3, and in one row of the access history record in the figure, different numbers in each grid represent accesses to different resources, and the same number represents accesses to the same resource.
According to the access history record of the nth access in fig. 1, the resource No. 4 is referred to 3 times, and the resource No. 2 and the resource No. 5 are referred to 2 times, and since the reference time of the resource No. 5 is the closest, the LFU is ranked first, and the resource No. 2 is ranked later, that is, the resource No. 4, the resource No. 5 and the resource No. 2 are ranked 3 times before the reference time, that is, the resource No. 4, the resource No. 5 and the resource No. 2 are currently in the cache region; and after the (n + 1) th access is finished, performing another round of window least-recent elimination algorithm sorting on the access history records, and if the sorting result is changed (namely the resources stored in the cache region need to be eliminated), preferentially eliminating the resource number 2. As shown in fig. 2, in the n +1 th access, the accessed resource is resource No. 2. The sorting result in the cache area becomes resource No. 4, resource No. 5, and resource No. 3. At this point resource number 1 has been evicted in the cache region and replaced with resource number 3. If the ordering result of the (n + 1) th access is the same as the ordering result of the (n) th access, the resource stored in the cache region is not eliminated, for example, as shown in fig. 3, in the (n + 2) th access, resource number 6 is accessed, the ordering of the resource in the cache region is not changed, the existing resource in the cache region does not need to be eliminated, and the resource number 6 is not stored in the cache region.
From the above description, it can be known that: the window minimum elimination algorithm only records a part of the latest access history, and has lower memory consumption and sequencing consumption compared with the traditional minimum elimination algorithm.
However, the window-minimum-recent-elimination algorithm still has a fatal defect, because the access history records are of a limited length, when a sudden hot resource is encountered, which may cause that the access histories recorded when the window-minimum-recent-elimination algorithm is adopted are all the same resource (for example, resource No. 4), the sorted result list only has the resource itself, normally, the number of the types of the resources in the sorted result list is greater than the number of the resources that can be stored in the cache region, we intercept the sorted result according to the number of the resources that can be stored in the cache region, at this time, whether to store the new resource is determined by checking whether there is a new resource enclosure in the intercepted sorted result, if there is only one resource in the sorted result (i.e., there is only resource No. 4 in the sorted result), that is, that the types of the resources in the sorted result are less than the number of the resources that can be stored in the cache region, we have no way of knowing whether other resources that have been accessed last time need to be stored in the cache region, and even if we want to put it in the cache region, we do not know which resource stored in the cache region needs to be evicted according to the sorting result, because we only know that the first-ranked resource in the cache region is resource number 4 (as shown in fig. 4). Therefore, when the existing window least-recently-eliminated algorithm is adopted and meets the sudden hot spot resource, the resource cannot be sequenced because the same resource is accessed in the history record, and the eliminated algorithm cannot work.
In order to solve the above problem, an embodiment of the present invention provides a method for updating resources stored in a cache region, and as shown in fig. 5, the method includes step S101.
Step S101, when traversing the resource pool to search the storage position of the resource to be accessed in the server, according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, performing the least recent elimination algorithm sorting of the window on each resource recorded in the resource list, so as to update the resource stored in the cache region according to the sorting result.
In the embodiment of the invention, a resource pool is set for executing the sequencing of the least recent elimination algorithm of the windows. The resource pool is provided with a plurality of resource lists, and each resource list stores and manages access records of a plurality of resources. The access record of a resource as referred to herein includes the name of the resource, the count of the counter corresponding to the resource, and the timestamp corresponding to the resource. When a first resource among the resources is accessed, recording the first resource in a resource list of a resource pool and updating the count and the timestamp of a counter corresponding to the first resource, wherein the first resource has a corresponding counter every day, for example, the counter corresponding to the nth day only records the number of times the resource is accessed on the nth day; when the time elapses to the (n + 1) th day, the number of times the resource is accessed on the (n + 1) th day is recorded by using a counter corresponding to the (n + 1) th day; the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time; when the first resource is accessed, the counter is incremented by one, and the timestamp is updated from the time of the last previous access to the time of the current access.
Since the count and the timestamp of the counter corresponding to each resource are set, each time a resource is accessed, the count and the timestamp of the counter corresponding to the resource are updated, and thus the count and the timestamp of the counter corresponding to the resource at this time can reflect a case that the resource is accessed in a time period (the time period is also referred to as "specified time" herein) longer than the window period of the window-latest minimum elimination algorithm; the resources stored in the cache area may be determined according to the count of the counter corresponding to each resource and the time stamp. In this context, the "cache area" may be a memory, and may also be a Solid State Disk (SSD) or other high-performance device as the cache area. Because the data access speed of the cache region is obviously higher than that of the server, the operating system can firstly search whether the resources to be searched exist in the cache region, so as to save the time for searching the resources and the computing resources; and only when the resource to be searched is not found in the cache region, traversing the resource list of the resource pool (the traversing sequence is arranged according to the sequence of adding the resource pool) to search the storage position of the resource to be accessed in the server. Since the counts of the counters and the time stamps corresponding to the respective resources are learned, it is possible to sort out the number of times the resource has been accessed in a prescribed time and the time of the last access, and update the resources stored in the cache area and the sorting of the resources accordingly. Because the number of times that the resource is accessed in the specified time and the time that the resource is accessed last time can be sorted, when the hot resource which is always in a burst state in the window period is accessed, the number of times that the resource is accessed in the specified time and the time that the resource is accessed last time can be still sorted by means of the count and the timestamp of the counter corresponding to each resource which are continuously updated after the resource is accessed each time, so that the resources stored in the cache region and the sorting of the resources are updated, the recorded access histories are the same resource, and the condition that the access histories recorded when the window least recent elimination algorithm is adopted are the same resource and the condition that which resource stored in the cache region needs to be eliminated is not known is avoided. The robustness of the window-least-recently-eliminated algorithm is enhanced. In addition, compared with the least-recently-eliminated algorithm, the method reduces the occupation of the memory and the pollution of the cache.
In an alternative embodiment, as shown in FIG. 6, step S101 includes sub-steps S1011-S1015.
In sub-step S1011, when the resource access request is received, it is determined whether the resource to be accessed is stored in the cache region.
According to the method provided by the embodiment of the invention, if the resource is required to be searched when the resource access request is received, the resource is required to be searched from the cache region, and if the resource to be accessed is not searched in the cache region, the resource to be accessed is searched from the server. Therefore, in sub-step S1011, when a resource access request is received, it is first determined whether a resource to be accessed is stored in the cache region.
Sub-step S1013, if the resource to be accessed is not stored in the cache region, traversing the resource pool and updating the count and the timestamp of the counter corresponding to each resource among all the resources recorded in the resource list of the resource pool.
In sub-step S1013, at this time, the resource to be accessed is not stored in the cache region (that is, the resource to be accessed is not found in the cache region), so that it is necessary to traverse the resource list of the resource pool, and update the count and the timestamp of the counter corresponding to each resource recorded in the resource list.
Substep S1015, according to the count and the timestamp of the counter corresponding to each resource in all the resources recorded in the resource list of the resource pool, performing window-minimum elimination algorithm sorting on all the resources recorded in the resource list of the resource pool to update the resources stored in the cache region.
After the count and the timestamp of the counter corresponding to each resource are updated, at the moment, according to the count and the timestamp of the counter corresponding to each resource, sequencing all the resources by using a window least-recent elimination algorithm, then updating the resources stored in the cache region according to the sequencing result, and storing the resources in the cache region before sequencing.
In an optional embodiment, the method further comprises:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
In the method provided by the embodiment of the present invention, when accessing a resource in the cache region, the resource (the resource to be accessed) in the current time of access is recorded in the resource list of the resource pool, and the count and the timestamp of the counter corresponding to the resource are also updated, so that when traversing the resource in the future, the window least recent elimination algorithm sorting is performed on all the resources recorded in the resource list of the resource pool according to the count and the timestamp of the counter of each resource.
In an alternative embodiment, sub-step S1013 comprises:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time or not according to the timestamp which is recorded in the resource list and corresponds to each resource in all the resources;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
Here, the format of the counter held in the program may be a key-val format in which a key is a character string, for example, 20190801, and this value indicates the number of times accessed on which date the counter is to be recorded. The val value is a positive integer indicating the number of times the resource was accessed on the day of the key value. The minimum unit of "allotted time" may therefore be days. For example, if the specified time is 3 days and the current date is 2019, 3 and 5 days, in combination with the method of the embodiment of the present invention, since the timestamp is used to record the time when the corresponding resource was accessed last time, when traversing the resource pool, first, according to the timestamp corresponding to each resource, it is determined whether each resource was accessed within the specified time (for example, 3 and 3 days in 2019 to 3 and 5 days in 2019), and if some resources are not accessed, the record of this resource in the resource list is deleted. Therefore, when the sorting by the window-least-recently-eliminated algorithm is performed, the resources whose records in the resource list have been deleted are not included in the sorting. If it is determined that a resource has been accessed within a specified time (for example, 3/2019-3/5/2019) according to a timestamp corresponding to the resource, it indicates that the resource should be within the range of the sequencing of the window least recent elimination algorithm, at this time, the counts of the counters before the specified time of the resource (the counts of the counters before and 3/2/2019) may be deleted first, because the counts of the counters before the specified time (the counts of the counters before and 3/2/2019) may not be considered in the subsequent sequencing of the window least recent elimination algorithm, and the deletion of the counts may reduce the occupation of the memory; then, the window least recent elimination algorithm ranking is performed according to the count of the counter at the specified time (the accumulated count of the counter at 3 months and 3 days in 2019-3 months and 5 days in 2019). As described above, the counter corresponding to the nth day only records the number of times the resource was accessed on the nth day; when the time elapses to the n +1 th day, the number of times the resource is accessed on the n +1 th day is recorded using a counter corresponding to the n +1 th day, and if the count of the counter corresponding to the 3 rd, 3 rd and 3 rd days in 2019 is 4, the count of the counter corresponding to the 3 rd, 4 th day in 2019 is 2, and the count of the counter corresponding to the 5 th day in 3 and 3 th months in 2019 is 6, the count of the counter at the prescribed time is 12. The window least recent elimination algorithm ordering is performed using 12 as the count of the counter for the resource.
In an alternative embodiment, step S101 includes:
when performing the sorting of the minimum least recent elimination algorithm of the window on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the timestamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after the count and the time stamp of the counter corresponding to the resource to be accessed are updated in the resource list;
and if the resource to be accessed is not stored in the cache region, after the resource to be accessed is accessed in the server, updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list.
In order to solve the above technical problem, an embodiment of the present invention further provides an apparatus for updating resources stored in a cache region, as shown in fig. 7, the apparatus includes a memory 10 and a processor 20;
memory 10 is used to store computer readable instructions;
the processor 20 is configured to execute the computer-readable instructions to perform the following operations:
when traversing the resource pool to search the storage position of the resource to be accessed in the server, performing the minimum-recent elimination algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, so as to update the resource stored in the cache region according to the sorting result;
when a first resource in each resource is accessed, recording the first resource in a resource list of a resource pool and updating the count and the timestamp of a counter corresponding to the first resource; and the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time.
In an optional embodiment, when traversing the resource pool to find the storage location of the resource to be accessed in the server, according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, performing a window-least-recent-elimination-algorithm sorting on each resource recorded in the resource list, so as to update the resource stored in the cache area according to the sorting result, includes:
when a resource access request is received, judging whether a resource to be accessed is stored in a cache region;
traversing the resource pool and updating a count and a timestamp of a counter corresponding to each resource among all resources recorded in a resource list of the resource pool if the resource to be accessed is not stored in the cache region;
and according to the count and the timestamp of the counter corresponding to each resource in all the resources recorded in the resource list of the resource pool, performing window minimum elimination algorithm sorting on all the resources recorded in the resource list of the resource pool so as to update the resources stored in the cache region.
In an alternative embodiment, processor 20 also performs the following operations:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
In an alternative embodiment, the operation of traversing the resource pool and updating the count and the timestamp of the counter corresponding to each resource among all resources recorded in the resource list of the resource pool comprises:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time or not according to the timestamp which is recorded in the resource list and corresponds to each resource in all the resources;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
In an alternative embodiment, the operation of performing a window-least-recently-eliminated algorithm sorting on each resource recorded in the resource list to update the resources stored in the cache region according to the sorting result includes:
when performing the sorting of the minimum least recent elimination algorithm of the window on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the timestamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after the count and the time stamp of the counter corresponding to the resource to be accessed are updated in the resource list;
and if the resource to be accessed is not stored in the cache region, updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list after the resource to be accessed is accessed in the server.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (6)

1. A method for updating resources stored in a cache region, comprising:
when traversing a resource pool to search the storage position of a resource to be accessed in a server, performing the least-recently-eliminated window algorithm sorting on each resource recorded in a resource list of the resource pool according to the count and the timestamp of a counter corresponding to each resource recorded in the resource list, so as to update the resource stored in a cache region according to the sorting result;
when a first resource among the resources is accessed, recording the first resource in a resource list of the resource pool and updating the count and the timestamp of a counter corresponding to the first resource; the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time;
when traversing the resource pool to search the storage position of the resource to be accessed in the server, according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, performing the minimum-recent-elimination-window algorithm sorting on each resource recorded in the resource list, so as to update the resource stored in the cache region according to the sorting result, including:
when a resource access request is received, judging whether the resource to be accessed is stored in the cache region;
if the resource to be accessed is not stored in the cache region, traversing the resource pool and updating the count and the timestamp of a counter corresponding to each resource in all the resources recorded in a resource list of the resource pool;
performing a window-minimum-elimination algorithm sorting on all the resources recorded in the resource list of the resource pool according to the count and the timestamp of the counter corresponding to each resource among all the resources recorded in the resource list of the resource pool, so as to update the resources stored in the cache region;
the step of traversing the resource pool and updating a count and a timestamp of a counter corresponding to each resource among all resources recorded in a resource list of the resource pool includes:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time at present according to the timestamp corresponding to each resource in all the resources recorded in the resource list;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the count of the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
2. The method of claim 1, further comprising:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
3. The method of claim 1, wherein the step of performing a window-least-recently-culling algorithm ranking on each resource recorded in the resource list to update resources stored in a cache region according to a ranking result comprises:
when performing window-least-recent elimination algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the time stamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list;
if the resource to be accessed is not stored in the cache region, after the resource to be accessed is accessed in the server side, the count and the timestamp of the counter corresponding to the resource to be accessed are updated in the resource list.
4. An apparatus for updating resources stored in a cache region, comprising a processor and a memory;
the memory is to store computer readable instructions;
the processor is configured to execute the computer-readable instructions to perform operations comprising:
when traversing a resource pool to search the storage position of a resource to be accessed in a server, performing the least-recently-eliminated window algorithm sorting on each resource recorded in a resource list of the resource pool according to the count and the timestamp of a counter corresponding to each resource recorded in the resource list, so as to update the resource stored in a cache region according to the sorting result;
when a first resource among the resources is accessed, recording the first resource in a resource list of the resource pool and updating the count and the timestamp of a counter corresponding to the first resource; and the counter corresponding to the first resource records the number of times of access to the first resource, and the timestamp corresponding to the first resource is the time when the first resource is accessed last time;
when traversing the resource pool to find the storage location of the resource to be accessed in the server, the operation of performing the minimum-recent-elimination-window algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, so as to update the resource stored in the cache region according to the sorting result, includes:
when a resource access request is received, judging whether the resource to be accessed is stored in the cache region;
if the resource to be accessed is not stored in the cache region, traversing the resource pool and updating the count and the timestamp of a counter corresponding to each resource in all the resources recorded in a resource list of the resource pool;
performing a window-minimum-elimination algorithm sorting on all the resources recorded in the resource list of the resource pool according to the count and the timestamp of the counter corresponding to each resource among all the resources recorded in the resource list of the resource pool, so as to update the resources stored in the cache region;
the operation of traversing the resource pool and updating a count and a timestamp of a counter corresponding to each resource among all resources recorded in a resource list of the resource pool includes:
when traversing the resource pool, judging whether the time of each resource which is accessed last time exceeds the specified time or not according to the timestamp corresponding to each resource in all the resources recorded in the resource list;
if the specified time is exceeded, deleting the record of the resource which is accessed last time and exceeds the specified time so far in the resource list, and clearing the count of the counter of the resource which is accessed last time and does not exceed the specified time so far before the specified time.
5. The apparatus of claim 4, wherein the processor further performs the following:
and if the resource to be accessed is judged to be stored in the cache region, accessing the resource to be accessed in the cache region, and updating the count and the time stamp of the counter corresponding to the resource to be accessed.
6. The apparatus of claim 4, wherein the operation of performing a window-least-recently-eliminated algorithm ranking on the resources recorded in the resource list to update the resources stored in the cache region according to the ranking result comprises:
when performing window-least-recent elimination algorithm sorting on each resource recorded in the resource list according to the count and the timestamp of the counter corresponding to each resource recorded in the resource list of the resource pool, judging whether the number of the sorted resources is more than the number of the resources which can be stored in the cache region:
if the number of the sorted resources is not more than the number of the resources which can be stored in the cache region, after the resources to be accessed are accessed from the cache region and the count and the time stamp of the counter corresponding to the resources to be accessed are updated in the resource list, the sorted resources are stored in the cache region according to a sorting sequence;
if the number of the sorted resources is more than the number of the resources which can be stored in the cache region, judging whether the resources to be accessed are stored in the cache region according to the sorting:
if the resource to be accessed is stored in the cache region, accessing the resource to be accessed in the server side and storing the resource to be accessed in the cache region after updating the count and the timestamp of the counter corresponding to the resource to be accessed in the resource list;
if the resource to be accessed is not stored in the cache region, after the resource to be accessed is accessed in the server side, the count and the timestamp of the counter corresponding to the resource to be accessed are updated in the resource list.
CN201910735316.8A 2019-08-09 2019-08-09 Method and device for updating resources stored in cache region Active CN110569261B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910735316.8A CN110569261B (en) 2019-08-09 2019-08-09 Method and device for updating resources stored in cache region

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910735316.8A CN110569261B (en) 2019-08-09 2019-08-09 Method and device for updating resources stored in cache region

Publications (2)

Publication Number Publication Date
CN110569261A CN110569261A (en) 2019-12-13
CN110569261B true CN110569261B (en) 2022-07-12

Family

ID=68775032

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910735316.8A Active CN110569261B (en) 2019-08-09 2019-08-09 Method and device for updating resources stored in cache region

Country Status (1)

Country Link
CN (1) CN110569261B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104750715A (en) * 2013-12-27 2015-07-01 中国移动通信集团公司 Data elimination method, device and system in caching system and related server equipment
CN106649313A (en) * 2015-10-29 2017-05-10 阿里巴巴集团控股有限公司 Method and equipment for processing cache data
CN107451071A (en) * 2017-08-04 2017-12-08 郑州云海信息技术有限公司 A kind of caching replacement method and system
CN108763110A (en) * 2018-03-22 2018-11-06 新华三技术有限公司 A kind of data cache method and device
CN109359095A (en) * 2018-09-11 2019-02-19 东华大学 A kind of DLK method that big data is quickly read

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104750715A (en) * 2013-12-27 2015-07-01 中国移动通信集团公司 Data elimination method, device and system in caching system and related server equipment
CN106649313A (en) * 2015-10-29 2017-05-10 阿里巴巴集团控股有限公司 Method and equipment for processing cache data
CN107451071A (en) * 2017-08-04 2017-12-08 郑州云海信息技术有限公司 A kind of caching replacement method and system
CN108763110A (en) * 2018-03-22 2018-11-06 新华三技术有限公司 A kind of data cache method and device
CN109359095A (en) * 2018-09-11 2019-02-19 东华大学 A kind of DLK method that big data is quickly read

Also Published As

Publication number Publication date
CN110569261A (en) 2019-12-13

Similar Documents

Publication Publication Date Title
EP3229142B1 (en) Read cache management method and device based on solid state drive
US8601216B2 (en) Method and system for removing cache blocks
US5778430A (en) Method and apparatus for computer disk cache management
US8161241B2 (en) Temperature-aware buffered caching for solid state storage
US8825959B1 (en) Method and apparatus for using data access time prediction for improving data buffering policies
US9779027B2 (en) Apparatus, system and method for managing a level-two cache of a storage appliance
US6807607B1 (en) Cache memory management system and method
US7673105B2 (en) Managing memory pages
US20060075007A1 (en) System and method for optimizing a storage system to support full utilization of storage space
CN1130641C (en) Recoverable disk control system with nonvolatile memory
US6842826B1 (en) Method and apparatus for providing efficient management of least recently used (LRU) algorithm insertion points corresponding to defined times-in-cache
EP4321980A1 (en) Method and apparatus for eliminating cache memory block, and electronic device
US20050283573A1 (en) System and method for an optimized least recently used lookup cache
US9851925B2 (en) Data allocation control apparatus and data allocation control method
JP2017162194A (en) Data management program, data management device, and data management method
CN110569261B (en) Method and device for updating resources stored in cache region
US7836248B2 (en) Methods and systems for managing persistent storage of small data objects
JPH08263380A (en) Disk cache control system
US11093397B1 (en) Container-based flash cache with a survival queue
US9710183B2 (en) Effectively limitless apparent free space on storage device
US20220179782A1 (en) Buffer pool maintenance improvement
US20220342564A1 (en) Method, electronic device, and computer program product for storage management
Burleson Creating a Self-Tuning Oracle Database: Automating Oracle9i Dynamic Sga Performance
CN117785933A (en) Data caching method, device, equipment and readable storage medium
CN113282585A (en) Report calculation method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant