Device cleaning method, electronic device and computer-readable storage medium
By detecting the total cache of the first preview file in the cloud disk target storage device, and timely cleaning up files that meet the conditions, the problem of storage space exhaustion is solved and reasonable storage resource management and utilization is achieved.
Patent Information
- Application Number
- CN202411923121.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-25
AI Technical Summary
How to effectively and promptly clean cache preview files in the target storage device of cloud disk to prevent the storage space from running out.
By obtaining the total cache amount of the first preview file in the target storage device, it is detected whether the cleaning start condition is met (such as the total cache amount is greater than the first cache threshold), and clean up when the condition is met. The cleaning process involves cleaning up the recently unreached preview files until the cleaning completion conditions are met.
It realizes the timely cleaning of the first preview file in the target storage device, reasonably managing the storage space, avoiding the exhaustion of storage space, and improving the efficiency of storage resource utilization.
Smart Images

Figure CN119396348B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud disk technology, and in particular to a device cleaning method, an electronic device, and a computer-readable storage medium. Background Art
[0002] Cloud disk is a widely used cloud computing service that allows users to store files on remote servers and access and share them over the network. To facilitate users to view files online, cloud disks usually provide an online preview function, allowing users to browse the file content directly without downloading the file. The basic principle of the online preview function is to convert the original file format to generate a previewable file, and then display the preview file in the browser. In order to improve the preview speed and user experience, the generated preview file will be cached on the target storage device of the cloud disk (such as the local hard disk of the cloud disk server).
[0003] At present, most of the preview files cached in the target storage device are cleaned up by scheduled cleaning. If the scheduled cleaning frequency is too low, the target storage device cannot be cleaned up in time, which will increase the risk of disk space exhaustion. Therefore, how to effectively clean up the preview files cached in the target storage device is an urgent problem to be solved. Summary of the invention
[0004] The main technical problem solved by the present application is to provide a device cleaning method, an electronic device and a computer-readable storage medium, which can clean up the first preview file in the target storage device in a timely manner, realize reasonable management of the first preview file in the target storage device, and save the storage space of the target storage device.
[0005] To solve the above technical problems, a technical solution adopted in the present application is: providing a device cleaning method, the method comprising: obtaining the total cache amount of several first preview files stored in the target storage device; wherein the target storage device is a device in the cloud disk for storing first preview files corresponding to different target files, and the first preview file is generated when the client requests to preview the corresponding target file; based on the total cache amount of the several first preview files, detecting whether the target storage device meets the cleaning start condition; in response to the target storage device meeting the cleaning start condition, cleaning the first preview files in the target storage device.
[0006] The cleaning start condition includes that the total cache amount of a plurality of first preview files is greater than a first cache threshold.
[0007] The first cache threshold is determined based on the device capacity of the target storage device.
[0008] Among them, cleaning up the first preview file in the target storage device includes: performing at least one round of cleaning up the first preview file in the target storage device until a cleaning completion condition is met; wherein the first preview file in each round of cleaning up is a first preview file that has not been accessed within the most recent first preset time length, and the first preset time length corresponding to the next round of cleaning up is less than the first preset time length corresponding to the previous round of cleaning up.
[0009] Among them, the target storage device also stores preview data of each first preview file, and the preview data includes a last access time; performing at least one round of cleaning on the first preview files in the target storage device until a cleaning completion condition is met, including: based on the last access time of each first preview file, determining the first preview files in the target storage device that have not been accessed within a first preset time period as files to be cleaned; cleaning the files to be cleaned; determining whether the cleaning completion condition is currently met; in response to not currently meeting the cleaning completion condition, continuing to obtain the first preview files in the target storage device that have not been accessed within a first preset time period as new files to be cleaned, and re-executing the cleaning of the files to be cleaned and subsequent steps until the cleaning completion condition is met.
[0010] Among them, the cleaning completion condition includes at least one of the following: the total cache amount of the remaining first preview files in the target storage device is less than or equal to the second cache threshold, the remaining first preview files in the target storage device are the first preview files that have been accessed within the last second preset time length, wherein the second cache threshold is less than or equal to the first cache threshold, and the second preset time length is less than the first preset time length.
[0011] The device cleaning method is configured to be executed once every third preset time period; and / or the device cleaning method is configured to be executed when it is determined that the target storage device will add a new first preview file within a fourth preset time period.
[0012] Among them, the target storage device also stores preview data of each first preview file, and the preview data includes a last access time; the device cleaning method also includes: receiving a first preview request sent by a client; wherein the first preview request is generated and sent by the client after accessing the second preview file for more than a fifth preset time, and the second preview file is the first preview file fed back when the client requests a preview; and updating the last access time of the second preview file.
[0013] The target storage device also stores preview data of each first preview file, and the preview data includes a most recent access time. The device cleaning method also includes: receiving a second preview request sent by a client; wherein the second preview request includes a file identifier and a download address of a target file corresponding to the file identifier; determining whether the first preview file corresponding to the file identifier exists in the target storage device; in response to the existence of the first preview file corresponding to the file identifier in the target storage device, feeding back the first preview file corresponding to the file identifier to the client, and updating the most recent access time of the first preview file corresponding to the file identifier; in response to the absence of the first preview file corresponding to the file identifier in the target storage device, downloading the target file corresponding to the file identifier from the download address, and generating a first preview file based on the target file; feeding back the first preview file corresponding to the file identifier to the client, and recording the most recent access time of the first preview file corresponding to the file identifier at the current moment.
[0014] Among them, generating a first preview file based on the target file includes: obtaining the file type of the target file; in response to the file type being a first format type, using the target file as the first preview file; in response to the file type being a second format type, performing format conversion on the target file to obtain a converted file, and using the converted file as the first preview file.
[0015] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, the electronic device includes a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the above device cleaning method.
[0016] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a computer-readable storage medium, which is used to store program instructions, and the program instructions can be executed to implement the above-mentioned device cleaning method.
[0017] The above technical solution cleans up the first preview file in the target storage device when the target storage device meets the cleaning start condition, and cleans up the first preview file in the target storage device in a timely manner, thereby reasonably managing the first preview file in the target storage device, saving the storage space of the target storage device, and subsequently being able to more effectively utilize the limited storage space of the target storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flow chart of an embodiment of a device cleaning method provided by the present application;
[0019] Figure 2 It is a schematic diagram of the interactive process of online preview of files provided by this application;
[0020] Figure 3 It is a structural schematic diagram of an embodiment of the equipment cleaning device provided by the present application;
[0021] Figure 4 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application;
[0022] Figure 5 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0023] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0024] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0025] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0026] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of the device cleaning method provided by the present application. It should be noted that if there are substantially the same results, this embodiment is not used as Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:
[0027] Step S11: obtaining the total cache size of a plurality of first preview files stored in the target storage device.
[0028] Cloud disk is a widely used cloud computing service that allows users to store files on remote servers and access and share them over the network. To facilitate users to view files online, cloud disks usually provide an online preview function, allowing users to browse the file content directly without downloading the file. The basic principle of the online preview function is to convert the original file format to generate a previewable file, and then display the preview file in the browser. In order to improve the preview speed and user experience, the generated preview file will be cached on the target storage device of the cloud disk (such as the local hard disk of the cloud disk server).
[0029] Specifically, Figure 2 As shown, Figure 2 This is a schematic diagram of the interactive process of online file preview provided by this application. The client initiates the process of sending a request to the cloud disk ( Figure 2 After receiving the request initiated by the client, the cloud disk initiates a request to the distributed storage system to request the generation of the file download address ( Figure 2 After receiving the request from the cloud disk, the distributed storage system generates a file download address and feeds it back to the cloud disk ( Figure 2 After receiving the file download address fed back by the distributed storage system, the cloud disk feeds it back to the client. The client sends a preview request to the preview component ( Figure 2 ), wherein the preview request includes a file download address and a file identifier, and the file identifier of each file is globally unique; the preview component queries the preview cache, that is, queries to determine whether there is a preview file with the corresponding file identifier in the target storage device of the cloud disk; if the cache hits, that is, if the preview file with the corresponding file identifier exists in the target storage device of the cloud disk, the preview file is fed back to the client, and the last access time of the preview file is updated; if the cache misses, that is, if the preview file with the corresponding file identifier does not exist in the target storage device of the cloud disk, the file is downloaded from the download address sent by the client, and a preview file is generated based on the downloaded file, and then the preview file is fed back to the client, and the preview file is stored in the target storage device ( Figure 2 and initializes the last access time of the generated preview file to the current time.
[0030] It should be noted that the preview component can directly feed back the preview file to the client. Of course, it is also possible to feed back only the preview file URL to the client. When the client previews, it can obtain the preview file data by block transmission (also called streaming transmission) to obtain the preview file in blocks; in the case of block transmission, the client will dynamically request and receive different parts of the preview file according to the size of the current viewport and the user's browsing behavior. This on-demand loading method can reduce the amount of data transmitted over the network, speed up the preview of the file, and avoid wasting resources by transmitting too much data at one time.
[0031] However, since the storage space of the target storage device is limited, the preview files may occupy a large amount of storage resources. If they are not cleaned up in time, the storage space of the target storage device may be exhausted, resulting in the inability to preview new files. In addition, if the location where the preview files are cached - the target storage device is also used as a system disk, if the system disk is full, it will cause the system to crash, posing a threat to system stability.
[0032] Therefore, in this embodiment, the total cache amount of several first preview files stored in the target storage device is obtained; wherein the target storage device is a device in the cloud disk used to store first preview files corresponding to different target files, and the first preview file is generated when the client requests to preview the corresponding target file. By obtaining the total cache amount of several first preview files stored in the target storage device, it is possible to determine whether the total cache amount of the first preview files occupies a large amount of storage resources, so that when it is determined that the total cache amount of several first preview files stored in the target storage device occupies a large amount of storage resources, the first preview files in the target storage device can be cleaned up in time, so as to achieve reasonable management of the first preview files in the target storage device, save the storage space of the target storage device, and more effectively use the limited storage space of the target storage device in the future.
[0033] It should be noted that the total cache size of the first preview files stored in the target storage device is the total size of all the first preview files stored in the target storage device. In addition, when the client requests to preview the corresponding target file, if the preview file corresponding to the target file requested for preview exists in the target storage device, there is no need to generate the preview file corresponding to the target file requested for preview. If the preview file corresponding to the target file requested for preview does not exist in the target storage device, it is necessary to generate the preview file corresponding to the target file first, that is, the target file needs to be converted into a previewable file.
[0034] Step S12: Based on the total cache size of the first preview files, detecting whether the target storage device meets the cleaning start condition.
[0035] In this embodiment, based on the total cache amount of the first preview files, it is detected whether the target storage device meets the cleaning start condition. That is, according to the total cache amount of the first preview files stored in the target storage device, it can be determined whether the total cache amount of the first preview files stored in the target storage device occupies a large amount of storage resources, so that it can be determined whether the first preview files in the target device need to be cleaned up, that is, it can be determined whether the target storage device meets the cleaning start condition, so that when it is determined that the target storage device meets the cleaning start condition, the first preview files in the target storage device can be cleaned up in time, so as to achieve reasonable management of the first preview files in the target storage device, save the storage space of the target storage device, and more effectively use the limited storage space of the target storage device later.
[0036] In one embodiment, the cleaning start condition includes that the total cache amount of several first preview files is greater than the first cache threshold. When the total cache amount of several first preview files stored in the target storage device is greater than the first cache threshold, it means that the total cache amount of several first preview files stored in the target storage device is too large, occupying a large amount of storage resources of the target storage device; at this time, if the first preview files in the target storage device are not cleaned up, the storage space of the target storage device may be exhausted, resulting in the inability to preview new files, etc.; therefore, when the total cache amount of several first preview files stored in the target storage device is greater than the first cache threshold, it means that the cleaning start condition is met, so that the first preview files in the target storage device can be cleaned up in time in the future, so as to reasonably manage the first preview files in the target storage device, save the storage space of the target storage device, and more effectively use the limited storage space of the target storage device in the future. On the contrary, when the total cache amount of several first preview files stored in the target storage device is less than or equal to the first cache threshold, it means that the total cache amount of several first preview files stored in the target storage device is small and does not occupy a large amount of storage resources of the target storage device, and the storage space of the target storage device is surplus; at this time, if the first preview files in the target storage device are not cleaned up, more first preview files can be saved as much as possible to improve the hit rate of subsequent preview requests, and if the first preview files in the target storage device are cleaned up, when requesting a preview later, it may be necessary to re-download the file and convert it to a previewable format, which will reduce the feedback efficiency based on the preview request; therefore, when the total cache amount of several first preview files stored in the target storage device is less than or equal to the first cache threshold, it means that the cleaning start condition is not met.
[0037] There is no limitation on the size of the first cache threshold, and it can be set according to actual use needs.
[0038] In a specific implementation, the first cache threshold is determined based on the device capacity of the target storage device. For example, the size of the first cache threshold is 80%, 70%, etc. of the device capacity of the target storage device. When the total cache amount of the first preview files stored in the target storage device is greater than the first cache threshold, and the first cache threshold is determined based on the device capacity of the target storage device, it directly indicates that the total cache amount of the first preview files stored in the target storage device occupies a large amount of storage resources of the target storage device; at this time, if the first preview files in the target storage device are not cleaned up, the storage space of the target storage device may be exhausted, resulting in the inability to preview new files, etc.; therefore, when the total cache amount of the first preview files stored in the target storage device is greater than the first cache threshold, it indicates that the cleaning start condition is met, so that the first preview files in the target storage device can be cleaned up in time in the future, so as to reasonably manage the first preview files in the target storage device, save the storage space of the target storage device, and more effectively use the limited storage space of the target storage device in the future. On the contrary, when the total cache amount of several first preview files stored in the target storage device is less than or equal to the first cache threshold, and the first cache threshold is determined based on the device capacity of the target storage device, it directly indicates that the total cache amount of several first preview files stored in the target storage device does not occupy a large amount of storage resources of the target storage device, and the storage space of the target storage device is surplus; at this time, if the first preview files in the target storage device are not cleaned up, more first preview files can be saved as much as possible to improve the hit rate of subsequent preview requests, and if the first preview files in the target storage device are cleaned up, when requesting a preview later, it may be necessary to re-download the file and convert it into a previewable format, which will reduce the feedback efficiency based on the preview request; therefore, when the total cache amount of several first preview files stored in the target storage device is less than or equal to the first cache threshold, it indicates that the cleaning start condition is not met.
[0039] Step S13: in response to the target storage device satisfying the cleaning start condition, cleaning the first preview file in the target storage device.
[0040] In this embodiment, in response to the target storage device satisfying the cleanup start condition, the first preview file in the target storage device is cleaned up. That is, when the target storage device satisfies the cleanup start condition, the first preview file in the target storage device is cleaned up, and the first preview file in the target storage device is cleaned up in time, so as to reasonably manage the first preview file in the target storage device, save the storage space of the target storage device, and subsequently more effectively utilize the limited storage space of the target storage device.
[0041] In one embodiment, in response to the target storage device not satisfying the cleaning start condition, the first preview file in the target storage device is not cleaned. That is, when the target storage device does not satisfy the cleaning start condition, the first preview file in the target storage device is not cleaned, so that more first preview files can be saved in the target storage device as much as possible, thereby improving the hit rate of subsequent preview requests and improving the feedback efficiency based on preview requests.
[0042] In one embodiment, the first preview file in the target storage device is cleaned up, specifically: at least one round of cleaning is performed on the first preview file in the target storage device until the cleaning completion condition is met, wherein the first preview file in each round of cleaning is the first preview file that has not been accessed within the most recent first preset time, and the first preset time corresponding to the next round of cleaning is less than the first preset time corresponding to the previous round of cleaning. That is, when the target storage device meets the cleaning start condition, at least one round of cleaning is performed from far to near according to the most recent access time of the first preview file in the target storage device until the cleaning completion condition is met, that is, the first preview file that has not been accessed for a long time will be cleaned up first until the cleaning completion condition is met. In addition, since the probability of the first preview file that has not been accessed for a long time being accessed later is relatively small, and the probability of the first preview file that has been accessed recently being accessed later is relatively large; therefore, cleaning up the first preview file that has not been accessed for a long time first can save as many first preview files with a high probability of being accessed later in the target storage device as possible, improve the hit rate of subsequent preview requests, and improve the feedback efficiency based on preview requests.
[0043] At least one round of cleaning is performed on the first preview file in the target storage device, that is, the first preview file in the target storage device is cleaned up step by step. Compared with cleaning up the first preview file in the target storage device all at once, on the one hand, the storage space in the target storage device can be released, and the limited storage space of the target storage device can be used more effectively later; on the other hand, more first preview files can be saved in the target storage device as much as possible, thereby improving the hit rate of subsequent preview requests and improving the feedback efficiency based on preview requests.
[0044] There is no limitation on the size of the first preset time length corresponding to each round, and it can be set according to actual use needs. For example, take two rounds of cleaning as an example: the first round of cleaning of the first preview file in the target storage device is to clean up the first preview file in the target storage device that has not been accessed within the last N hours; the second round of cleaning of the first preview file in the target storage device is to clean up the first preview file in the target storage device that has not been accessed within the last N-1 hours.
[0045] In a specific embodiment, the target storage device also stores preview data of each first preview file, and the preview data includes a last access time; at least one round of cleaning is performed on the first preview files in the target storage device until a cleaning completion condition is met, specifically: based on the last access time of each first preview file, the first preview files that have not been accessed within a first preset time period in the target storage device are determined as files to be cleaned; the files to be cleaned are cleaned; it is determined whether the cleaning completion condition is currently met; in response to the cleaning completion condition not being met currently, the first preview files that have not been accessed within the first preset time period in the target storage device are continued to be obtained as new files to be cleaned, and the cleaning of the files to be cleaned and subsequent steps are re-executed until the cleaning completion condition is met.
[0046] That is, when the target storage device meets the cleaning start condition, the first round of cleaning will be executed to clean the first preview files that have not been accessed within the first preset time period corresponding to the first round of cleaning; after the first round of cleaning is completed, it is determined whether the target storage device meets the cleaning completion condition. If the target storage device does not meet the cleaning completion condition after the first round of cleaning is completed, the second round of cleaning will be executed to clean the first preview files that have not been accessed within the first preset time period corresponding to the second round of cleaning; after the second round of cleaning is completed, it is determined whether the target storage device meets the cleaning completion condition. If the target storage device does not meet the cleaning completion condition after the second round of cleaning is completed, the next round of cleaning will continue to be executed until the cleaning completion condition is met.
[0047] For example, the first preset duration corresponding to the first round of cleaning is the last N (N is an integer and can be specifically configured) hours, the first preset duration corresponding to the second round of cleaning is the last N-1 hours, and the last first preset durations corresponding to the remaining other rounds of cleaning are analogous to this example: when the target storage device meets the cleaning start condition, the first round of cleaning will be executed to clean the first preview files that have not been accessed in the last N hours; after the first round of cleaning is completed, it is determined whether the target storage device meets the cleaning completion condition. If the target storage device does not meet the cleaning completion condition after the first round of cleaning is completed, the second round of cleaning will be executed to clean the first preview files that have not been accessed in the last N-1 hours; after the second round of cleaning is completed, it is determined whether the target storage device meets the cleaning completion condition. If the target storage device does not meet the cleaning completion condition after the second round of cleaning is completed, the next round of cleaning will continue until the cleaning completion condition is met.
[0048] It should be noted that the target storage device also stores preview data of each first preview file, and the preview data includes the last access time. For each first preview file stored in the target storage device, the target storage device also stores the corresponding last access time. If the client currently requests a preview and the preview file requested for preview exists in the target storage device, then the last access time corresponding to the preview file requested for preview by the client is updated to the current time. If the client currently requests a preview and the preview file requested for preview does not exist in the target storage device, then the corresponding preview file will be generated and stored in the target storage device, and the last access time of the preview file will be set to the current time.
[0049] Of course, the preview data of each first preview file stored in the target storage device may also include the file size of the first preview file, so that the total cache amount of several first preview files stored in the target storage device can be determined according to the file size of each first preview file.
[0050] In a specific embodiment, the cleaning completion condition includes that the total cache amount of the remaining first preview files in the target storage device is less than or equal to the second cache threshold, and the second cache threshold is less than or equal to the first cache threshold. When the total cache amount of the remaining first preview files in the target storage device is less than or equal to the second cache threshold, it means that the total cache amount of the remaining first preview files in the target storage device is small, and no large amount of storage resources of the target storage device are occupied, the current storage space of the target storage device is surplus, and the situation that the new file cannot be previewed due to the small storage space of the target storage device will not occur. In addition, when the total cache amount of the remaining first preview files in the target storage device is less than or equal to the second cache threshold, the cleaning of the first preview files in the target storage device is stopped instead of completely cleaning the first preview files in the target storage device, so that more first preview files can be saved in the target storage device as much as possible, the hit rate of subsequent preview requests is improved, and the feedback efficiency based on preview requests is improved.
[0051] There is no limitation on the size of the second cache threshold, and it can be set according to actual use needs.
[0052] In a specific implementation, the second cache threshold is determined based on the device capacity of the target storage device. For example, the size of the second cache threshold is 30%, 20%, etc. of the device capacity of the target storage device.
[0053] In other specific embodiments, the cleaning completion condition includes that the remaining first preview files in the target storage device are first preview files that have been accessed within the second preset time period, and the second preset time period is less than the first preset time period. When the client previews, the first preview file can be obtained by block transmission (also known as streaming transmission); in the case of block transmission, the client will dynamically request and receive different parts of the first preview file according to the size of the current viewport and the user's browsing behavior. The first preview file that has been accessed within the second preset time period may be the first preview file that is currently being accessed by the client, such as the client is accessing the first half of the first preview file A. By setting the cleaning completion condition to that the remaining first preview files in the target storage device are first preview files that have been accessed within the second preset time period, it is possible to avoid cleaning up the first preview file that is currently being accessed by the client, that is, it is possible to avoid the situation where the first preview file is cleaned up during the preview process by the client, resulting in preview failure, thereby improving the user experience.
[0054] The second preset time length is not limited and can be set according to actual use needs. For example, if the second preset time length is 1 hour, then the cleaning completion condition is that the remaining first preview files in the target storage device are first preview files that have been accessed within the last 1 hour.
[0055] In one embodiment, the device cleaning method provided by the present application is executed once every third preset time period. In other words, the device cleaning method provided by the present application is triggered once every third preset time period to regularly clean the device and improve the timeliness of device cleaning.
[0056] The third preset time length is not limited and can be set according to actual use needs. For example, if the third preset time length is 1 hour, the device will be cleaned up every 1 hour.
[0057] In other embodiments, the device cleaning method provided by the present application is configured to be executed when it is determined that the target storage device will add a new first preview file within a fourth preset time length. When receiving a preview request from a client, it is determined whether the preview file requested by the client preview exists in the target storage device. If the preview file requested by the client preview does not exist in the target storage device, a preview file corresponding to the client preview request is generated and stored in the target storage device. Therefore, if the preview file requested by the client preview does not exist in the target storage device, it means that the target storage device will add a new first preview file within the fourth preset time length. At this time, the execution of the device cleaning method will be triggered.
[0058] In other embodiments, the device cleaning method provided by the present application is configured to be executed once every third preset time interval, and is executed when it is determined that the target storage device will add a new first preview file within a fourth preset time interval. The device cleaning method is triggered to execute every third preset time interval as a timed trigger, and the device cleaning method is triggered to execute in real-time when it is determined that the target storage device will add a new first preview file within the fourth preset time interval. The timed trigger and real-time trigger mechanisms can complement each other. When the preview access volume is at a low point (all preview cache hits), the timed trigger plays the role of active device cleaning. When the preview access volume is at a peak, the timed cleaning time point may not have been reached at this time, and the real-time trigger plays the role of passive device cleaning. The combination of real-time trigger and timed trigger improves the timeliness of device cleaning, ensures that the target storage device is always kept in a good state, and provides users with stable and efficient preview services.
[0059] In one embodiment, the target storage device is fully cleaned every sixth preset time period, that is, all first preview files in the target storage device are deleted every sixth preset time period as a means of thoroughly cleaning the target storage device to ensure that the first preview files in the target storage device do not grow indefinitely, and as an emergency option.
[0060] The sixth preset time length is not limited, and can be set according to actual use needs. For example, if the sixth preset time length is 1 week, then the device will be fully cleaned every 1 week.
[0061] In one specific implementation, the full cleaning may be manually triggered by the user at every sixth preset time. Of course, in other specific implementations, the full cleaning of the device may be triggered at every sixth preset time.
[0062] In one embodiment, the target storage device also stores preview data of each first preview file, and the preview data includes a last access time; at this time, a first preview request sent by the client is received, wherein the first preview request is generated and sent by the client after accessing the second preview file for more than a fifth preset time, and the second preview file is the first preview file fed back when the client requests a preview; the last access time of the second preview file is updated.
[0063] That is to say, after the client previews a first preview file for more than the fifth preset time, the client will resend the preview request to update the last access time of the first preview file previewed by the client, so as to prevent the first preview file currently being previewed by the client from being cleared and causing preview failure. Since when the target storage device meets the cleaning start condition, the first preview files in the target storage device that have not been accessed within the last first preset time will be cleared. Therefore, the client re-initiates the preview request, which can update the last access time of the first preview file currently being previewed by the client, so as to prevent the first preview file currently being previewed by the client from being cleared as a first preview file that has not been accessed for a long time.
[0064] The fifth preset time length is not limited and can be set according to actual use needs. For example, the fifth preset time length is 1 hour.
[0065] like Figure 2 As shown, the client will detect whether the preview exceeds 1 hour. If so, it will resend the file preview request to the preview component. The preview component will update the last access time of the first preview file accessed by the client, and the client can continue to obtain preview files in blocks.
[0066] In one embodiment, the target storage device further stores preview data of a first preview file, the preview data including a most recent access time, and further receives a second preview request sent by a client, wherein the second preview request includes a file identifier and a download address of a target file corresponding to the file identifier; determines whether the first preview file corresponding to the file identifier exists in the target storage device; in response to the existence of the first preview file corresponding to the file identifier in the target storage device, feeds back the first preview file corresponding to the file identifier to the client, and updates the most recent access time of the first preview file corresponding to the file identifier; in response to the absence of the first preview file corresponding to the file identifier in the target storage device, downloads the target file corresponding to the file identifier from the download address, and generates a first preview file based on the target file; feeds back the first preview file corresponding to the file identifier to the client, and records the most recent access time of the first preview file corresponding to the file identifier at the current moment.
[0067] That is, the client sends a second preview request to the preview component to request an online preview file, wherein the second preview request includes a file download address and a file identifier, and the file identifier of each file is globally unique; the preview component queries to determine whether a first preview file with a corresponding file identifier exists in the target storage device; if the first preview file with a corresponding file identifier exists in the target storage device, the first preview file is fed back to the client; if the first preview file with a corresponding file identifier does not exist in the target storage device, the file is downloaded from the download address sent by the client, and a preview file is generated based on the downloaded file, and then the preview file is fed back to the client, and the preview file is stored in the target storage device, and the last access time of the generated preview file is initialized to the current time.
[0068] In a specific implementation, a first preview file is generated based on a target file, specifically by: obtaining a file type of the target file; in response to the file type being a first format type, using the target file as a first preview file; in response to the file type being a second format type, performing format conversion on the target file to obtain a converted file, and using the converted file as the first preview file.
[0069] That is, if the first preview file corresponding to the file identifier does not exist in the target storage device, the file is downloaded from the download address sent by the client, and a preview file is generated based on the downloaded file. When the file downloaded from the download address is in a previewable file format, that is, when the file downloaded from the download address is in the first format type, the file downloaded from the download address is directly used as the corresponding first preview file. When the file downloaded from the download address is in a non-previewable file format, that is, when the file downloaded from the download address is in the second format type, the file downloaded from the download address will be converted into a previewable file format.
[0070] See also Figure 3 , Figure 3 It is a structural diagram of an embodiment of a device cleaning device provided by the present application. The device cleaning device 30 includes an acquisition module 31, a detection module 32 and a cleaning module 33. The acquisition module 31 is used to obtain the total cache amount of several first preview files stored in the target storage device; wherein the target storage device is a device in the cloud disk for storing first preview files corresponding to different target files, and the first preview file is generated when the client requests to preview the corresponding target file; the detection module 32 is used to detect whether the target storage device meets the cleaning start condition based on the total cache amount of several first preview files; the cleaning module 33 is used to clean up the first preview file in the target storage device in response to the target storage device meeting the cleaning start condition.
[0071] The cleaning start condition includes that the total cache amount of a plurality of first preview files is greater than a first cache threshold.
[0072] The first cache threshold is determined based on the device capacity of the target storage device.
[0073] Among them, the cleaning module 33 is used to clean up the first preview file in the target storage device, including: performing at least one round of cleaning on the first preview file in the target storage device until the cleaning completion condition is met; wherein the first preview file in each round of cleaning is the first preview file that has not been accessed within the last first preset time length, and the first preset time length corresponding to the next round of cleaning is less than the first preset time length corresponding to the previous round of cleaning.
[0074] Among them, the above-mentioned target storage device also stores preview data of each first preview file, and the preview data includes a most recent access time; the cleaning module 33 is used to perform at least one round of cleaning on the first preview files in the target storage device until the cleaning completion condition is met, including: based on the most recent access time of each first preview file, determining the first preview files in the target storage device that have not been accessed within the most recent first preset time period as files to be cleaned; cleaning the files to be cleaned; determining whether the cleaning completion condition is currently met; in response to not currently meeting the cleaning completion condition, continuing to obtain the first preview files in the target storage device that have not been accessed within the most recent first preset time period as new files to be cleaned, and re-executing the cleaning of the files to be cleaned and its subsequent steps until the cleaning completion condition is met.
[0075] Among them, the above-mentioned cleaning completion conditions include at least one of the following: the total cache amount of the remaining first preview files in the target storage device is less than or equal to the second cache threshold, the remaining first preview files in the target storage device are the first preview files that have been accessed within the last second preset time length, wherein the second cache threshold is less than or equal to the first cache threshold, and the second preset time length is less than the first preset time length.
[0076] The device cleaning method is configured to be executed once every third preset time period; and / or the device cleaning method is configured to be executed when it is determined that a new first preview file will be added to the target storage device within a fourth preset time period.
[0077] Among them, the above-mentioned target storage device also stores preview data of each first preview file, and the preview data includes the last access time; the device cleaning device 30 also includes an update module 34, and the update module 34 is used to receive a first preview request sent by the client; wherein, the first preview request is generated and sent by the client after accessing the second preview file for more than a fifth preset time, and the second preview file is the first preview file fed back when the client requests a preview; the last access time of the second preview file is updated.
[0078] The target storage device also stores preview data of each first preview file, and the preview data includes a most recent access time. The device cleaning device 30 also includes a feedback module 35, and the feedback module 35 is used to receive a second preview request sent by the client. The second preview request includes a file identifier and a download address of a target file corresponding to the file identifier. It is determined whether the first preview file corresponding to the file identifier exists in the target storage device. In response to the existence of the first preview file corresponding to the file identifier in the target storage device, the first preview file corresponding to the file identifier is fed back to the client, and the most recent access time of the first preview file corresponding to the file identifier is updated. In response to the absence of the first preview file corresponding to the file identifier in the target storage device, the target file corresponding to the file identifier is downloaded from the download address, and the first preview file is generated based on the target file. The first preview file corresponding to the file identifier is fed back to the client, and the most recent access time of the first preview file corresponding to the file identifier is recorded at the current time.
[0079] Among them, the feedback module 35 is used to generate a first preview file based on the target file, including: obtaining the file type of the target file; in response to the file type being a first format type, using the target file as the first preview file; in response to the file type being a second format type, performing format conversion on the target file to obtain a converted file, and using the converted file as the first preview file.
[0080] See also Figure 4 , Figure 4 4 is a schematic diagram of the structure of an embodiment of an electronic device provided by the present application. The electronic device 40 includes a memory 41 and a processor 42 coupled to each other, and the processor 42 is used to execute program instructions stored in the memory 41 to implement the steps of any of the above-mentioned device cleaning method embodiments. In a specific implementation scenario, the electronic device 40 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 40 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0081] Specifically, the processor 42 is used to control itself and the memory 41 to implement the steps of any of the above-mentioned device cleaning method embodiments. The processor 42 can also be called a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 42 can be implemented by an integrated circuit chip.
[0082] See also Figure 5 , Figure 5 It is a structural diagram of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 50 of the embodiment of the present application stores a program instruction 51, and when the program instruction 51 is executed, it implements the method provided by any embodiment of the device cleaning method of the present application and any non-conflicting combination. Among them, the program instruction 51 can form a program file and be stored in the above-mentioned computer-readable storage medium 50 in the form of a software product, so that a computer device (which can be a personal computer, a server, or a network device, etc.) executes all or part of the steps of the methods of each implementation method of the present application. The aforementioned computer-readable storage medium 50 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, or a terminal device such as a computer, a server, a mobile phone, and a tablet.
[0083] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0084] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A device cleaning method, characterized in that: The method comprises: Obtaining a total cache amount of a plurality of first preview files stored in a target storage device; wherein the target storage device is a device in a cloud disk for storing first preview files corresponding to different target files, and the first preview files are generated when a client requests to preview a corresponding target file; Based on the total cache amount of the plurality of first preview files, detecting whether the target storage device meets a cleaning start condition; In response to the target storage device satisfying the cleaning start condition, performing at least one round of cleaning on the first preview files in the target storage device until a cleaning completion condition is satisfied; wherein the first preview files in each round of cleaning are first preview files that have not been accessed within a recent first preset time period, the first preset time period corresponding to a subsequent round of cleaning is less than the first preset time period corresponding to a previous round of cleaning, and the cleaning completion condition includes that the remaining first preview files in the target storage device are first preview files that have been accessed within a recent second preset time period, and the second preset time period is less than the first preset time period; The target storage device further stores preview data of each of the first preview files, and the preview data includes a most recent access time; the method further includes: Receiving a first preview request sent by the client; wherein the first preview request is generated and sent by the client after accessing the second preview file for more than a fifth preset time, and the second preview file is the first preview file fed back when the client requests a preview; The last access time of the second preview file is updated.
2. The method according to claim 1, characterized in that The cleaning start condition includes that the total cache amount of the plurality of first preview files is greater than a first cache threshold.
3. The method according to claim 2, characterized in that The first cache threshold is determined based on a device capacity of the target storage device.
4. The method according to claim 1, characterized in that: The target storage device further stores preview data of each of the first preview files, wherein the preview data includes a most recent access time; and performing at least one round of cleaning of the first preview files in the target storage device until a cleaning completion condition is met, comprising: Based on the most recent access time of each of the first preview files, determining first preview files in the target storage device that have not been accessed within a first preset time period as files to be cleaned up; Cleaning up the files to be cleaned up; Determine whether the cleaning completion conditions are currently met; In response to the cleaning completion condition not being met at present, continue to obtain the first preview file in the target storage device that has not been accessed within the last first preset time period as a new file to be cleaned, and re-execute the cleaning of the file to be cleaned and its subsequent steps until the cleaning completion condition is met.
5. The method according to claim 1, characterized in that The cleanup completion condition also includes that a total cache amount of remaining first preview files in the target storage device is less than or equal to a second cache threshold, wherein the second cache threshold is less than or equal to the first cache threshold.
6. The method according to claim 1, characterized in that The method is configured to be performed once every third preset time interval; And / or, the method is configured to be executed when it is determined that the target storage device will add a new first preview file within a fourth preset time period.
7. The method according to claim 1, characterized in that The target storage device further stores preview data of each of the first preview files, wherein the preview data includes a most recent access time; and the method further includes: receiving a second preview request sent by the client; wherein the second preview request includes a file identifier and a download address of a target file corresponding to the file identifier; Determining whether a first preview file corresponding to the file identifier exists in the target storage device; In response to the first preview file corresponding to the file identifier existing in the target storage device, feeding back the first preview file corresponding to the file identifier to the client, and updating the most recent access time of the first preview file corresponding to the file identifier; In response to the first preview file corresponding to the file identifier not existing in the target storage device, downloading the target file corresponding to the file identifier from the download address, and generating a first preview file based on the target file; The first preview file corresponding to the file identifier is fed back to the client, and the current time is recorded as the most recent access time of the first preview file corresponding to the file identifier.
8. The method according to claim 7, characterized in that The generating a first preview file based on the target file comprises: Obtain the file type of the target file; In response to the file type being a first format type, using the target file as the first preview file; In response to the file type being the second format type, the target file is format converted to obtain a converted file, and the converted file is used as the first preview file.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program instructions, and the program instructions can be executed to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
File previewing method, device and equipment and computer storage medium
CN116166619A
Data cleaning method and device for terminal equipment, equipment and storage medium
CN116560572A