Data caching method, device, electronic device and storage medium for online applications
By updating the access information of network files in online applications and deleting the files with the lowest access popularity, the problem of storage space is solved and more efficient data cache management is achieved.
Patent Information
- Application Number
- CN202110155661.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-04
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-02-04
AI Technical Summary
When existing online applications are cached local data, they cannot accurately identify and delete files that are not often used, resulting in the problem of full storage space.
By receiving access requests for network files, we can determine whether the file has been stored in the local storage space. If it has been stored, update the access information of the file, including access time and access popularity; if it is not stored, download the file and delete the file with the lowest access popularity to make space.
It realizes accurate identification and deletion of infrequently used files, avoids full storage space and improves the work efficiency of online applications.
Smart Images

Figure CN113806649B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data management, and in particular to a data caching method, device, electronic device and storage medium for online applications. Background Art
[0002] Online applications, such as WeChat applets, often need to download network files to the local computer before performing related processing, such as Canvas drawing, file editing, image editing, etc. These files are usually not updated. If the files are downloaded to the local computer for processing every time, a lot of redundant downloads will be added, and the user experience will be poor. Therefore, online applications generally cache the downloaded network files locally. Currently, there are two main local data caching methods:
[0003] The first type is that every time you download a network file, no matter whether the network file is already stored locally, it will be downloaded again and saved directly to the local storage space. Since the local storage space size of online applications is limited, for example, the maximum storage space is 10M, when the local storage space is full, saving network files will fail.
[0004] The second method is to combine local storage. Every time you want to download a network file, delete the files that have not been used recently in the local storage space of the online application, so as to obtain enough free space to save the network file to be downloaded. However, this method has the problem of not being able to accurately delete files that are not frequently used. Because the access time of a file cannot accurately identify whether the file is frequently accessed, if a file has not been accessed for a long time and is suddenly accessed at a certain moment, it is very likely that the file will not be deleted when it is deleted next time, but the file data is likely to be rarely accessed, and the file should be deleted from the local storage space. Summary of the invention
[0005] In view of this, an object of the present invention is to provide a data caching method, device, electronic device and storage medium for online applications, which can accurately identify and delete files that are not frequently used.
[0006] In order to achieve the above object, the present invention provides the following technical solutions:
[0007] A data caching method for an online application, comprising:
[0008] receiving access requests for network files;
[0009] Determining whether the network file has been stored in the local storage space of the online application;
[0010] If the network file has been stored in the local storage space of the online application, the access information of the network file is updated according to the current time, and the access information includes the access time and the access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of the network file being accessed;
[0011] If the network file is not stored in the local storage space of the online application, the network file is downloaded, the network file with the lowest access popularity of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized.
[0012] A data cache device for online applications, comprising:
[0013] A receiving unit, used for receiving an access request for a network file;
[0014] A judging unit, configured to judge whether the network file has been stored in the local storage space of the online application after the receiving unit receives the access request for the network file;
[0015] A processing unit is used to update the access information of the network file according to the current time if the judgment unit determines that the network file has been stored in the local storage space of the online application, the access information including the access time and the access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file; if the judgment unit determines that the network file is not stored in the local storage space of the online application, download the network file, delete the network file with the lowest access popularity of the online application to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0016] An electronic device, comprising: a processor and a memory;
[0017] The memory stores one or more computer programs that can be executed by the processor; when the processor executes the one or more computer programs, the steps in the data caching method for online applications are implemented.
[0018] A non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, enable the processor to implement the steps in the above-mentioned online application data caching method.
[0019] It can be seen from the above technical solution that in the present invention, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time, and the access information includes the access time and the access heat used to indicate the frequency of access to the network file; if the network file is not stored locally, the network file is downloaded, the network file with the lowest access heat of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized. The present invention can accurately identify and delete files that are not frequently used. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 This is a flow chart of a data caching method for online applications according to an embodiment of the present invention;
[0022] Figure 2 This is a flow chart of a data caching method for online applications according to a second embodiment of the present invention;
[0023] Figure 3 This is a flow chart of a data caching method for online applications according to Embodiment 3 of the present invention;
[0024] Figure 4 This is a flow chart of a data caching method for online applications according to a fourth embodiment of the present invention;
[0025] Figure 5 This is a flow chart of a data caching method for online applications according to a fifth embodiment of the present invention;
[0026] Figure 6 This is a flow chart of a data caching method for online applications according to a sixth embodiment of the present invention;
[0027] Figure 7 This is a flow chart of a data caching method for online applications according to Embodiment 7 of the present invention;
[0028] Figure 8 This is a flow chart of a data caching method for online applications according to Embodiment 8 of the present invention;
[0029] Fig. 9 This is a flow chart of a data caching method for online applications according to a ninth embodiment of the present invention;
[0030] Fig.10It is a structural diagram of a data cache device for online application according to an embodiment of the present invention;
[0031] Fig.11 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] See also Figure 1 , Figure 1 : is a flow chart of a data caching method for online application in Embodiment 1 of the present invention. Figure 1 As shown, the method mainly includes the following steps:
[0034] Step 101: receiving an access request for a network file;
[0035] Step 102, determining whether the network file has been stored in the local storage space of the online application, if yes, executing step 103, otherwise, executing step 104;
[0036] Step 103: update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file;
[0037] Step 104: download the network file, delete the network file with the lowest access popularity among online applications to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize access information of the network file.
[0038] from Figure 1It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, the network file with the lowest access popularity of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized. By updating the access popularity of the locally stored network files and deleting the locally stored network files with the lowest access popularity to store the newly downloaded network files, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved, and because the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, thereby improving the working efficiency of online applications.
[0039] See also Figure 2 , Figure 2 : is a flow chart of a data caching method for online application in Embodiment 2 of the present invention. Figure 2 As shown, the method mainly includes the following steps:
[0040] Step 201: receiving an access request for a network file;
[0041] Step 202: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 2031; otherwise, execute step 204;
[0042] Step 2031, calculating the time interval between the current time and the access time in the access information of the network file;
[0043] In this embodiment, the time interval between the current time and the access time in the access information of the network file is the time interval between the current access to the network file and the previous access to the network file.
[0044] Step 2032: determining the current access popularity of the network file according to the time interval and the access popularity in the access information of the network file;
[0045] In this embodiment, the shorter the access interval to the network file, the higher the access frequency of the network file, the more it indicates that the network file is hot data (i.e., data that is frequently accessed) and has a higher access popularity. Conversely, the longer the access interval to the network file, the lower the access frequency of the network file, the lower the access frequency of the network file, the more it indicates that the network data is cold data (i.e., data that is not frequently accessed) and has a lower access popularity.
[0046] Step 2033: update the access time and access heat in the access information of the network file to the current time and the current access heat respectively;
[0047] The above steps 2031 to 2033 are Figure 1 The specific refinement of step 103 is shown.
[0048] Step 204: download the network file, delete the network file with the lowest access popularity among online applications to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize access information of the network file.
[0049] In this embodiment, initializing the access information of the network file specifically includes: setting the access time and access heat in the access information of the network file to the current time and the preset initialization heat respectively. Here, the initialization heat can be determined based on experience or actual needs. For example, the initialization heat is set to the preset minimum access heat T min and preset maximum access heat T max The middle value of T min and T max They are the minimum and maximum allowed values of access heat, which can be determined according to actual needs.
[0050] from Figure 2 It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the current access heat of the network file is determined by using the time interval between the current time and the access time in the access information of the network file, and then the access information of the network file is updated; if the network file is not stored locally, the network file is downloaded, the network file with the lowest access heat of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized. By updating the access heat of the locally stored network file and deleting the locally stored network file with the lowest access heat to store the newly downloaded network file, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved, and because the most frequently used network files are stored in the local storage space, the number of downloads of the network file can be further reduced, thereby improving the working efficiency of the online application.
[0051] See also Figure 3 , Figure 3 : is a flow chart of a data caching method for online application in Embodiment 3 of the present invention. Figure 3 As shown, the method mainly includes the following steps:
[0052] Step 301: receiving an access request for a network file;
[0053] Step 302: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 3031; otherwise, execute step 304;
[0054] Step 3031, calculating the time interval between the current time and the access time in the access information of the network file;
[0055] In this embodiment, the time interval between the current time and the access time in the access information of the network file is the time interval between the current access to the network file and the previous access to the network file.
[0056] Step 3032a, calculating the ratio of the time interval to the preset time threshold, when the ratio is greater than 1, executing step 3032b, when the ratio is equal to 1, executing step 3032c, when the ratio is less than 1, executing step 3032d;
[0057] In this embodiment, according to the time interval and the preset time threshold, it is determined whether to increase or decrease the access popularity in the access information of the network file to obtain the current access popularity of the network file. The preset time threshold can be set according to experience or actual needs, for example, a value of 1024.
[0058] Step 3032b, determining the heat reduction ratio according to the principle that the larger the ratio, the larger the reduction ratio, and determining the current access heat of the network file according to the heat reduction ratio and the access heat in the access heat information of the network file;
[0059] In this embodiment, the larger the ratio of the time interval to the preset time threshold, the lower the access frequency of the network file. The access heat in the access heat information of the network file can be lowered so that the access frequency of the network file matches the access heat.
[0060] In a preferred embodiment of the present invention, the heat reduction ratio α can be determined according to the principle that the larger the ratio R, the larger the reduction ratio, which can be achieved by using the following formula α=R-1.
[0061] In this embodiment, determining the current access heat of the network file according to the heat reduction ratio and the access heat in the access heat information of the network file specifically includes:
[0062] The access heat in the access heat information of the network file is adjusted downward according to the heat reduction ratio to obtain a new access heat. If the new access heat is less than the preset minimum access heat T min , then the current access heat of the network file is set to T min; Otherwise, the current access heat of the network file is set as the new access heat.
[0063] In a preferred embodiment of the present invention, the access heat in the access heat information of the network file is adjusted downward according to the heat reduction ratio to obtain a new access heat T m1 , the following formula can be used: Among them, t i-1 and T i-1 are the access time and access heat in the access heat information of the network file, respectively, i is the current access time, and N is the preset time threshold.
[0064] Step 3032c, determining the access heat in the access heat information of the network file as the current access heat of the network file;
[0065] Step 3032d: determine the heat increase ratio according to the principle that the smaller the ratio, the larger the increase ratio; and determine the current access heat of the network file according to the heat increase ratio and the access heat in the access heat information of the network file.
[0066] In this embodiment, the smaller the ratio of the time interval to the preset time threshold, the higher the access frequency of the network file. The access heat in the access heat information of the network file can be increased so that the access frequency of the network file matches the access heat.
[0067] In a preferred embodiment of the present invention, the heat increase ratio β is determined according to the principle that the smaller the ratio R is, the larger the increase ratio is, which can be achieved by using the following formula β=1-R.
[0068] In this embodiment, determining the current access heat of the network file according to the heat increase ratio and the access heat in the access heat information of the network file specifically includes:
[0069] The access heat in the access heat information of the network file is adjusted upward according to the heat increase ratio to obtain a new access heat. If the new access heat is greater than the preset maximum access heat T max , then the current access heat of the network file is set to T max , otherwise, the current access heat of the network file is set as the new access heat.
[0070] In a preferred embodiment of the present invention, the access heat in the access heat information of the network file is adjusted upward according to the heat increase ratio to obtain a new access heat T m2 , the following formula can be used: Among them, t i-1 and Ti-1 are the access time and access heat in the access heat information of the network file, respectively, i is the current access time, and N is the preset time threshold.
[0071] The above steps 3032a to 3032d are Figure 2 The specific refinement of step 2032 is shown.
[0072] Step 3033: update the access time and access heat in the access information of the network file to the current time and the current access heat respectively;
[0073] The above steps 3031 to 3033 are Figure 1 The specific refinement of step 103 is shown.
[0074] Step 304: download the network file, delete the network file with the lowest access popularity among online applications to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize access information of the network file.
[0075] In this embodiment, initializing the access information of the network file specifically includes: setting the access time and access heat in the access information of the network file to the current time and the preset initialization heat respectively. Here, the initialization heat can be determined based on experience or actual needs. For example, the initialization heat is set to the preset minimum access heat T min and preset maximum access heat T max The middle value of .
[0076] from Figure 3 It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file is already stored locally, the time interval between the current time and the access time in the access information of the network file, and the ratio of the time interval to the preset time threshold are calculated, and the access heat in the access information of the network file is adjusted up or down according to the ratio to obtain the current access heat of the network file, and then the access information of the network file is updated; if the network file is not stored locally, the network file is downloaded, the network file with the lowest access heat of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized. By updating the access heat of the locally stored network file and deleting the locally stored network file with the lowest access heat to store the newly downloaded network file, the purpose of accurately identifying and deleting the network file that is not frequently used can be achieved, and since the local storage space stores the most frequently used network files, the number of downloads of the network file can be further reduced, and the working efficiency of the online application can be improved.
[0077] See also Figure 4 , Figure 4 4 is a flow chart of a data caching method for online application according to a fourth embodiment of the present invention. Figure 4 As shown, the method mainly includes the following steps:
[0078] Step 401: receiving an access request for a network file;
[0079] Step 4021, searching for a network file whose network download address is the same as the network download address of the network file from the existing network files of the online application, if found, executing step 4022, otherwise executing step 4023;
[0080] In this embodiment, each existing network file of the online application (ie, each network file stored in the local storage space of the online application) has corresponding access information, and the access information includes not only the access time and access popularity, but also the network download address.
[0081] Under normal circumstances, the network download address of the same network file is unchanged. Therefore, the network download address of the network file can be compared with the network download address included in the access information of each network file already applied online. If a network file is found whose network download address included in the access information is the same as the network download address of the network file, step 4022 can be executed, otherwise, step 4023 can be executed.
[0082] Step 4022: Determine that the network file has been stored in the local storage space of the online application, and go to step 403;
[0083] Step 4023: Determine that the network file is not stored in the local storage space of the online application, and go to step 404;
[0084] The above steps 4021 to 4023 are Figure 1 The specific refinement of step 102 is shown.
[0085] Step 403: update the access information of the network file according to the current time, wherein the access information includes the access time, access popularity and network download address; wherein the access time indicates the time record of the last access to the network file, and the access popularity indicates the frequency of access to the network file;
[0086] Step 404: download the network file, delete the network file with the lowest access popularity among online applications to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize access information of the network file.
[0087] from Figure 4 It can be seen from the method shown that in this embodiment, when an access request for a network file is received, it is determined whether the network file has been stored locally by comparing the network download address. If the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, the network file with the lowest access popularity of the online application is deleted to obtain local storage space, the downloaded network file is stored in the obtained local storage space, and the access information of the network file is initialized. By updating the access popularity of the locally stored network files and deleting the locally stored network files with the lowest access popularity to store the newly downloaded network files, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved. Moreover, since the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, thereby improving the working efficiency of online applications.
[0088] See also Figure 5 , Figure 5 : is a flow chart of a data caching method for online application in Embodiment 5 of the present invention. Figure 5 As shown, the method mainly includes the following steps:
[0089] Step 501: Receive an access request for a network file;
[0090] Step 502: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 503; otherwise, execute step 5041;
[0091] Step 503: Update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; wherein the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file;
[0092] Step 5041, downloading the network file;
[0093] In this embodiment, the network file can be downloaded from the network download address of the network file.
[0094] Step 5042: Calculate the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0095] In this embodiment, the upper limit of the local storage space of the online application is pre-set, for example, 10M.
[0096] In this embodiment, assuming that the storage space required by the network file is cursize, and the storage space occupied by the existing network files of the online application (that is, the storage space occupied by the network files stored in the local storage space of the online application) is totalsize, then the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application is cursize+totalsize.
[0097] Step 5043: determine whether the sum of the spaces exceeds the upper limit of the local storage space of the online application. If so, execute step 5044; otherwise, execute step 5045.
[0098] In this embodiment, if the sum of the spaces exceeds the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is small, and it is necessary to delete the existing network files to free up enough storage space to store the newly downloaded network files, so step 5044 is executed. If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is large, and the newly downloaded network files can be directly stored in the local storage space of the online application without deleting the existing network files, so step 5045 is executed.
[0099] Step 5044: Delete the network file with the lowest access popularity of the online application to obtain local storage space, and go to step 5046;
[0100] Step 5045: do not delete the network file with the lowest access popularity of the online application to obtain the local storage space, but directly obtain the local storage space, and go to step 5046;
[0101] Step 5046: Store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0102] The above steps 5041 to 5046 are Figure 1 The specific refinement of step 104 is shown.
[0103] from Figure 5It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, and according to whether the sum of the space required for the network file and the space occupied by the network files already in the online application exceeds the upper limit of the storage space of the online application, it is determined whether to perform the operation of deleting the network file with the lowest access popularity of the online application to obtain the local storage space, and then the downloaded network file is stored in the local storage space of the online application, and the access information of the network file is initialized. By updating the access popularity of the locally stored network files and deleting the locally stored network files with the lowest access popularity to store the newly downloaded network files, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved, and because the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, thereby improving the working efficiency of the online application.
[0104] See also Figure 6 , Figure 6 : is a flow chart of a data caching method for online application in Embodiment 6 of the present invention. Figure 6 As shown, the method mainly includes the following steps:
[0105] Step 601: Receive an access request for a network file;
[0106] Step 602: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 603; otherwise, execute step 6041;
[0107] Step 603: Update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; wherein the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file;
[0108] Step 6041, downloading the network file;
[0109] In this embodiment, the network file can be downloaded from the network download address of the network file.
[0110] Step 6042: Calculate the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0111] In this embodiment, the upper limit of the local storage space of the online application is pre-set, for example, 10M.
[0112] In this embodiment, assuming that the storage space required by the network file is cursize, and the storage space occupied by the existing network files of the online application (that is, the storage space occupied by the network files stored in the local storage space of the online application) is totalsize, then the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application is cursize+totalsize.
[0113] Step 6043: determine whether the sum of the spaces exceeds the upper limit of the local storage space of the online application. If so, execute step 6044; otherwise, execute step 6045.
[0114] In this embodiment, if the sum of the spaces exceeds the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is small, and it is necessary to delete the existing network files to free up enough storage space to store the newly downloaded network files, so step 6044 is executed. If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is large, and the newly downloaded network files can be directly stored in the local storage space of the online application without deleting the existing network files, so step 6045 is executed.
[0115] Step 6044a, calculating the difference between the sum of the spaces and the upper limit of the local storage space of the online application;
[0116] Step 6044b, delete the network file with the lowest access popularity among the network files already available in the online application, so as to obtain a local storage space whose size is not less than the difference between the spaces, and then go to step 6046;
[0117] In one embodiment of the present invention, the network file with the lowest access popularity among the existing network files of the online application is deleted to obtain a local storage space whose size is not less than the difference of the spaces. Specifically, the following method can be used:
[0118] Sort the existing network files of online applications from low to high according to access popularity;
[0119] Delete the first M network files in the sorting order, and the first M network files meet the following conditions: the storage space occupied by the first M-1 network files in the sorting order is less than the difference in space, and the storage space occupied by the first M network files is greater than the difference in space. The above conditions can ensure that the storage space finally vacated can just accommodate the newly downloaded network file.
[0120] The above steps 6044a to 6044b are Figure 5 A specific refinement of step 5044 is shown.
[0121] Step 6045: Do not delete the network file with the lowest access popularity of the online application to obtain the local storage space, but directly obtain the local storage space, and go to step 6046;
[0122] Step 6046: store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0123] The above steps 6041 to 6046 are Figure 1 The specific refinement of step 104 is shown.
[0124] from Figure 6 It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, and according to whether the sum of the space required for the network file and the space occupied by the network files already in the online application exceeds the upper limit of the storage space of the online application, it is determined whether to perform the operation of deleting the network file with the lowest access popularity of the online application to obtain the local storage space, and then the downloaded network file is stored in the local storage space of the online application, and the access information of the network file is initialized. By updating the access popularity of the locally stored network files and deleting the locally stored network files with the lowest access popularity to store the newly downloaded network files, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved, and because the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, thereby improving the working efficiency of the online application.
[0125] See also Figure 7 , Figure 7 : is a flow chart of a data caching method for online application in Embodiment 7 of the present invention. Figure 7 As shown, the method mainly includes the following steps:
[0126] Step 701: Receive an access request for a network file;
[0127] Step 702: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 703; otherwise, execute step 7041;
[0128] Step 703: Update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; wherein the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file;
[0129] Step 7041, calling the network file downloading interface to download the network file to a preset temporary file path;
[0130] In this embodiment, the temporary file path is pre-set and is used to temporarily store downloaded network files.
[0131] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path is successful, continue to execute step 7042;
[0132] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path fails, it further includes: outputting a download failure prompt message and terminating the current process.
[0133] In this embodiment, the network file can be downloaded from the network download address of the network file.
[0134] Step 7042: Calculate the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0135] In this embodiment, the upper limit of the local storage space of the online application is pre-set, for example, 10M.
[0136] In this embodiment, assuming that the storage space required by the network file is cursize, and the storage space occupied by the existing network files of the online application (that is, the storage space occupied by the network files stored in the local storage space of the online application) is totalsize, then the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application is cursize+totalsize.
[0137] Step 7043: determine whether the sum of the spaces exceeds the upper limit of the local storage space of the online application. If so, execute step 7044; otherwise, execute step 7045.
[0138] In this embodiment, if the sum of the spaces exceeds the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is small, and it is necessary to delete the existing network files to free up enough storage space to store the newly downloaded network files, so step 7044 is executed. If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is large, and the newly downloaded network files can be directly stored in the local storage space of the online application without deleting the existing network files, so step 7045 is executed.
[0139] Step 7044: Delete the network file with the lowest access popularity of the online application to obtain local storage space, and go to step 7046;
[0140] Step 7045: do not delete the network file with the lowest access popularity of the online application to obtain the local storage space, but directly obtain the local storage space, and go to step 7046;
[0141] Step 7046: store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0142] The above steps 7041 to 7046 are Figure 1 The specific refinement of step 104 is shown.
[0143] from Figure 7 It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, and according to whether the sum of the space required for the network file and the space occupied by the network files already in the online application exceeds the upper limit of the storage space of the online application, it is determined whether to perform the operation of deleting the network file with the lowest access heat of the online application to obtain the local storage space, and then the downloaded network file is stored in the local storage space of the online application, and the access information of the network file is initialized. By updating the access heat of the locally stored network files and deleting the network files with the lowest access heat stored locally to store the newly downloaded network files, the purpose of accurately identifying and deleting network files that are not frequently used can be achieved, and since the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, and the working efficiency of online applications can be improved. In addition, in this embodiment, when the operation of calling the download network file interface to download the network data to the preset temporary file path fails, fault tolerance processing is performed to avoid errors in the operation of the online application.
[0144] See also Figure 8 , Figure 8 8 is a flow chart of a data caching method for online applications according to an eighth embodiment of the present invention. Figure 8 As shown, the method mainly includes the following steps:
[0145] Step 801: Receive an access request for a network file;
[0146] Step 802: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 803; otherwise, execute step 8041.
[0147] Step 803: Update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; wherein the access time indicates the time record of the last access to the network file, and the access popularity indicates the frequency of the network file being accessed;
[0148] Step 8041: Call the network file download interface to download the network file to a preset temporary file path;
[0149] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path is successful, continue to execute step 8042a;
[0150] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path fails, it further includes: outputting a download failure prompt message and terminating the current process.
[0151] In this embodiment, the network file can be downloaded from the network download address of the network file.
[0152] Step 8042a: Call the file information acquisition interface to acquire the file information of the network file, and determine the storage space required for the network file according to the file size in the acquired file information.
[0153] In this embodiment, the file information acquisition interface can be a general interface function GetFileInfo. When calling GetFileInfo to acquire file information, it may succeed or fail. If successful, step 8042b and subsequent steps can be continued. If failed, fault-tolerant processing can be performed.
[0154] In this embodiment, when the operation of calling the file information acquisition interface to acquire the file information of the network file fails, it further includes: providing the network file downloaded to the preset temporary file path to the online application for use, and no longer executing subsequent steps 8042b to step 8046 to achieve fault-tolerant processing.
[0155] Step 8042b, calculating the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0156] In this embodiment, the upper limit of the local storage space of the online application is pre-set, for example, 10M.
[0157] In this embodiment, assuming that the storage space required by the network file is cursize, and the storage space occupied by the existing network files of the online application (that is, the storage space occupied by the network files stored in the local storage space of the online application) is totalsize, then the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application is cursize+totalsize.
[0158] Step 8043: determine whether the sum of the spaces exceeds the upper limit of the local storage space of the online application. If so, execute step 8044; otherwise, execute step 8045.
[0159] In this embodiment, if the sum of the spaces exceeds the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is small, and it is necessary to delete the existing network files to free up enough storage space to store the newly downloaded network files, so step 8044 is executed. If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is large, and the newly downloaded network files can be directly stored in the local storage space of the online application without deleting the existing network files, so step 8045 is executed.
[0160] Step 8044: Delete the network file with the lowest access popularity of the online application to obtain local storage space, and go to step 8046;
[0161] Step 8045: Do not delete the network file with the lowest access popularity of the online application to obtain the local storage space, but directly obtain the local storage space, and go to step 8046;
[0162] Step 8046: Store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0163] The above steps 8041 to 8046 are Figure 1 The specific refinement of step 104 is shown.
[0164] from Figure 8It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, and according to whether the sum of the space required for the network file and the space occupied by the network files already in the online application exceeds the upper limit of the storage space of the online application, it is determined whether to perform the operation of deleting the network file with the lowest access heat of the online application to obtain the local storage space, and then the downloaded network file is stored in the local storage space of the online application, and the access information of the network file is initialized. By updating the access heat of the locally stored network files and deleting the network files with the lowest access heat stored locally to store the newly downloaded network files, the purpose of accurately identifying and deleting network files that are not frequently used can be achieved, and since the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, and the working efficiency of online applications can be improved. In addition, in this embodiment, when the operation of calling the download network file interface to download the network data to the preset temporary file path fails, and the operation of calling the file information acquisition interface to obtain the file information of the network file fails, fault tolerance processing is performed to avoid errors in the operation of online applications.
[0165] See also Fig. 9 , Fig. 9 is a flow chart of a data caching method for online application in Embodiment 9 of the present invention. Fig. 9 As shown, the method mainly includes the following steps:
[0166] Step 901: Receive an access request for a network file;
[0167] Step 902: determine whether the network file has been stored in the local storage space of the online application. If yes, execute step 903; otherwise, execute step 9041.
[0168] Step 903: Update the access information of the network file according to the current time, wherein the access information includes the access time and the access popularity; wherein the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file;
[0169] Step 9041: Call the network file download interface to download the network file to a preset temporary file path;
[0170] In this embodiment, the temporary file path is pre-set and is used to temporarily store downloaded network files.
[0171] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path is successful, step 9042 is continued;
[0172] In this embodiment, when the operation of calling the network file download interface to download the network data to the preset temporary file path fails, it further includes: outputting a download failure prompt message and terminating the current process.
[0173] In this embodiment, the network file can be downloaded from the network download address of the network file.
[0174] Step 9042: Calculate the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0175] In this embodiment, the upper limit of the local storage space of the online application is pre-set, for example, 10M.
[0176] In this embodiment, assuming that the storage space required by the network file is cursize, and the storage space occupied by the existing network files of the online application (that is, the storage space occupied by the network files stored in the local storage space of the online application) is totalsize, then the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application is cursize+totalsize.
[0177] Step 9043: determine whether the sum of the spaces exceeds the upper limit of the local storage space of the online application. If so, execute step 9044; otherwise, execute step 9045.
[0178] In this embodiment, if the sum of the spaces exceeds the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is small, and it is necessary to delete the existing network files to free up enough storage space to store the newly downloaded network files, so step 9044 is executed. If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, it means that the unoccupied storage space in the local storage space of the online application is large, and the newly downloaded network files can be directly stored in the local storage space of the online application without deleting the existing network files, so step 9045 is executed.
[0179] Step 9044: Delete the network file with the lowest access popularity of the online application to obtain local storage space, and go to step 9046;
[0180] Step 9045: do not delete the network file with the lowest access popularity of the online application to obtain the local storage space, but directly obtain the local storage space, and go to step 9046;
[0181] Step 9046: Call the file copy interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application, and initialize the access information of the network file.
[0182] In this embodiment, "calling the copy file interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application" is a specific refinement of "storing the downloaded network file in the obtained local storage space".
[0183] In this embodiment, after successfully calling the copy file interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application, the method further includes: providing the network file in the local storage path of the online application to the online application for use;
[0184] In this embodiment, when the operation of calling the file copy interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application fails, it further includes: deleting all network files stored in the local storage space of the online application and terminating this process.
[0185] The above steps 9041 to 9046 are Figure 1 The specific refinement of step 104 is shown.
[0186] from Fig. 9It can be seen from the method shown that in this embodiment, when an access request for a network file is received, if the network file has been stored locally, the access information of the network file is updated according to the current time; if the network file is not stored locally, the network file is downloaded, and according to whether the sum of the space required for the network file and the space occupied by the network files already in the online application exceeds the upper limit of the storage space of the online application, it is determined whether to perform the operation of deleting the network file with the lowest access popularity of the online application to obtain the local storage space, and then the downloaded network file is stored in the local storage space of the online application, and the access information of the network file is initialized. By updating the access popularity of the locally stored network files and deleting the locally stored network files with the lowest access popularity to store the newly downloaded network files, the purpose of accurately identifying and deleting the network files that are not frequently used can be achieved, and because the most frequently used network files are stored in the local storage space, the number of downloads of network files can be further reduced, thereby improving the working efficiency of the online application. In addition, in this embodiment, fault-tolerant processing is performed to avoid errors in the operation of online applications when the operation of calling the network file download interface to download the network data to the preset temporary file path fails, and when the operation of calling the file copy interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application fails.
[0187] The above describes in detail the data caching method for online applications in an embodiment of the present invention. The present invention also provides a data caching device for online applications. Figure 8 Provide detailed explanation.
[0188] See also Fig.10 , Fig.10 is a schematic diagram of the structure of a data cache device for online application according to an embodiment of the present invention. Fig.10 As shown, the device comprises:
[0189] The receiving unit 1001 is used to receive an access request for a network file;
[0190] The judging unit 1002 is configured to judge whether the network file has been stored in the local storage space of the online application after the receiving unit 1001 receives the access request for the network file;
[0191] The processing unit 1003 is used to update the access information of the network file according to the current time if the judgment unit 1002 determines that the network file has been stored in the local storage space of the online application, and the access information includes the access time and the access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file; if the judgment unit 1002 determines that the network file is not stored in the local storage space of the online application, download the network file, delete the network file with the lowest access popularity of the online application to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize the access information of the network file.
[0192] Fig.10 In the device shown,
[0193] The processing unit 1003 updates the access information of the network file according to the current time, including:
[0194] Calculating the time interval between the current time and the access time in the access information of the network file;
[0195] Determine the current access heat of the network file according to the time interval and the access heat in the access information of the network file;
[0196] Updating the access time and access temperature in the access information of the network file to the current time and the current access temperature respectively;
[0197] Initialize the access information of the network file, including:
[0198] The access time and access temperature in the access information of the network file are respectively set to the current time and the preset initialization temperature.
[0199] Fig.10 In the device shown,
[0200] The processing unit 1003 determines the current access heat of the network file according to the time interval and the access heat in the access heat information of the network file, including:
[0201] Calculating a ratio of the time interval to a preset time threshold;
[0202] When the ratio is greater than 1, the heat reduction ratio is determined according to the principle that the greater the ratio, the greater the reduction ratio, and the current access heat of the network file is determined according to the heat reduction ratio and the access heat in the access heat information of the network file;
[0203] When the ratio is equal to 1, the access heat in the access heat information of the network file is determined as the current access heat of the network file;
[0204] When the ratio is less than 1, the heat increase ratio is determined according to the principle that the smaller the ratio, the larger the increase ratio is, and the current access heat of the network file is determined according to the heat increase ratio and the access heat in the access heat information of the network file.
[0205] Fig.10 In the device shown,
[0206] The processing unit 1003 determines the current access heat of the network file according to the heat reduction ratio and the access heat in the access heat information of the network file, including:
[0207] The access heat in the access heat information of the network file is adjusted downward according to the heat reduction ratio to obtain a new access heat. If the new access heat is less than the preset minimum heat T min , then the current access heat of the network file is set to T min ; Otherwise, the current access heat of the network file is set as the new access heat;
[0208] The processing unit 1003 determines the current access heat of the network file according to the heat increase ratio and the access heat in the access heat information of the network file, including:
[0209] The access heat in the access heat information of the network file is adjusted upward according to the heat increase ratio to obtain a new access heat. If the new access heat is greater than the preset maximum heat T max , then the current access heat of the network file is set to T max , otherwise, the current access heat of the network file is set as the new access heat.
[0210] Fig.10 In the device shown,
[0211] The access information of the network file also includes: a network download address;
[0212] The determining unit 1002 determines whether the network file has been stored in the local storage space of the online application, including:
[0213] Search the existing network files of the online application for a network file whose network download address is the same as the network download address of the network file. If found, it is determined that the network file has been stored in the local storage space of the online application. Otherwise, it is determined that the network file has not been stored in the local storage space of the online application.
[0214] Fig.10 In the device shown,
[0215] The processing unit 1003, after downloading the network file, and before deleting the network file with the lowest access popularity already available in the online application to obtain the local storage space, further comprises:
[0216] Calculating the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application;
[0217] If the sum of the spaces exceeds the upper limit of the local storage space of the online application, deleting the least popular network file of the online application to obtain the local storage space;
[0218] If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, the operation step of deleting the least popular network file of the online application to obtain the local storage space is not performed.
[0219] Fig.10 In the device shown,
[0220] The processing unit 1003 deletes the network file with the lowest access popularity of the online application to obtain the local storage space, including:
[0221] Calculate the difference between the sum of the spaces and the upper limit of the local storage space of the online application;
[0222] The network file with the lowest access popularity among the existing network files of the online application is deleted to obtain a local storage space whose size is not less than the difference of the spaces.
[0223] Fig.10 In the device shown,
[0224] The processing unit 1003 downloads the network file, including: calling a network file download interface to download the network file to a preset temporary file path;
[0225] When the operation of calling the network file download interface to download the network data to the preset temporary file path fails, the processing unit 1003 further includes: outputting a download failure prompt message and terminating the current process.
[0226] Fig.10 In the device shown,
[0227] The processing unit 1003, before calculating the sum of the storage space required for the network file and the storage space occupied by the existing network files of the online application, further includes: calling a file information acquisition interface to acquire file information of the network file, and determining the storage space required for the network file according to the file size in the acquired file information;
[0228] When the operation of calling the file information acquisition interface to acquire the file information of the network file fails, the processing unit 1003 further includes: providing the network file downloaded to the preset temporary file path to the online application for use.
[0229] Fig.10 In the device shown,
[0230] The processing unit 1003 stores the downloaded network file in the obtained local storage space, including: calling a copy file interface to copy the network file downloaded to a preset temporary file path to a local storage path of the online application;
[0231] The processing unit 1003, after calling the copy file interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application, further includes: providing the network file in the local storage path of the online application to the online application for use;
[0232] When the operation of calling the file copy interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application fails, the processing unit 1003 further includes: deleting all network files stored in the local storage space of the online application and terminating the current process.
[0233] The embodiment of the present invention further provides an electronic device, such as Fig.11 As shown, the electronic device includes: a processor 1101 and a memory 1102;
[0234] The memory 1102 stores one or more computer programs that can be executed by the processor 1101; when the processor 1101 executes the one or more computer programs, the following is achieved: Figure 1-9 The steps in the data caching method for online applications shown in any of the flowcharts.
[0235] The embodiment of the present invention further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores instructions, and when the instructions are executed by a processor, the processor implements the following Figure 1-9 The steps in the data caching method for online applications shown in any of the flowcharts.
[0236] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A data caching method for online applications, characterized in that: The method includes: receiving access requests for network files; Determining whether the network file has been stored in the local storage space of the online application; If the network file has been stored in the local storage space of the online application, the access information of the network file is updated according to the current time, and the access information includes the access time and the access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of the network file being accessed; If the network file is not stored in the local storage space of the online application, download the network file, delete the network file with the lowest access popularity that the online application already has to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize access information of the network file; The updating of the access information of the network file according to the current time includes: Calculating the time interval between the current time and the access time in the access information of the network file; Determine the current access heat of the network file according to the time interval and the access heat in the access information of the network file; Updating the access time and access temperature in the access information of the network file to the current time and the current access temperature respectively; The determining the current access heat of the network file according to the time interval and the access heat in the access information of the network file includes: Calculating a ratio of the time interval to a preset time threshold; When the ratio is greater than 1, the heat reduction ratio is determined according to the principle that the greater the ratio, the greater the reduction ratio, and the current access heat of the network file is determined according to the heat reduction ratio and the access heat in the access heat information of the network file; When the ratio is equal to 1, the access heat in the access heat information of the network file is determined as the current access heat of the network file; When the ratio is less than 1, the heat increase ratio is determined according to the principle that the smaller the ratio, the larger the increase ratio is, and the current access heat of the network file is determined according to the heat increase ratio and the access heat in the access heat information of the network file.
2. The method according to claim 1, characterized in that Initialize the access information of the network file, including: The access time and access temperature in the access information of the network file are respectively set to the current time and the preset initialization temperature.
3. The method according to claim 1, characterized in that The determining the current access heat of the network file according to the heat reduction ratio and the access heat in the access heat information of the network file includes: The access heat in the access heat information of the network file is adjusted downward according to the heat adjustment ratio to obtain a new access heat. If the new access heat is less than a preset minimum heat Tmin, the current access heat of the network file is set to Tmin; otherwise, the current access heat of the network file is set to the new access heat; The determining the current access heat of the network file according to the heat increase ratio and the access heat in the access heat information of the network file includes: The access heat in the access heat information of the network file is increased according to the heat increase ratio to obtain a new access heat; if the new access heat is greater than a preset maximum heat T max, the current access heat of the network file is set to T max; otherwise, the current access heat of the network file is set to the new access heat.
4. The method according to claim 1, characterized in that: The access information of the network file also includes: a network download address; Determining whether the network file has been stored in the local storage space of the online application includes: Search the existing network files of the online application for a network file whose network download address is the same as the network download address of the network file. If found, it is determined that the network file has been stored in the local storage space of the online application. Otherwise, it is determined that the network file has not been stored in the local storage space of the online application.
5. The method according to claim 1, characterized in that After downloading the network file, before deleting the network file with the lowest access popularity already in the online application to obtain the local storage space, further comprising: Calculating the sum of the storage space required by the network file and the storage space occupied by the existing network files of the online application; If the sum of the spaces exceeds the upper limit of the local storage space of the online application, deleting the least popular network file of the online application to obtain the local storage space; If the sum of the spaces does not exceed the upper limit of the local storage space of the online application, the operation step of deleting the least popular network file of the online application to obtain the local storage space is not performed.
6. The method according to claim 5, characterized in that The deleting of the least popular network file of the online application to obtain the local storage space includes: Calculate the difference between the sum of the spaces and the upper limit of the local storage space of the online application; The network file with the lowest access popularity among the existing network files of the online application is deleted to obtain a local storage space whose size is not less than the difference of the spaces.
7. The method according to claim 5, characterized in that The downloading of the network file comprises: calling a network file download interface to download the network file to a preset temporary file path; When the operation of calling the network file download interface to download the network file to the preset temporary file path fails, the process further includes: outputting a download failure prompt message and terminating the process.
8. The method according to claim 7, characterized in that Before calculating the sum of the storage space required for the network file and the storage space occupied by the existing network files of the online application, the method further includes: calling a file information acquisition interface to acquire file information of the network file, and determining the storage space required for the network file according to the file size in the acquired file information; When the operation of calling the file information acquisition interface to acquire the file information of the network file fails, the method further includes: providing the network file downloaded to the preset temporary file path to an online application for use.
9. The method according to claim 7, characterized in that: The storing the downloaded network file into the obtained local storage space includes: calling a copy file interface to copy the network file downloaded to a preset temporary file path to a local storage path of the online application; After calling the copy file interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application, the method further includes: providing the network file in the local storage path of the online application to the online application for use; When the operation of calling the file copy interface to copy the network file downloaded to the preset temporary file path to the local storage path of the online application fails, it further includes: deleting all network files stored in the local storage space of the online application and terminating this process.
10. A data cache device for online applications, characterized in that: The device includes: A receiving unit, used for receiving an access request for a network file; A judging unit, configured to judge whether the network file has been stored in the local storage space of the online application after the receiving unit receives the access request for the network file; a processing unit, configured to update access information of the network file according to the current time if the judging unit determines that the network file has been stored in the local storage space of the online application, the access information including access time and access popularity; the access time indicates the time record of the most recent access to the network file, and the access popularity indicates the frequency of access to the network file; if the judging unit determines that the network file is not stored in the local storage space of the online application, download the network file, delete the network file with the lowest access popularity of the online application to obtain local storage space, store the downloaded network file in the obtained local storage space, and initialize the access information of the network file; The processing unit updates the access information of the network file according to the current time, including: Calculating the time interval between the current time and the access time in the access information of the network file; Determine the current access heat of the network file according to the time interval and the access heat in the access information of the network file; Updating the access time and access temperature in the access information of the network file to the current time and the current access temperature respectively; The processing unit determines the current access heat of the network file according to the time interval and the access heat in the access heat information of the network file, including: Calculating a ratio of the time interval to a preset time threshold; When the ratio is greater than 1, the heat reduction ratio is determined according to the principle that the greater the ratio, the greater the reduction ratio, and the current access heat of the network file is determined according to the heat reduction ratio and the access heat in the access heat information of the network file; When the ratio is equal to 1, the access heat in the access heat information of the network file is determined as the current access heat of the network file; When the ratio is less than 1, the heat increase ratio is determined according to the principle that the smaller the ratio, the larger the increase ratio is, and the current access heat of the network file is determined according to the heat increase ratio and the access heat in the access heat information of the network file.
11. An electronic device, characterized in that: The electronic device includes: a processor and a memory; The memory stores one or more computer programs that can be executed by the processor; when the processor executes the one or more computer programs, the processor implements the steps in the data caching method for online applications as described in any one of claims 1-9.
12. A non-transitory computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor implements the steps in the data caching method for online applications as claimed in any one of claims 1 to 9.
Citation Information
Patent Citations
File storage method and device
CN108460053A
Cache space cleaning method and device
CN110287160A