CN109947665B - Caching method and device - Google Patents

Caching method and device Download PDF

Info

Publication number
CN109947665B
CN109947665B CN201711387705.3A CN201711387705A CN109947665B CN 109947665 B CN109947665 B CN 109947665B CN 201711387705 A CN201711387705 A CN 201711387705A CN 109947665 B CN109947665 B CN 109947665B
Authority
CN
China
Prior art keywords
cache
probability
caching
access
area
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
CN201711387705.3A
Other languages
Chinese (zh)
Other versions
CN109947665A (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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201711387705.3A priority Critical patent/CN109947665B/en
Publication of CN109947665A publication Critical patent/CN109947665A/en
Application granted granted Critical
Publication of CN109947665B publication Critical patent/CN109947665B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

Disclosed herein is a caching method and apparatus; the caching method comprises the following steps: calculating the caching probability of the object according to the size of the object requested by the access request; based on the object's cache probability, it is determined whether to write the object to the cache region. In this way, the object hit rate OHR of the cache area can be improved on the premise of ensuring the byte hit rate BHR of the cache area.

Description

Caching method and device
Technical Field
The present disclosure relates to, but not limited to, data processing technologies, and in particular, to a caching method and apparatus.
Background
In order to improve the data access efficiency, a memory or a multi-level cache area of an SSD (Solid State Drives, solid state disk) is generally added before the disk is stored. However, since this portion of storage space is much smaller than the disk storage space, it is necessary to increase the utilization of the buffer area by a certain algorithm. Algorithms currently in common use include FIFO (First Input First Output, first in first out), LRU (Least Recently Used ), LFU (Least Frequently Used, least recently used), S4LRU, and the like. When the FIFO needs to add cache area access miss data, eliminating the data of the first advance queue; the LRU maintains a priority queue (small top stack) ordered according to the access times, and eliminates the data at the head of the queue (with the minimum access times) each time the data need to be eliminated; the LFU maintains a priority queue which is ordered according to the access times and then the access time; the S4LRU is implemented by a multi-layer LRU. These algorithms typically eliminate data in the cache region based on the number of accesses and access time of the data, however, in some scenarios, the processing of the above algorithm cannot ensure OHR (Object Hit Ratio) of the cache region.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the application provides a caching method and device, which can improve the OHR (Object Hit Ratio) of a cache area on the premise of ensuring the BHR (Bit Hit Ratio) of the cache area.
In a first aspect, an embodiment of the present application provides a caching method, including:
calculating the caching probability of the object according to the size of the object requested by the access request;
and determining whether the object is written into a cache area according to the cache probability of the object.
In an exemplary embodiment, the calculating the buffering probability of the object according to the size of the object requested by the access request may include one of the following:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area;
determining an object set to which the object belongs according to the size of the object requested by the access request; and calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area.
In an exemplary embodiment, the calculating the buffering probability of the object according to the access ratio and the storage ratio of the object set in the buffering area may include:
calculating the caching probability of the object according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents a cache probability of the object, α represents a weight factor, α is greater than 0 and less than 1, a represents an access ratio of an object set to which the object belongs, S represents a storage ratio of the object set to which the object belongs, and P' represents a cache replacement probability determined according to at least one of an access frequency and an access time of the object.
In an exemplary embodiment, the determining whether to write the object into the cache area according to the cache probability of the object may include:
when the caching probability of the object is larger than a probability threshold, determining to write the object into a caching area;
when the caching probability of the object is smaller than or equal to a probability threshold value, determining that the object is not cached in a caching area;
and after the cache area is fully written, the value of the probability threshold is the minimum value in the cache probabilities of all objects in the cache area.
In an exemplary embodiment, the above method may further include:
and if the object requested by the access request does not exist in the cache area and the size of the object is smaller than or equal to a threshold value, determining to write the object into the cache area.
In an exemplary embodiment, before calculating the cache probability of the object according to the size of the object requested by the access request, the method may further include:
after receiving an access request, judging whether an object requested by the access request exists in a cache area;
and when the object is not in the cache area, reading the object from a source station or other storage area of the object, and determining the size of the object.
In a second aspect, an embodiment of the present application provides a buffering device, including:
the cache probability calculation module is suitable for calculating the cache probability of the object according to the size of the object requested by the access request;
and the cache determining module is suitable for determining whether the object is written into the cache area according to the cache probability of the object.
In an exemplary embodiment, the cache probability calculation module may be adapted to calculate the cache probability of the object requested by the access request according to the size of the object by one of the following ways:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area;
determining an object set to which the object belongs according to the size of the object requested by the access request; and calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area.
In an exemplary embodiment, the cache determining module may be adapted to determine whether to write the object to the cache region according to a cache probability of the object by:
when the caching probability of the object is larger than a probability threshold, determining to write the object into a caching area;
when the caching probability of the object is smaller than or equal to a probability threshold value, determining that the object is not cached in a caching area;
and after the cache area is fully written, the value of the probability threshold is the minimum value in the cache probabilities of all objects in the cache area.
In a third aspect, an embodiment of the present application provides a buffering device, including: a memory and a processor; the memory is used for storing a cache program; the caching program, when read and executed by the processor, performs the following operations:
calculating the caching probability of the object according to the size of the object requested by the access request;
and determining whether the object is written into a cache area according to the cache probability of the object.
In addition, an embodiment of the present application further provides a computer readable medium storing a cache program, where the cache program when executed by a processor implements the steps of:
calculating the caching probability of the object according to the size of the object requested by the access request;
and determining whether the object is written into a cache area according to the cache probability of the object.
In the embodiment of the application, according to the size of the object requested by the access request, calculating the caching probability of the object; based on the object's cache probability, it is determined whether to write the object to the cache region. In the embodiment of the application, based on the size of the object, it is determined whether to write the object into the cache area. In this way, on the premise of ensuring the BHR of the buffer area, the OHR of the buffer area can be improved. For example, the hit rate of the small file in the cache area in the CDN (Content Delivery Network ) system can be improved.
Of course, it is not necessary for any of the products of the present application to be practiced with all of the above advantages.
Drawings
Fig. 1 is a schematic diagram of an implementation scenario of a caching method provided in an embodiment of the present application;
FIG. 2 is a flowchart of a caching method according to an embodiment of the present application;
FIG. 3 is an example flowchart of a caching method provided in an embodiment of the present application;
fig. 4 is a schematic diagram of a buffering device provided in an embodiment of the present application.
Detailed Description
The following detailed description of embodiments of the present application is provided in connection with the accompanying drawings, and it is to be understood that the embodiments described below are merely illustrative and explanatory of the application, and are not restrictive of the application.
It should be noted that, if not conflicting, the embodiments of the present application and the features of the embodiments may be combined with each other, which are all within the protection scope of the present application. In addition, while a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in a different order than is shown.
In some implementations, a computing device executing the caching method may include one or more processors (CPUs), input/output interfaces, network interfaces, and memory (memory).
The memory may include forms of non-volatile memory, random Access Memory (RAM), and/or nonvolatile memory in a computer-readable medium, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media. The memory may include module 1, module 2, … …, module N (N is an integer greater than 2).
Computer readable media include both non-transitory and non-transitory, removable and non-removable storage media. The storage medium may implement information storage by any method or technique. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only optical disk read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer readable media, as defined herein, does not include non-transitory computer readable media (transmission media), such as modulated data signals and carrier waves.
The concepts mentioned in the present application are explained first below.
Object Hit Ratio (OHR) refers to the probability that an Object (e.g., file) requesting access hits a cache within a period of time. That is, the OHR may be equal to a ratio of the number of objects present in the buffer area requesting access to the total number of objects requesting access for a period of time.
The Byte Hit Rate (BHR) refers to the probability that a byte requesting access hits the cache for a period of time. That is, the BHR may be equal to the ratio of the total number of bytes of the object present in the cache area requesting access to the total number of bytes of the object requesting access for a period of time.
Fig. 1 is a schematic diagram of an implementation scenario of a caching method according to an embodiment of the present application. The caching method provided in this embodiment can be applied to CDN (Content Delivery Network ).
As shown in fig. 1, after receiving an access request from a terminal (for example, a mobile terminal such as a smart phone, a notebook computer, or a fixed terminal such as a desktop computer), a CDN node queries whether an object requested by the access request exists in a local cache area, and if so, the CDN node reads the object requested by the access request from the local cache area and returns the object to the terminal; if the CDN node inquires that the local cache area does not have the object requested by the access request, the CDN node reads the object from a source station where the object is located or other CDN nodes cached with the object, and then returns the object to the terminal; and, the CDN node determines whether to store the object in the local cache region.
Assuming that the size of the buffer area on a CDN node is 1GB, a user accesses 1 ten thousand files by using a Round Robin (RR) method, where 9999 files of 100KB and 1 file of 500MB are included. When the access heat of the 1-ten thousand files is averaged, every time a 500MB file enters the cache area, about 5000 files with 100KB are removed from the cache area, and the average OHR is about 50%. Therefore, the mode of replacing the content of the cache area based on the access heat is unfair to the small files, and the hit rate of the small files in the cache area in the scene is more improved than that of the large files.
Additionally, in some CDN scenarios, there is a time difference in the size of the object requested by the access request. For example, 8:00 a.m. to 10:00 a.m., the size of the object requesting access is around 180K (e.g., the user typically accesses the file content of the information class in the morning), and 20:00 a.m. to 24:00 a.m., the size of the object requesting access is around 250K (e.g., the user typically accesses the video file in the evening). In some CDN scenarios, there is a large difference in the size of objects that are requested to be accessed by access requests received on nodes of different service types. For example, the size of an object requested to be accessed by an access request received at a node providing video access is 1000K or more, and the size of an object requested to be accessed by an access request received at a node providing text access is about 30K.
Therefore, when determining the content replacement policy of the cache area, only the access times and access time of the data in the cache area are considered, and the OHR of the cache area cannot be improved.
The embodiment provides a caching method, which determines whether to cache an object based on the size of the object to be cached, so that on the premise of not reducing the BHR as much as possible, the OHR of a cache area is improved.
It should be noted that, the implementation scenario of the caching method provided in this embodiment is not limited to the scenario shown in fig. 1, and may be applied to other scenarios. The present application is not limited in this regard.
Fig. 2 is a flowchart of a caching method provided in an embodiment of the present application. As shown in fig. 2, the caching method provided in this embodiment includes the following steps:
s201, calculating the caching probability of an object according to the size of the object requested by the access request;
s202, determining whether the object is written into a cache area according to the cache probability of the object.
Before S201, the caching method of this embodiment may further include:
after receiving the access request, judging whether an object requested by the access request exists in the cache area;
when the object is not in the cache region, the object is read from the source or other storage region of the object and the size of the object is determined.
Taking the caching method of the embodiment as an example, after the CDN node receives an access request of the terminal, the CDN node determines whether an object requested by the access request exists in a local cache region according to information (for example, information such as an object identifier, an object name, etc.) carried by the access request; if the local cache area does not have the object, the CDN node can request the object from a source station of the object, or can acquire the object from other CDN nodes cached with the object; after acquiring the object, the CDN node can determine the size of the object, namely, determine the size of the space occupied by the object; then, the CDN node may execute S201 and S202 to determine whether to write the object into a local cache region, and at the same time, the CDN node may return the object to the terminal after obtaining the object; in addition, if the CDN node determines that the object exists in the local cache region, the object may be directly read from the local cache region and returned to the terminal.
In an exemplary embodiment, S201 may include one of:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area;
determining an object set to which the object belongs according to the size of the object requested by the access request; and calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area.
The objects in the cache area may be divided into multiple sets according to the size of the objects, for example, an object with a size of 0 to 1KB belongs to one set of objects, and an object with a size of 4 to 8KB belongs to another set of objects.
For each set of objects, the access and storage duty cycles within a set time period may be counted. The access ratio of one object set can be determined according to the ratio of the access amount of all objects in the object set to the access amount of all objects in the cache area in a set time length; the storage duty cycle of an object set may be determined based on the ratio of the number of objects in the object set stored in the cache area to the total number of objects stored in the cache area.
Wherein, the cumulative access ratio of one object set can be determined according to the sum of the access ratio of the object set in the buffer area and the access ratio of other object sets with the object size smaller than the minimum object in the object set; the cumulative storage duty cycle of one set of objects may be determined from the sum of the storage duty cycle of that set of objects within the cache region and the storage duty cycle of other sets of objects having an object size smaller than the smallest object within that set of objects. For example, the objects in the buffer area are divided into three object sets A, B, C in order of the object sizes from small to large, and the object size in the object set C is larger than the object size in the object set B, and the object size in the object set B is larger than the object size in the object set a, so that the cumulative access ratio of the object set a is equal to the access ratio of the object set a, the cumulative access ratio of the object set B may be equal to the sum of the access ratios of the object sets a and B, and the cumulative access ratio of the object set C may be equal to the sum of the access ratios of the object sets A, B and C.
In an exemplary embodiment, calculating the cache probability of the object according to the access ratio and the storage ratio of the object set in the cache area may include:
calculating the cache probability of the object according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents the cache probability of the object, alpha represents the weight factor, alpha is larger than 0 and smaller than 1, A represents the access duty ratio of the object set to which the object belongs, S represents the storage duty ratio of the object set to which the object belongs, and P' represents the cache replacement probability determined according to at least one of the access frequency and the access time of the object.
In other exemplary embodiments, a may also be the cumulative access duty cycle of the set of objects to which the object belongs, and S may also be the cumulative storage duty cycle of the set of objects to which the object belongs.
The weighting factor alpha can adjust the affinity to the storage duty ratio or the access duty ratio, the storage duty ratio can reflect the history condition of the object set in the cache area, and the access duty ratio can reflect the current condition of the object set in the cache area.
The cache replacement probability P' can be determined according to a cache content replacement algorithm adopted by the cache region; when the adopted algorithm is different, the calculation mode of the cache replacement probability P' is also different. The present application is not limited in this regard.
In an exemplary embodiment, S202 may include:
when the caching probability of the object is larger than the probability threshold, determining to write the object into the caching area;
when the caching probability of the object is smaller than or equal to the probability threshold value, determining that the object is not cached in the caching area;
the initial value of the probability threshold is 0, and after the cache area is fully written, the value of the probability threshold can be the minimum value in the cache probabilities of all objects in the cache area.
In this embodiment, the probability threshold may be dynamically changed after the cache area is full. Through the probability threshold value of dynamic change, the objects cached in the cache area can adapt to scene change to change.
In an exemplary embodiment, the caching method of the present embodiment may further include:
if the object requested by the access request does not exist in the cache area and the size of the object is smaller than or equal to the threshold value, determining to write the object into the cache area.
Wherein, a threshold MSize of the buffer memory object size can be set for the scene of relatively fixed access object size; if the cache area does not have the object which requests access and the size of the object which requests access is larger than the threshold MSize, the object is not cached in the cache area; if the cache area does not have the object which requests access and the size of the object which requests access is smaller than or equal to the threshold MSize, writing the object in the cache area.
Fig. 3 is an example flowchart of a caching method provided in an embodiment of the present application. The caching method of the present embodiment will be described by taking as an example the execution of any CDN node in fig. 1.
In this example, the CDN node may count the size distribution and access of objects in the local cache area over the past N minutes (e.g., 5 minutes). Wherein, N can be adjusted according to real-time requirement, this application is not limited to this. The statistics of object sizes in the cache area of CDN nodes are described below using table 1 as an example.
Figure BDA0001516937770000091
/>
Figure BDA0001516937770000101
TABLE 1
In table 1, the access ratio a of one object set in the cache area is equal to the ratio of the access amount of all objects in the object set to the access amount of all objects in the cache area in the past N minutes; the storage duty ratio S of an object set is equal to the ratio of the total number of objects in the object set to the total number of all objects in the cache area.
As shown in fig. 3, the buffering method provided in this embodiment includes:
s301, receiving an access request of a request end (such as a user terminal);
s302, judging whether an object requested by an access request exists in a local cache area; if the object exists in the local cache area, executing S303, otherwise, executing S304;
s303, reading the object from the local cache area and returning the object to the request end; updating the cache probability and probability threshold value of each object in the cache region;
in this step, for example, when the size of the currently read object is 6KB, the object belongs to the object set 4 in table 1, and since the number of accesses to the cache area is changed, the access ratio of each object set in the cache area and the cache probability of each object can be updated.
When the cache area is not fully written, the value of the probability threshold value is 0; after the cache area is fully written, the value of the probability threshold value is dynamically changed, namely the minimum value in the cache probability of all objects in the cache area.
S304, reading the object from a source station of the object or other CDN nodes cached with the object, and returning the object to the request end; determining the size of the object according to the read object; calculating the caching probability of the object according to the size of the object;
in this step, according to the size of the read object, the object set to which the object belongs is determined, for example, the size of the object is 3KB, as can be seen from table 1, the object set to which the object belongs is object set 3, and the access ratio a of the object set 3 in the past N minutes is 35%, and the storage ratio S is 33%; the cache probability for the object may then be calculated according to the following equation:
P=P’×(α×A+(1-α)×S);
wherein A is the access ratio of the object set to which the object belongs in the cache area, and S is the storage ratio of the object set to which the object belongs in the cache area; 0< alpha <1, and the cache probability affinity to the storage duty ratio (history condition) or the access duty ratio (current condition) can be adjusted by adjusting the value of alpha; p' is a cache replacement probability determined according to a cache region replacement algorithm, and can be determined based on at least one of an access frequency and an access time of the object within a set duration.
S305, comparing the cache probability of the object with the latest probability threshold; if the cache probability of the object is greater than the probability threshold, executing S306; if the buffering probability of the object is less than or equal to the probability threshold, then S307 is executed;
s306, determining to write the object into a local cache area;
after this step, the storage duty cycle of each object set in the cache area may be changed, so that the cache probability and probability threshold of each object in the cache area may be updated.
S307, determining not to write the object into the local cache area.
Fig. 4 is a schematic diagram of a buffering device provided in an embodiment of the present application. As shown in fig. 4, the buffering device provided in this embodiment includes:
a cache probability calculation module 401 adapted to calculate a cache probability of an object requested by the access request according to the size of the object;
the cache determination module 402 is adapted to determine whether to write the object to the cache area according to the cache probability of the object.
In an exemplary embodiment, the cache probability calculation module 401 may be adapted to calculate the cache probability of an object requested by an access request from the size of the object by one of the following ways:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area;
determining an object set to which the object belongs according to the size of the object requested by the access request; and calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area.
In an exemplary embodiment, the cache probability calculation module 401 is adapted to calculate the cache probability of an object in the cache region from the access and storage duty cycles of the set of objects by:
the caching probability of the object is calculated according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents a cache probability of the object, α represents a weight factor, α is greater than 0 and less than 1, a represents an access duty ratio of an object set to which the object belongs, S represents a storage duty ratio of the object set to which the object belongs, and P' represents a cache replacement probability determined according to at least one of an access frequency and an access time of the object.
In an exemplary embodiment, the cache determination module 402 may be adapted to determine whether to write the object to the cache region according to the cache probability of the object by:
when the caching probability of the object is larger than a probability threshold value, determining to write the object into a caching area;
when the caching probability of the object is smaller than or equal to a probability threshold value, determining that the object is not cached in a caching area;
the initial value of the probability threshold is 0, and after the cache area is fully written, the value of the probability threshold is the minimum value in the cache probabilities of all objects in the cache area.
In an exemplary embodiment, the cache determination module 402 is further adapted to determine to write an object requested by the access request to the cache region if the object is not present in the cache region and the size of the object is less than or equal to the threshold.
In an exemplary embodiment, the buffering device of this embodiment may further include:
the judging module is suitable for judging whether an object requested by the access request exists in the cache area after the access request is received;
and the object acquisition module is suitable for reading the object from a source station or other storage area of the object when the object is not in the cache area and determining the size of the object.
The description of the buffering device provided in this embodiment may refer to the description of the buffering method, so that the description is omitted here.
The embodiment of the application further provides a caching device, which comprises: the device comprises a memory and a processor, wherein the memory is used for storing a cache program; the caching program, when read and executed by the processor, executes the steps of the caching method provided in the present embodiment.
The caching apparatus provided in this embodiment may be disposed at a CDN node in fig. 1. However, the present application is not limited thereto.
The processor may include, but is not limited to, a microprocessor (MCU, microcontroller Unit), a programmable logic device (FPGA, field Programmable Gate Array), or the like. The memory may be used to store software programs and modules of application software, such as program instructions or modules corresponding to the caching method in this embodiment, and the processor executes the software programs and modules stored in the memory, thereby executing various functional applications and data processing, that is, implementing the above-mentioned caching method. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, the memory may further include memory remotely located with respect to the processor, the remote memory being connectable to the cache device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The above-mentioned buffer device may further include: a communication unit that can receive or transmit data via a network. In one example, the communication unit may be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In addition, the embodiment of the application further provides a computer readable medium storing a caching program, where the caching program implements the steps of the caching method when executed by a processor.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on machine-readable media (e.g., computer-readable media), which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media.
The foregoing has outlined and described the basic principles and main features of the present application and the advantages of the present application. The present application is not limited to the embodiments described above, which are described in the foregoing embodiments and description merely illustrate the principles of the application, and various changes and modifications can be made therein without departing from the spirit and scope of the application, which is defined by the claims.

Claims (8)

1. A caching method, comprising:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area; or (b)
Determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area; determining whether the object is written into a cache area according to the cache probability of the object;
wherein the cache probability of the object is calculated according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents a cache probability of the object, α represents a weight factor, α is greater than 0 and less than 1, a represents an access ratio or an accumulated access ratio of an object set to which the object belongs, S represents a storage ratio or an accumulated storage ratio of the object set to which the object belongs, and P' represents a cache replacement probability determined according to at least one of an access frequency and an access time of the object.
2. The method of claim 1, wherein determining whether to write the object to a cache region based on the object's cache probability comprises:
when the caching probability of the object is larger than a probability threshold, determining to write the object into a caching area;
when the caching probability of the object is smaller than or equal to a probability threshold value, determining that the object is not cached in a caching area;
and after the cache area is fully written, the value of the probability threshold is the minimum value in the cache probabilities of all objects in the cache area.
3. The method according to claim 1, wherein the method further comprises:
and if the object requested by the access request does not exist in the cache area and the size of the object is smaller than or equal to a threshold value, determining to write the object into the cache area.
4. A method according to claim 1 or 3, wherein before calculating the cache probability of the object according to the size of the object requested by the access request, the method further comprises:
after receiving an access request, judging whether an object requested by the access request exists in a cache area;
and when the object is not in the cache area, reading the object from a source station or other storage area of the object, and determining the size of the object.
5. A caching apparatus, comprising:
the cache probability calculation module is suitable for determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area; or (b)
Determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area; wherein the cache probability of the object is calculated according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents the caching probability of the object, alpha represents a weight factor, alpha is larger than 0 and smaller than 1, A represents the access ratio or the accumulated access ratio of the object set to which the object belongs, S represents the storage ratio or the accumulated storage ratio of the object set to which the object belongs, and P' represents the caching replacement probability determined according to at least one of the access frequency and the access time of the object;
and the cache determining module is suitable for determining whether the object is written into the cache area according to the cache probability of the object.
6. The apparatus of claim 5, wherein the cache determination module is adapted to determine whether to write the object to a cache region based on a cache probability of the object by:
when the caching probability of the object is larger than a probability threshold, determining to write the object into a caching area;
when the caching probability of the object is smaller than or equal to a probability threshold value, determining that the object is not cached in a caching area;
and after the cache area is fully written, the value of the probability threshold is the minimum value in the cache probabilities of all objects in the cache area.
7. A caching apparatus, comprising: a memory and a processor; the memory is used for storing a cache program; the caching program, when read and executed by the processor, performs the following operations:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area; or (b)
Determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area;
determining whether the object is written into a cache area according to the cache probability of the object;
wherein the cache probability of the object is calculated according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents a cache probability of the object, α represents a weight factor, α is greater than 0 and less than 1, a represents an access ratio or an accumulated access ratio of an object set to which the object belongs, S represents a storage ratio or an accumulated storage ratio of the object set to which the object belongs, and P' represents a cache replacement probability determined according to at least one of an access frequency and an access time of the object.
8. A computer readable medium, characterized in that a caching program is stored, which caching program, when executed by a processor, performs the steps of:
determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the access ratio and the storage ratio of the object set in the caching area; or (b)
Determining an object set to which the object belongs according to the size of the object requested by the access request; calculating the caching probability of the object according to the accumulated access proportion and the accumulated storage proportion of the object set in the caching area;
determining whether the object is written into a cache area according to the cache probability of the object;
wherein the cache probability of the object is calculated according to the following formula:
P=P’×(α×A+(1-α)×S);
wherein P represents a cache probability of the object, α represents a weight factor, α is greater than 0 and less than 1, a represents an access ratio or an accumulated access ratio of an object set to which the object belongs, S represents a storage ratio or an accumulated storage ratio of the object set to which the object belongs, and P' represents a cache replacement probability determined according to at least one of an access frequency and an access time of the object.
CN201711387705.3A 2017-12-20 2017-12-20 Caching method and device Active CN109947665B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711387705.3A CN109947665B (en) 2017-12-20 2017-12-20 Caching method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711387705.3A CN109947665B (en) 2017-12-20 2017-12-20 Caching method and device

Publications (2)

Publication Number Publication Date
CN109947665A CN109947665A (en) 2019-06-28
CN109947665B true CN109947665B (en) 2023-06-13

Family

ID=67004409

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711387705.3A Active CN109947665B (en) 2017-12-20 2017-12-20 Caching method and device

Country Status (1)

Country Link
CN (1) CN109947665B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5751993A (en) * 1995-09-05 1998-05-12 Emc Corporation Cache management system
CN1480850A (en) * 2002-12-04 2004-03-10 联想(北京)有限公司 Method for dynamic transferring data and its storing system
CN102576350A (en) * 2009-08-21 2012-07-11 谷歌公司 System and method of caching information
CN106612329A (en) * 2016-12-29 2017-05-03 北京奇艺世纪科技有限公司 Caching method and device
CN107038127A (en) * 2017-02-08 2017-08-11 阿里巴巴集团控股有限公司 Application system and its buffer control method and device
CN107247675A (en) * 2017-05-31 2017-10-13 华中科技大学 A kind of caching system of selection and system based on classification prediction

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9424194B2 (en) * 2012-05-01 2016-08-23 International Business Machines Corporation Probabilistic associative cache
US9323695B2 (en) * 2012-11-12 2016-04-26 Facebook, Inc. Predictive cache replacement

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5751993A (en) * 1995-09-05 1998-05-12 Emc Corporation Cache management system
CN1480850A (en) * 2002-12-04 2004-03-10 联想(北京)有限公司 Method for dynamic transferring data and its storing system
CN102576350A (en) * 2009-08-21 2012-07-11 谷歌公司 System and method of caching information
CN106612329A (en) * 2016-12-29 2017-05-03 北京奇艺世纪科技有限公司 Caching method and device
CN107038127A (en) * 2017-02-08 2017-08-11 阿里巴巴集团控股有限公司 Application system and its buffer control method and device
CN107247675A (en) * 2017-05-31 2017-10-13 华中科技大学 A kind of caching system of selection and system based on classification prediction

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种基于SDN的ICN高效缓存机制;雷方元等;《计算机科学》;20160815(第08期);全文 *
内容中心网络概率缓存策略的研究;张俊等;《新疆师范大学学报(自然科学版)》;20170930(第03期);全文 *

Also Published As

Publication number Publication date
CN109947665A (en) 2019-06-28

Similar Documents

Publication Publication Date Title
CN105740164B (en) Multi-core processor supporting cache consistency, reading and writing method, device and equipment
CN107066397B (en) Method, system, and storage medium for managing data migration
US10169240B2 (en) Reducing memory access bandwidth based on prediction of memory request size
US8271729B2 (en) Read and write aware cache storing cache lines in a read-often portion and a write-often portion
US9665658B2 (en) Non-blocking queue-based clock replacement algorithm
US9501419B2 (en) Apparatus, systems, and methods for providing a memory efficient cache
US20150143045A1 (en) Cache control apparatus and method
US20200117462A1 (en) Memory integrated circuit and pre-fetch method thereof
US11899580B2 (en) Cache space management method and apparatus
US9465743B2 (en) Method for accessing cache and pseudo cache agent
EP3115904A1 (en) Method for managing a distributed cache
CN116897335A (en) Cache replacement method and device
CN113094392A (en) Data caching method and device
KR20100005539A (en) Cache memory system and prefetching method thereof
CN109947665B (en) Caching method and device
KR20160018204A (en) Electronic device, On-Chip memory and operating method of the on-chip memory
US10860498B2 (en) Data processing system
CN115080459A (en) Cache management method and device and computer readable storage medium
CN113297106A (en) Data replacement method based on hybrid storage, related method, device and system
CN112559574B (en) Data processing method, device, electronic equipment and readable storage medium
WO2022028165A1 (en) Cache management method, terminal, and storage medium
CN116107926B (en) Cache replacement policy management method, device, equipment, medium and program product
CN113821173B (en) Data storage method, device, equipment and computer readable storage medium
CN116069719A (en) Processor, memory controller, system-on-chip and data prefetching method
WO2021103020A1 (en) Cache memory and method for allocating write operation

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