Cache file processing method and device, computer equipment and storage medium

By splitting cache files into multiple blocks and storing them using binary tree structures, adjusting node locations according to access frequency, the problem of difficult to manage large files in traditional cache strategies is solved, and more efficient data loading and service quality are achieved.

CN119474018APending Publication Date: 2025-02-18CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411652212.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

Traditional caching strategies are difficult to effectively manage large files such as high-definition videos and large pictures, which makes it difficult to improve service quality.

Method used

By obtaining the size of the cache file, dividing it into multiple cache file blocks, and storing these blocks using a binary tree structure, adjusting the location of the tree nodes according to the access frequency, ensuring that frequently accessed data can be quickly found and loaded.

Benefits of technology

It enables faster finding and loading of frequently accessed data, improving service quality and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474018A_ABST
    Figure CN119474018A_ABST
Patent Text Reader

Abstract

The invention relates to a cache file processing method and device, computer equipment and a storage medium. The method comprises the following steps: obtaining the size of a cache file; based on the size of the cache file and the size of a preset memory block, obtaining a plurality of cache file blocks; constructing a binary tree, wherein tree nodes of the binary tree comprise a root node, a left child node and a right child node; the access frequency of the cache file block is obtained, the cache file block is stored in the tree node based on the access frequency, the access frequency of the root node is larger than the access frequency of the left child node, and the access frequency of the root node is smaller than the access frequency of the right child node. By adopting the method, the cache file can be quickly searched.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer storage technology, and in particular to a method, device, computer equipment, and storage medium for processing cache files. Background Art

[0002] In CDN (Content Delivery Network), a cache mechanism can be used to improve the efficiency of content distribution and service quality. However, with the popularity of large files such as high-definition videos and large pictures, traditional cache strategies are difficult to manage data.

[0003] In the related art, hot data is stored on a solid-state drive with faster read and write speeds, while infrequently accessed data is stored on a lower-cost mechanical hard drive. However, as the access pattern changes, the hot data is also constantly changing, making it difficult to improve the service quality. Summary of the invention

[0004] Based on this, it is necessary to provide a cache file processing method, device, computer equipment, and storage medium to address the above technical issues.

[0005] In a first aspect, the present application provides a method for processing cache files. The method comprises:

[0006] Get the size of the cache file;

[0007] Based on the size of the cache file and the preset memory block size, a plurality of cache file blocks are obtained;

[0008] Constructing a binary tree, wherein the tree nodes of the binary tree include a root node, a left child node, and a right child node;

[0009] The access frequency of the cache file block is obtained, and the cache file block is stored in the tree node based on the access frequency, wherein the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

[0010] In one embodiment, the method further comprises:

[0011] Creating a cache linked list, the cache linked list comprising a plurality of linked list nodes, wherein the access time of the cache files stored in the head linked list node to the tail linked list node in the cache linked list increases in sequence;

[0012] Get the type of cache file and the access time of the cache file;

[0013] The number of cache file blocks stored in the cache linked list is obtained based on the type of the cache file, and the position of the cache file stored in the cache linked list is obtained based on the access time of the cache file.

[0014] In one embodiment, the method further comprises:

[0015] Obtaining a memory usage of the cache linked list based on the number of cache file blocks included in the linked list nodes of the cache linked list;

[0016] When the memory usage of the cache linked list is greater than the total memory, the cache files in the tail linked list node are deleted.

[0017] In one of the embodiments, the cache file block includes cache data, a starting position of the cache data in the cache file, and an ending position of the cache data in the cache file.

[0018] In one embodiment, the types of cache files include picture type, video type and download type, and each type of cache file adopts a different cache strategy according to the characteristics of the cache file.

[0019] In one embodiment, after obtaining the size of the cache file, the method further includes:

[0020] Dividing the cache file into a large file or a small file based on the size of the cache file;

[0021] If the cache file is a small file, storing the cache file in a memory;

[0022] In the case that the cache file is a large file, the cache file is stored based on the binary tree.

[0023] In a second aspect, the present application further provides a cache file processing device, the device comprising:

[0024] The acquisition module is used to obtain the size of the cache file;

[0025] A calculation module, used for obtaining a plurality of tree nodes based on the size of the cache file and a preset storage size of a single tree node;

[0026] A storage module is used to obtain the access frequency of the multiple tree nodes, build a binary tree based on the access frequency of the multiple tree nodes, and store the cache file in the tree nodes of the binary tree; the tree nodes of the binary tree include a root node, a left child node, and a right child node, the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

[0027] In one embodiment, the device further comprises:

[0028] Creating a cache linked list, the cache linked list comprising a plurality of linked list nodes, wherein the access time of the cache files stored in the head linked list node to the tail linked list node in the cache linked list increases in sequence;

[0029] Get the type of cache file and the access time of the cache file;

[0030] The number of cache file blocks stored in the cache linked list is obtained based on the type of the cache file, and the position of the cache file stored in the cache linked list is obtained based on the access time of the cache file.

[0031] In one embodiment, the device further comprises:

[0032] Obtaining a memory usage of the cache linked list based on the number of cache file blocks included in the linked list nodes of the cache linked list;

[0033] When the memory usage of the cache linked list is greater than the total memory, the cache files in the tail linked list node are deleted.

[0034] In one of the embodiments, the cache file block includes cache data, a starting position of the cache data in the cache file, and an ending position of the cache data in the cache file.

[0035] In one embodiment, the types of cache files include picture type, video type and download type, and each type of cache file adopts a different cache strategy according to the characteristics of the cache file.

[0036] In one of the embodiments, after obtaining the size of the cache file, the device further includes:

[0037] Dividing the cache file into a large file or a small file based on the size of the cache file;

[0038] If the cache file is a small file, storing the cache file in a memory;

[0039] In the case that the cache file is a large file, the cache file is stored based on the binary tree.

[0040] In a third aspect, the present disclosure further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the cache file processing method when executing the computer program.

[0041] In a fourth aspect, the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method for processing cache files are implemented.

[0042] In a fifth aspect, the present disclosure further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the method for processing cache files are implemented.

[0043] The above cache file processing method has at least the following beneficial effects:

[0044] The embodiment scheme provided by the present disclosure can divide the cache file into multiple cache file blocks based on a preset memory block size, store the cache file blocks in a binary tree structure, and adjust the stored tree node position according to the access frequency of the cache file blocks, the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the left child node. A binary tree is constructed based on the access frequency of the tree nodes, so that frequently accessed data can be found and loaded more quickly.

[0045] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 An application environment diagram of a method for processing cache files in one embodiment;

[0048] Figure 2 A schematic diagram of a process flow of a method for processing cache files in one embodiment;

[0049] Figure 3 A schematic diagram of the construction of a binary tree in one embodiment;

[0050] Figure 4 is a schematic diagram of a cache linked list in one embodiment;

[0051] Figure 5 A schematic diagram of processing cache files in one embodiment;

[0052] Figure 6 It is a structural block diagram of a cache file processing device in one embodiment;

[0053] Figure 7 is an internal structure diagram of a computer device in one embodiment;

[0054] Figure 8 The figure is a diagram of the internal structure of a server in one embodiment. DETAILED DESCRIPTION

[0055] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0056] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described here can be implemented in an order other than those illustrated or described here. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the attached claims. The terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, product or device including a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, product or device. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.

[0057] The present disclosure provides a method for processing cache files, which can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0058] In some embodiments of the present disclosure, Figure 2As shown, a method for processing cache files is provided, and the method is applied to Figure 1 The method is described by taking the example of a server in processing cache files. It is understandable that the method can be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In a specific embodiment, the method can include the following steps:

[0059] S202: Obtain the size of the cache file.

[0060] The types of cached files may include image files, video files, text files, etc. The CDN platform (Content Delivery Network) can provide an API (Application Programming Interface) to obtain the metadata of cached files, including the file size. By calling the API, the size of the cached file can be easily obtained.

[0061] S204: Based on the size of the cache file and the preset memory block size, a plurality of cache file blocks are obtained.

[0062] Get the size of the cache file and the preset memory block size. Multiple cache file blocks are possible. Each cache file block represents a fragment of the cache file. The starting position of this fragment in the cache file is defined by start, and the ending position is defined by end, that is, range. Range is used as the key value of the tree node to identify the tree node in the binary tree.

[0063] S206: Construct a binary tree, wherein tree nodes of the binary tree include a root node, a left child node, and a right child node.

[0064] A binary tree can be constructed in a preset order. The tree nodes of the binary tree include a root node, a left child node, and a right child node. Then, the access frequency of the cache file block can be obtained, and the position of the tree node in the binary tree can be adjusted according to the access frequency of the cache file block.

[0065] S208: Obtain the access frequency of the cache file block, and store the cache file block in the tree node based on the access frequency, wherein the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

[0066] Figure 3The diagram is a construction diagram of a binary tree in one embodiment. The root node can be the most frequently accessed range block, that is, the cache file block with the highest access frequency is placed at the root node of the tree. When accessing the cache file, the most likely required data will be found first. The access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node. This ensures that when searching for a specific range, the target tree node can be quickly located by binary search. For example, a video cache file has characteristics such as climax clips and chorus, which results in differences in the number of corresponding requests for the same cache file. The cache file blocks with high access frequency can be stored in the root node.

[0067] The level of the binary tree reflects the access popularity of the data. The root node can be the hottest range block, and the nodes in the first layer are the second hottest range blocks. The lower the level, the lower the access frequency of the data. Building a binary tree based on the access frequency of the tree nodes can find and load frequently accessed data faster.

[0068] In the above-mentioned cache file processing method, the cache file can be divided into multiple cache file blocks based on a preset memory block size, and the cache file blocks are stored in a binary tree structure. The stored tree node position is adjusted according to the access frequency of the cache file blocks. The access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node. A binary tree is constructed based on the access frequency of the tree nodes, so that frequently accessed data can be found and loaded more quickly.

[0069] In some embodiments of the present disclosure, the method further includes:

[0070] Creating a cache linked list, the cache linked list comprising a plurality of linked list nodes, wherein the access time of the cache files stored in the head linked list node to the tail linked list node in the cache linked list increases in sequence;

[0071] Get the type of cache file and the access time of the cache file;

[0072] The number of cache file blocks stored in the cache linked list is obtained based on the type of the cache file, and the position of the cache file stored in the cache linked list is obtained based on the access time of the cache file.

[0073] Figure 4Schematic diagram of a cache linked list in an embodiment. The cache linked list can be used to manage cache data. The head linked list node of the cache linked list stores the cache data that has been accessed most recently, and the tail linked list node stores the cache data that has not been accessed for the longest time. When new cache data is accessed, it can be moved to the head of the linked list. Each linked list node contains not only the cache data itself, but also cache file blocks, which helps to calculate the memory usage of the entire cache linked list. For example, when a cache request is received, the file type can be determined based on the URL suffix, the number of cache file blocks stored in the cache linked list can be calculated based on the file type, and the new cache data can be inserted into the head of the cache linked list.

[0074] In some embodiments of the present disclosure, the method further includes:

[0075] Obtaining a memory usage of the cache linked list based on the number of tree nodes included in the linked list nodes of the cache linked list;

[0076] When the memory usage of the cache linked list is greater than the total memory, the cache files in the tail linked list node are deleted.

[0077] Provides configuration items to configure the total memory cache memory usage, which helps control memory usage and prevent the system from crashing due to insufficient memory.

[0078] Figure 5 The figure is a schematic diagram of the processing of cache files in an embodiment. In which, treeNode represents a tree node, and lruNode represents a linked list node. Each time the cache linked list is updated, the total memory usage of the entire cache linked list is calculated according to the number of cache file blocks carried by each linked list node. If the total memory usage exceeds the configured memory cache usage, the cache file blocks corresponding to the cache file are deleted from the tail of the cache linked list to release memory and ensure that the total memory usage does not exceed the configured upper limit.

[0079] In some embodiments of the present disclosure, the cache file block includes cache data, a starting position of the cache data in the cache file, and an ending position of the cache data in the cache file.

[0080] Each cache file block represents a fragment of the cache file. The starting position of this fragment in the cache file is defined by start, and the ending position is defined by end, that is, range. Range is used as the key value of the tree node to identify the tree node in the binary tree.

[0081] In some embodiments of the present disclosure, the types of cache files include picture type, video type and download type, and each type of cache file adopts a different cache strategy according to the characteristics of the cache file.

[0082] You can determine the cache file type based on the cache file type. Different types of files have different cache strategies:

[0083] Image files: The number of cache file blocks stored in the tree node is 100% of the total cache file blocks.

[0084] Video files: The number of cache file blocks stored in the tree node is 20% of the total number of cache file blocks.

[0085] Download files: Only 1-2 cached file blocks are put into memory, mainly used to optimize the first packet rate.

[0086] In some embodiments of the present disclosure, after obtaining the size of the cache file, the method further includes:

[0087] Dividing the cache file into a large file or a small file based on the size of the cache file;

[0088] If the cache file is a small file, storing the cache file in a memory;

[0089] In the case that the cache file is a large file, the cache file is stored based on the binary tree.

[0090] Large cache files can be distinguished according to business types. For download caches, the first few cache file blocks can be put into memory to ensure the quality of the first packet and the first frame. For video caches, sparsely distributed hot cache file blocks are put into memory, and memory continuity is not mandatory. The content with high access frequency of the current cache file is stored in memory to improve the memory cache hit rate and reduce input and output read and write requests.

[0091] Provides a threshold for small file caching and stores them directly in the memory cache, reducing small input and output requests to the disk.

[0092] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0093] Based on the same inventive concept, the embodiment of the present disclosure also provides a cache file processing device for implementing the above-mentioned cache file processing method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in the cache file processing device embodiment provided below can refer to the limitations of the cache file processing method above, and will not be repeated here.

[0094] The device may include a system (including a distributed system), software (application), module, component, server, client, etc. that uses the method described in the embodiments of this specification and is combined with necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided in the embodiments of the present disclosure is as described in the following embodiments. Since the implementation scheme and method of the device to solve the problem are similar, the implementation of the specific device in the embodiments of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0095] In one embodiment, Figure 6 As shown, a cache file processing device 600 is provided, and the device may be the aforementioned server, or a module, component, device, unit, etc. integrated in the server. The device 600 may include:

[0096] The acquisition module 602 is used to acquire the size of the cache file;

[0097] A calculation module 604 is used to obtain multiple tree nodes based on the size of the cache file and the preset storage size of a single tree node;

[0098] The storage module 606 is used to obtain the access frequency of the multiple tree nodes, construct a binary tree based on the access frequency of the multiple tree nodes, and store the cache file in the tree nodes of the binary tree; the tree nodes of the binary tree include a root node, a left child node, and a right child node, the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

[0099] In one embodiment, the device further comprises:

[0100] Creating a cache linked list, the cache linked list comprising a plurality of linked list nodes, wherein the access time of the cache files stored in the head linked list node to the tail linked list node in the cache linked list increases in sequence;

[0101] Get the type of cache file and the access time of the cache file;

[0102] The number of cache file blocks stored in the cache linked list is obtained based on the type of the cache file, and the position of the cache file stored in the cache linked list is obtained based on the access time of the cache file.

[0103] In one embodiment, the device further comprises:

[0104] Obtaining a memory usage of the cache linked list based on the number of cache file blocks included in the linked list nodes of the cache linked list;

[0105] When the memory usage of the cache linked list is greater than the total memory, the cache files in the tail linked list node are deleted.

[0106] In one of the embodiments, the cache file block includes cache data, a starting position of the cache data in the cache file, and an ending position of the cache data in the cache file.

[0107] In one embodiment, the types of cache files include picture type, video type and download type, and each type of cache file adopts a different cache strategy according to the characteristics of the cache file.

[0108] In one of the embodiments, after obtaining the size of the cache file, the device further includes:

[0109] Dividing the cache file into a large file or a small file based on the size of the cache file;

[0110] If the cache file is a small file, storing the cache file in a memory;

[0111] In the case that the cache file is a large file, the cache file is stored based on the binary tree.

[0112] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0113] Each module in the above-mentioned processing device for cache files can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.

[0114] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cached data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for processing cached files is implemented.

[0115] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for processing cache files is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse, etc.

[0116] Those skilled in the art will understand that Figure 7 , Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0117] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in any embodiment of the present disclosure is implemented.

[0118] In one embodiment, a computer program product is provided, including a computer program, which implements the method described in any embodiment of the present disclosure when executed by a processor.

[0119] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.

[0120] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above 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.

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

Claims

1. A method for processing cache files, characterized in that: The method comprises: Get the size of the cache file; Based on the size of the cache file and the preset memory block size, a plurality of cache file blocks are obtained; Constructing a binary tree, wherein the tree nodes of the binary tree include a root node, a left child node, and a right child node; The access frequency of the cache file block is obtained, and the cache file block is stored in the tree node based on the access frequency, wherein the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

2. The method according to claim 1, characterized in that The method further comprises: Creating a cache linked list, the cache linked list comprising a plurality of linked list nodes, wherein the access time of the cache files stored in the head linked list node to the tail linked list node in the cache linked list increases in sequence; Get the type of cache file and the access time of the cache file; The number of cache file blocks stored in the cache linked list is obtained based on the type of the cache file, and the position of the cache file stored in the cache linked list is obtained based on the access time of the cache file.

3. The method according to claim 2, characterized in that The method further comprises: Obtaining a memory usage of the cache linked list based on the number of cache file blocks included in the linked list nodes of the cache linked list; When the memory usage of the cache linked list is greater than the total memory, the cache files in the tail linked list node are deleted.

4. The method according to claim 1, characterized in that The cache file block includes cache data, a starting position of the cache data in the cache file, and an ending position of the cache data in the cache file.

5. The method according to claim 2, characterized in that: The types of cache files include picture type, video type and download type, and each type of cache file adopts a different cache strategy according to the characteristics of the cache file.

6. The method according to claim 1, characterized in that After obtaining the size of the cache file, the method further includes: Dividing the cache file into a large file or a small file based on the size of the cache file; If the cache file is a small file, storing the cache file in a memory; In the case that the cache file is a large file, the cache file is stored based on the binary tree.

7. A cache file processing device, characterized in that: The device comprises: The acquisition module is used to obtain the size of the cache file; A calculation module, used for obtaining a plurality of tree nodes based on the size of the cache file and a preset storage size of a single tree node; A storage module is used to obtain the access frequency of the multiple tree nodes, build a binary tree based on the access frequency of the multiple tree nodes, and store the cache file in the tree nodes of the binary tree; the tree nodes of the binary tree include a root node, a left child node, and a right child node, the access frequency of the root node is greater than the access frequency of the left child node, and the access frequency of the root node is less than the access frequency of the right child node.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.