A CDN cache replacement method

By using fixed-size memory tables and hash indexes in the CDN cache system, the problem of low disk IO efficiency in the prior art is solved, efficient cache replacement is achieved, and access speed and hit rate are improved.

CN118760631BActive Publication Date: 2024-12-27JIANGXI QIUSHI INST OF ADVANCED STUDIES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411252239.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-12-27
Estimated Expiration
2044-09-09

AI Technical Summary

Technical Problem

Existing CDN cache replacement algorithms such as LRU and MRU fail to effectively consider access frequency, resulting in frequent cache replacement, resulting in low disk IO efficiency and large pulling traffic to the upper-level nodes.

Method used

Using a memory table with a fixed size space, resource fragments are stored through slices and hash indexes, and quick search operations are used to insert and update, to realize a hotspot update mechanism, reduce direct disk operations, and improve disk IO efficiency.

Benefits of technology

By adding new writes to memory, the write speed is greatly accelerated, the disk IO load is reduced, the cache hit rate and access speed are improved, and the disk IO performance is optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760631B_ABST
    Figure CN118760631B_ABST
Patent Text Reader

Abstract

The present invention provides a CDN cache replacement method, the method comprising creating a memory table with a fixed-size space, wherein the memory table is an empty table and the number of the memory table is one; when a current CDN node obtains a first resource from a previous CDN node, the obtained first resource is sliced ​​to obtain a plurality of fragments, a first index corresponding to each of the fragments is calculated, and the fragments are stored in the memory table based on the first index; when the current CDN node returns a second resource in response to a user request, a second index of the second resource to be returned is calculated, and the memory table storing the fragments is searched for the second resource to be returned according to the second index; if the second resource to be returned is found in the memory table storing the fragments, the second resource to be returned is returned and a hotspot update is performed; if the second resource to be returned is not found, the second resource to be returned is not found in the memory table storing the fragments, thereby improving disk IO efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network transmission, and in particular relates to a CDN cache replacement method. Background Art

[0002] CDN (Content Delivery Network) is a distributed network system that aims to improve the speed and reliability of content delivery by distributing content cache to multiple geographically dispersed servers. CDN is widely used to accelerate the content transmission of websites, streaming media, online games and other Internet services. When a user initiates a network request, the nearest CDN node is accessed first. If there are resources, they can be obtained with lower network latency. Otherwise, further requests to the network center node are required. However, it is impossible for each CDN node to store all resources. Only key resources can be selected to meet the needs of the largest number of users. Therefore, when the CDN node returns resources to the user, it needs to consider whether to retain this resource for the next request. The trade-off between new and old resources is the cache replacement of CDN. At present, the more representative cache replacement algorithms are LRU (Least Recently Used) and MRU (Most Recently Used). These two methods are simple in principle and implementation, and thus become common strategies.

[0003] LRU and MRU do not take into account other factors such as access frequency, which can easily lead to frequent cache replacement, resulting in excessive disk IO and excessive traffic being pulled to the upper-level node. Summary of the invention

[0004] In order to solve the above technical problem, the present invention provides a CDN cache replacement method, which is used to solve the technical problem of low disk IO efficiency in the prior art.

[0005] On the one hand, the invention provides the following technical solution, a CDN cache replacement method, the method comprising: creating a memory table with a fixed size space, wherein the memory table is an empty table and the number of the memory table is one;

[0006] If the current CDN node obtains the first resource from the previous CDN node, the obtained first resource is sliced ​​to obtain a plurality of segments, a first index corresponding to each of the segments is calculated, and the segments are stored in the memory table based on the first index;

[0007] When the current CDN node returns the second resource in response to the user request, a second index of the second resource to be returned is calculated, and the second index is searched for whether the memory table with the inserted fragments has the second resource to be returned according to the second index;

[0008] If the second resource to be returned is found in the memory table storing the fragments, the second resource to be returned is returned and a hotspot update is performed;

[0009] If the second resource to be returned is not found in the memory table storing the segments, the step of if the current CDN node obtains the first resource from the previous CDN node is re-executed.

[0010] Compared with the prior art, the beneficial effects of the present application are: by calculating the first index corresponding to each of the fragments, and storing the fragments in the memory table based on the first index, when a new resource is obtained, the disk data is not directly updated, but additional writing is done in the memory, which greatly speeds up the writing speed. At the same time, compared with the direct operation of the disk by LRU, MRU and its variant methods, the operation of the disk by the present application is only batch sequential reading and writing, thereby improving the disk IO efficiency. By returning the second resource to be returned and performing a hot spot update, it can be ensured that the frequently read data is always in the lower layer table, which greatly improves the hit rate and access speed.

[0011] Furthermore, the step of calculating the first index corresponding to each of the fragments includes:

[0012] A hash function value of each of the fragments is calculated, and the hash function value is used as a first index of the fragment, wherein if two first indexes are different, the fragments corresponding to the two are also different.

[0013] Furthermore, the step of storing the fragment in the memory table based on the first index includes:

[0014] Using a quick search operation to find out whether the first index exists in the memory table;

[0015] If the first index exists in the memory table, updating the third resource corresponding to the first index;

[0016] If the first index does not exist in the memory table, insert the fragment corresponding to the first index into the memory table.

[0017] Furthermore, after the step of inserting the fragment corresponding to the first index into the memory table, the method further includes:

[0018] Determine in real time whether the memory table has any storage space left, if the memory table has no storage space left;

[0019] The memory table is persisted to form a persistent table, and a new memory table is created;

[0020] The remaining segments continue to be stored in the new memory table, and the step of determining in real time whether there is any storage space left in the memory table is repeated until all the segments are stored.

[0021] Furthermore, after the step of storing all the fragments, the method further comprises:

[0022] Determine whether the number of the persistent tables currently reaches a first threshold, if the number of the persistent tables currently reaches the first threshold;

[0023] Based on the index value corresponding to the persistent table, all the current persistent tables are multi-way merged to form a merged table, wherein when the index values ​​of two persistent tables are the same, the data with the latest timestamp is taken for merging;

[0024] Determine whether the current number of the merged tables reaches a second threshold, if the current number of the merged tables reaches the second threshold;

[0025] Then all the current persistent tables are merged to form a merged layer, a multi-layer space is created in the hard disk, and the merged layer is stored in the multi-layer space;

[0026] If the storage of the multi-layer space reaches an upper limit, the data corresponding to the highest layer of the multi-layer space is cleared.

[0027] Furthermore, the step of performing a hotspot update includes:

[0028] Repeat the steps when the current CDN node obtains the first resource from the previous CDN node, insert a triplet, and mark in the additional data of the triplet that the data stored in the triplet is an address, and mark the triplet as referenced in the additional data of the triplet corresponding to the address, wherein the index of the triplet is the second index, and the value of the triplet data is the address of the second resource.

[0029] Furthermore, after the step of returning the second resource if the memory table storing the fragments does not find the second resource, the method further includes:

[0030] Determine whether the address of the second resource to be returned is the address obtained by performing a hotspot update step, if the address of the second resource to be returned is the address obtained by performing a hotspot update step;

[0031] It is then determined whether the address is valid. If the address is invalid, the step of re-executing the step of obtaining the first resource from the previous CDN node by the current CDN node is performed.

[0032] In a second aspect, the invention provides the following technical solution: a CDN cache replacement system, the system comprising:

[0033] A creation module, used for creating a memory table of a fixed-size space, wherein the memory table is an empty table and the number of the memory table is one;

[0034] a storage module, configured to slice the acquired first resource to obtain a plurality of segments, calculate a first index corresponding to each segment, and store the segment in the memory table based on the first index when the current CDN node acquires the first resource from the previous CDN node;

[0035] a search module, configured to calculate a second index of the second resource to be returned when the current CDN node returns the second resource in response to a user request, and search the memory table storing the fragments according to the second index to see whether the second resource to be returned exists;

[0036] An updating module, configured to return the second resource to be returned and perform a hotspot update if the second resource to be returned is found in the memory table storing the fragments;

[0037] The execution module is used to re-execute the step of obtaining the first resource from the previous CDN node if the second resource to be returned is not found in the memory table storing the fragments.

[0038] In a third aspect, the invention provides the following technical solution: a computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the CDN cache replacement method as described above when executing the computer program.

[0039] In a fourth aspect, the invention provides the following technical solution: a storage medium having a computer program stored thereon, wherein the computer program implements the CDN cache replacement method as described above when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0041] Figure 1 A flowchart of a CDN cache replacement method provided by a first embodiment of the present invention;

[0042] Figure 2A structural block diagram of a CDN cache replacement system provided by a second embodiment of the present invention;

[0043] Figure 3 A schematic diagram of the hardware structure of a computer provided in the third embodiment of the present invention.

[0044] The embodiments of the present invention will be further described below with reference to the accompanying drawings. DETAILED DESCRIPTION

[0045] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout are the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the embodiments of the present invention, and should not be construed as limiting the present invention.

[0046] In the description of the embodiments of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0047] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0048] Embodiment 1

[0049] In the first embodiment of the present invention, see Figure 1 , a CDN cache replacement method, comprising the following steps S01 to S05:

[0050] S01, creating a memory table with a fixed size space, wherein the memory table is an empty table and the number of the memory table is one;

[0051] In this embodiment, a fixed-size space is allocated in the memory of the CDN as an empty table, called the l0 table, and only one l0 table is allowed to exist.

[0052] S02, if the current CDN node obtains the first resource from the previous CDN node, it slices the obtained first resource to obtain a plurality of segments, calculates a first index corresponding to each of the segments, and stores the segments in the memory table based on the first index;

[0053] Specifically, the step of calculating the first index corresponding to each of the fragments includes:

[0054] A hash function value of each of the fragments is calculated, and the hash function value is used as a first index of the fragment, wherein if two first indexes are different, the fragments corresponding to the two are also different.

[0055] In this embodiment, when a CDN node obtains resources from a higher-level CDN node, it slices the obtained resources into segments of size m, creates an index for each segment, and stores all segments in table l0. The index is created by calculating the hash function value of the segment as the index. If the index is different, it means that the segment is different.

[0056] Specifically, the step of storing the fragment in the memory table based on the first index includes:

[0057] S21, using a quick search operation to find out whether the first index exists in the memory table;

[0058] S22: if the first index exists in the memory table, updating the third resource corresponding to the first index;

[0059] S23: If the first index does not exist in the memory table, insert the fragment corresponding to the first index into the memory table.

[0060] In this embodiment, the storage method is to use the quick search operation of the table to find the fragment index. If the index is found to exist in the table, the data corresponding to the index is directly updated. Otherwise, the fragment corresponding to the index is inserted into the table according to the position returned by the quick search operation.

[0061] After the step of inserting the fragment corresponding to the first index into the memory table, the method further includes:

[0062] S24, determining in real time whether the memory table has any storage space left, if the memory table has no storage space left;

[0063] S25, making the memory table persistent to form a persistent table, and creating a new memory table;

[0064] S26, continue to store the remaining fragments in the new memory table, and repeat the step of determining in real time whether there is any storage space left in the memory table until all the fragments are stored.

[0065] In this embodiment, when the l0 table has no storage space, the l0 table is persisted to the hard disk. The table persisted from the l0 table to the hard disk is called the 11 table. At the same time, a new empty l0 table is created and the remaining fragments are stored in the new l0 table.

[0066] Specifically, after the step of storing all the fragments, the method further includes:

[0067] S27, determining whether the number of the current persistent tables reaches a first threshold, if the number of the current persistent tables reaches the first threshold;

[0068] S28, based on the index value corresponding to the persistent table, all the current persistent tables are multi-way merged to form a merged table, wherein when the index values ​​of two persistent tables are the same, the data with the latest timestamp is merged;

[0069] S29, determining whether the current number of the merged tables reaches a second threshold, if the current number of the merged tables reaches the second threshold;

[0070] S30, merging all the current persistent tables to form a merged layer, creating a multi-layer space in the hard disk, and storing the merged layer in the multi-layer space;

[0071] S31, if the storage of the multi-layer space reaches an upper limit, clearing the data corresponding to the highest layer of the multi-layer space.

[0072] In this embodiment, multiple tables 11 are allowed to exist, and the upper limit is recorded as When the 11 tables reach the upper limit, all 11 tables are merged to form a new table, called l2 table (merged table). There can be multiple l2 tables, and the upper limit is recorded as This table structure can be built in multiple layers according to needs and disk space, such as 13, 14...1 n When the number of layers reaches the upper limit, the data in the highest layer is cleaned. The merging process is to merge multiple tables into one table by multi-way merging based on the index value. When encountering the same index value, the data with the latest timestamp is taken.

[0073] S03, when the current CDN node returns the second resource in response to the user request, a second index of the second resource to be returned is calculated, and the second index is used to search whether the memory table with the inserted fragments exists and the second resource to be returned exists.

[0074] S04: If the second resource to be returned is found in the memory table storing the fragments, the second resource to be returned is returned and a hotspot update is performed.

[0075] Specifically, the step of performing a hotspot update includes:

[0076] Repeat the steps of if the current CDN node obtains the first resource from the previous CDN node, insert a triple, and mark the data stored in the triple as an address in the additional data of the triple, and mark the triple as referenced in the additional data of the triple corresponding to the address, wherein the index of the triple is the second index, and the value of the triple data is the address of the second resource

[0077] In this implementation, the hotspot update step is to execute step S02 once and insert a triple. The index of the triple is the index of the resource fragment found in step S03, the value of the data is the address of the found resource, and the data stored in the triple is marked as an address in the additional data, and the additional data of the triple corresponding to the address marks that the triple is referenced.

[0078] S05, if the second resource to be returned is not found in the memory table storing the segments, the step of if the current CDN node obtains the first resource from the previous CDN node is re-executed.

[0079] Specifically, after the step of returning the second resource if the memory table storing the fragments does not find the second resource, the method further includes:

[0080] Determine whether the address of the second resource to be returned is the address obtained by performing a hotspot update step, if the address of the second resource to be returned is the address obtained by performing a hotspot update step;

[0081] It is then determined whether the address is valid. If the address is invalid, the step of re-executing the step of obtaining the first resource from the previous CDN node by the current CDN node is performed.

[0082] In this embodiment, when the CDN node returns data in response to a user request, it calculates the index of the data to be returned and searches for the data in turn according to the index. surface, surface…… If the resource is found in the table, the resource is returned and a hotspot update is performed. If the resource is not found, the process jumps to step S02 to pull the resource from the upper-level CDN node.

[0083] In this embodiment, when searching in step S03, if the data is found to be an address of a hotspot update, the address is further searched. If the address is invalid (such as being cleared in step S31), it is considered that it is not found, and the process jumps to step S02 to pull resources from the upper-level CDN node;

[0084] When the data cleaning of step S31 is triggered, if the cleaned data is referenced, the cleaned data is copied to the referenced data.

[0085] In this embodiment, a CDN cache replacement method can be applied to live broadcasts on the Internet. The live broadcast clips of the anchor will be uploaded to the live broadcast platform, and the live broadcast platform will distribute the live broadcast clips to CDN nodes deployed throughout the country. This distribution process can be active distribution, that is, the platform actively sends the live broadcast clips to each CDN node; it can also be passive distribution, that is, the audience visits the anchor's live broadcast room, performs DNS resolution, and redirects to the CDN node closest to the audience. After receiving the audience's access request, the CDN node finds that it does not have the corresponding live broadcast clip resources, so it initiates a resource request to the superior CDN node, layer by layer, until the live broadcast platform. The present invention is deployed on the CDN node, and when the resource (live broadcast clip) enters the CDN node (distributed by the superior CDN node) or the resource leaves the CDN node (in response to the audience's access request), the resource is cached.

[0086] Among them, the core component of a CDN cache replacement method is a data structure called a "table". The table is a sequence of triplets of (index, additional data, data) sorted by index, where the additional data is used to store some additional information, such as timestamps. It also provides a fast search (complexity of log(n)) operation, which returns the location of an existing triple corresponding to an index or the location where a non-existent triple should belong, and the space allocated to each triple is the same size. In actual implementation, the table can adopt a "skip table" data structure.

[0087] In summary, a CDN cache replacement method has the following effects:

[0088] When a new resource is acquired, the disk data is not updated directly, but written in the memory, which greatly speeds up the writing speed. Compared with LRU, MRU and its variant methods that directly operate the disk (which is usually a random read and write process), the disk operation of the present invention is only batch sequential read and write (persisting a new table only stores the data on the hard disk, without searching for a specific location, and sequential read and write is much faster than random read and write), and the disk IO performance is also excellent.

[0089] In terms of cache hit rate, due to the existence of the hotspot update mechanism, it can ensure that frequently read data is always in the lower-level table, greatly improving the hit rate and access speed.

[0090] In searching for returned resources, since the table is designed as a sequential structure, a fast search method can be used to search within the table, and when searching for deeper tables on disk, tables can be searched from new to old according to timestamps. In actual situations, most data is rarely accessed, and only a very small amount of data is frequently accessed. Therefore, in most cases, searches are performed in memory (most hot data is concentrated in table), thus providing excellent search efficiency.

[0091] In the present invention, due to the append write, the two write operations are completely unrelated, and no complex mechanisms such as data locks are involved, so efficient concurrent access can be supported; when the fragment is written to the next layer, the merging and creation of a new table in the next layer are unrelated to the search, reading and writing of the previous layer, so it has the potential to be designed as a multi-threaded or distributed system with certain expansion and acceleration capabilities.

[0092] Embodiment 2

[0093] like Figure 2 As shown, a second embodiment of the present invention provides a CDN cache replacement system, the system comprising:

[0094] A creation module 10 is used to create a memory table with a fixed size space, wherein the memory table is an empty table and the number of the memory table is one;

[0095] The storage module 20 is used for slicing the first resource obtained from the previous CDN node to obtain a plurality of segments, calculating a first index corresponding to each segment, and storing the segment in the memory table based on the first index when the current CDN node obtains the first resource from the previous CDN node;

[0096] A search module 30, configured to calculate a second index of the second resource to be returned when the current CDN node returns the second resource in response to a user request, and search the memory table storing the fragments according to the second index to see whether the second resource to be returned exists;

[0097] An updating module 40, configured to return the second resource to be returned and perform a hotspot update if the second resource to be returned is found in the memory table storing the fragments;

[0098] The execution module 50 is used to re-execute the step of obtaining the first resource from the previous CDN node if the second resource to be returned is not found in the memory table storing the fragments.

[0099] The CDN cache replacement system provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0100] Embodiment 3

[0101] like Figure 3 As shown, in the third embodiment of the present invention, the embodiment of the present invention provides the following technical solution: a computer, comprising a memory 202, a processor 201, and a computer program stored in the memory 202 and executable on the processor 201, wherein the processor 201 implements the CDN cache replacement method as described above when executing the computer program.

[0102] Specifically, the processor 201 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0103] Among them, the memory 202 may include a large-capacity memory for resources or instructions. For example, but not limitation, the memory 202 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 202 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 202 may be inside or outside the resource processing device. In a specific embodiment, the memory 202 is a non-volatile memory. In a specific embodiment, the memory 202 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended date out dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0104] The memory 202 may be used to store or cache various resource files required for processing and / or communication, as well as possible computer program instructions executed by the processor 201 .

[0105] The processor 201 implements the above CDN cache replacement method by reading and executing the computer program instructions stored in the memory 202 .

[0106] In some embodiments, the computer may further include a communication interface 203 and a bus 200. Figure 3 As shown, the processor 201, the memory 202, and the communication interface 203 are connected via a bus 200 and communicate with each other.

[0107] The communication interface 203 is used to implement communication between the modules, devices, units and / or devices in the embodiment of the present application. The communication interface 203 can also implement resource communication with other components such as: external devices, image / resource acquisition devices, resource libraries, external storage, and image / resource processing workstations.

[0108] The bus 200 includes hardware, software or both, and couples the components of the computer to each other. The bus 200 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 200 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 200 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.

[0109] Embodiment 4

[0110] In a fourth embodiment of the present invention, in combination with the above-mentioned CDN cache replacement method, the embodiment of the present invention provides the following technical solution: a storage medium having a computer program stored thereon, and the computer program implements the above-mentioned CDN cache replacement method when executed by a processor.

[0111] Those skilled in the art will appreciate that the logic and / or steps described in the flowchart or in other ways herein, for example, can be considered as a sequenced resource list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses.

[0112] More specific examples of readable media (a non-exhaustive list of resources) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0113] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a resource signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0114] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0115] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A CDN cache replacement method, characterized in that: The method comprises: Create a memory table with a fixed size space, wherein the memory table is an empty table and the number of the memory table is one; If the current CDN node obtains the first resource from the previous CDN node, the obtained first resource is sliced ​​to obtain a plurality of segments, a first index corresponding to each of the segments is calculated, and the segments are stored in the memory table based on the first index; When the current CDN node returns the second resource in response to the user request, the second index of the second resource to be returned is calculated, and the second index is searched to determine whether the memory table storing the fragments contains the second resource to be returned according to the second index; If the second resource to be returned is found in the memory table storing the fragments, the second resource to be returned is returned and a hotspot update is performed; If the second resource to be returned is not found in the memory table storing the segments, the step of re-performing the step of obtaining the first resource from the previous CDN node is performed; The step of storing the fragment in the memory table based on the first index comprises: Using a quick search operation to find out whether the first index exists in the memory table; If the first index exists in the memory table, updating the third resource corresponding to the first index; If the first index does not exist in the memory table, insert the fragment corresponding to the first index into the memory table; The steps of performing a hotspot update include: Repeat the steps when the current CDN node obtains the first resource from the previous CDN node, insert a triplet, and mark in the additional data of the triplet that the data stored in the triplet is an address, and mark the triplet as referenced in the additional data of the triplet corresponding to the address, wherein the index of the triplet is the second index, and the value of the triplet data is the address of the second resource.

2. The CDN cache replacement method according to claim 1, characterized in that: The step of calculating the first index corresponding to each of the fragments comprises: A hash function value of each of the fragments is calculated, and the hash function value is used as a first index of the fragment, wherein if two first indexes are different, the fragments corresponding to the two are also different.

3. The CDN cache replacement method according to claim 1, characterized in that: After the step of inserting the fragment corresponding to the first index into the memory table, the method further includes: Determine in real time whether the memory table has any storage space left, if the memory table has no storage space left; The memory table is persisted to form a persistent table, and a new memory table is created; The remaining segments continue to be stored in the new memory table, and the step of determining in real time whether there is any storage space left in the memory table is repeated until all the segments are stored.

4. The CDN cache replacement method according to claim 3, characterized in that: After the step of storing all the fragments, the method further comprises: Determine whether the number of the persistent tables currently reaches a first threshold, if the number of the persistent tables currently reaches the first threshold; Based on the index value corresponding to the persistent table, all the current persistent tables are multi-way merged to form a merged table, wherein when the index values ​​of two persistent tables are the same, the data with the latest timestamp is taken for merging; Determine whether the current number of the merged tables reaches a second threshold, if the current number of the merged tables reaches the second threshold; Then all the current persistent tables are merged to form a merged layer, a multi-layer space is created in the hard disk, and the merged layer is stored in the multi-layer space; If the storage of the multi-layer space reaches an upper limit, the data corresponding to the highest layer of the multi-layer space is cleared.

5. The CDN cache replacement method according to claim 1, characterized in that: After the step of returning the second resource if the memory table storing the fragments does not find the second resource, the method further includes: Determine whether the address of the second resource to be returned is the address obtained by performing a hotspot update step, if the address of the second resource to be returned is the address obtained by performing a hotspot update step; It is then determined whether the address is valid. If the address is invalid, the step of re-executing the step of obtaining the first resource from the previous CDN node by the current CDN node is performed.

6. A CDN cache replacement system, characterized in that: The system comprises: A creation module, used for creating a memory table of a fixed-size space, wherein the memory table is an empty table and the number of the memory table is one; a storage module, configured to slice the acquired first resource to obtain a plurality of segments, calculate a first index corresponding to each segment, and store the segment in the memory table based on the first index when the current CDN node acquires the first resource from the previous CDN node; a search module, configured to calculate a second index of the second resource to be returned when the current CDN node returns the second resource in response to a user request, and search the memory table storing the fragments according to the second index to see whether the second resource to be returned exists; An updating module, configured to return the second resource to be returned and perform a hotspot update if the second resource to be returned is found in the memory table storing the fragments; An execution module, configured to re-execute the step of obtaining the first resource from the previous CDN node if the second resource to be returned is not found in the memory table storing the fragments; The step of storing the fragment in the memory table based on the first index comprises: Using a quick search operation to find out whether the first index exists in the memory table; If the first index exists in the memory table, updating the third resource corresponding to the first index; If the first index does not exist in the memory table, insert the fragment corresponding to the first index into the memory table; The steps of performing a hotspot update include: Repeat the steps when the current CDN node obtains the first resource from the previous CDN node, insert a triplet, and mark in the additional data of the triplet that the data stored in the triplet is an address, and mark the triplet as referenced in the additional data of the triplet corresponding to the address, wherein the index of the triplet is the second index, and the value of the triplet data is the address of the second resource.

7. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the CDN cache replacement method according to any one of claims 1 to 5 is implemented.

8. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the CDN cache replacement method according to any one of claims 1 to 5 is implemented.