WO2020140634A1 - 存储空间优化方法、装置、计算机设备及存储介质 - Google Patents

存储空间优化方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2020140634A1
WO2020140634A1 PCT/CN2019/118353 CN2019118353W WO2020140634A1 WO 2020140634 A1 WO2020140634 A1 WO 2020140634A1 CN 2019118353 W CN2019118353 W CN 2019118353W WO 2020140634 A1 WO2020140634 A1 WO 2020140634A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
storage
stored
maxamout
application
Prior art date
Application number
PCT/CN2019/118353
Other languages
English (en)
French (fr)
Inventor
镐振鹏
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020140634A1 publication Critical patent/WO2020140634A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of communication technology, and in particular, to a storage space optimization method, device, computer equipment, and storage medium.
  • the purpose of the present application is to provide a storage space optimization method, device, computer equipment, and storage medium to solve the problem that application programs repeatedly store files in smart terminals and waste local storage space.
  • the present application provides a storage space optimization method for optimizing the local storage space occupied by an application program.
  • the method includes performing the following file storage steps when the application program is in the foreground running state:
  • S11 Generate a file storage table to store storage information of each file stored locally by the application, where the storage information includes a local storage address, storage times, unique identification information, and storage time;
  • step S12 Determine whether a storage instruction from the application program is received. If yes, perform step S13, where the storage instruction includes a file to be stored;
  • step S13 Obtain the unique identification information of the file to be stored, and find whether the unique identification information of the file to be stored exists in the file storage table. If yes, perform step S14; otherwise, perform step S15;
  • the present application also provides a storage space optimization device for optimizing the local storage space occupied by an application program.
  • the device includes a file storage module, and the file storage module includes:
  • the storage table survival unit is used to generate a file storage table to store storage information of each file stored locally by the application, the storage information includes a local storage address, storage times, unique identification information, and storage time;
  • a storage instruction receiving judgment unit used for judging whether a storage instruction from the application program is received, the storage instruction including a file to be stored;
  • a unique identification information acquiring unit configured to acquire unique identification information of the file to be stored
  • a unique identification information searching unit used to find whether the unique identification information of the file to be stored exists in the file storage table
  • a first local storage address search unit used to search whether the local storage address corresponding to the file to be stored exists in the file storage table when the search result of the unique identification information search module is yes;
  • a storage unit configured to add 1 to the number of storage times corresponding to the file to be stored and set the storage time to the current time when the search result of the first local storage address search module is yes;
  • the search result of the first local storage address search module is no, the file to be stored is stored, and the storage frequency corresponding to the file to be stored is set to 1, and the storage time is set to the current time;
  • the search result of the identification information search module is no, the file to be stored is stored, and the corresponding storage information of the file to be stored is added to the file storage table, wherein, the number of storage times corresponding to the file to be stored Set to 1.
  • the storage time is set to the current time.
  • the present application also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the computer program to implement a storage space optimization method , Used to optimize the local storage space occupied by the application, the method includes performing the following file storage steps when the application is in the foreground running state:
  • S11 Generate a file storage table to store storage information of each file stored locally by the application, where the storage information includes a local storage address, storage times, unique identification information, and storage time;
  • step S12 Determine whether a storage instruction from the application program is received. If yes, perform step S13, where the storage instruction includes a file to be stored;
  • step S13 Obtain the unique identification information of the file to be stored, and find whether the unique identification information of the file to be stored exists in the file storage table. If yes, perform step S14; otherwise, perform step S15;
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, a storage space optimization method is implemented to optimize the local storage space occupied by an application program,
  • the method includes performing the following file storage steps when the application is in the foreground running state:
  • S11 Generate a file storage table to store storage information of each file stored locally by the application, where the storage information includes a local storage address, storage times, unique identification information, and storage time;
  • step S12 Determine whether a storage instruction from the application program is received. If yes, perform step S13, where the storage instruction includes a file to be stored;
  • step S13 Obtain the unique identification information of the file to be stored, and find whether the unique identification information of the file to be stored exists in the file storage table. If yes, perform step S14; otherwise, perform step S15;
  • FIG. 1 is a flowchart of the file storage steps of the storage space optimization method of the present application
  • FIG. 2 is a flowchart of a first automatic cleaning step of the storage space optimization method of the present application
  • FIG. 3 is a flowchart of a second automatic cleaning step of the storage space optimization method of this application.
  • FIG. 5 is a flowchart of a file clearing step of the storage space optimization method of this application.
  • FIG. 6 is a structural block diagram of a file storage module in a storage space optimization device of this application.
  • FIG. 7 is a structural block diagram of a first automatic cleaning module in the storage space optimization device of the present application.
  • FIG. 8 is a structural block diagram of a second automatic cleaning module in the storage space optimization device of the present application.
  • FIG. 9 is a structural block diagram of a file deletion module in the storage space optimization device of the present application.
  • FIG. 10 is a structural block diagram of a file clearing module in the storage space optimization device of the present application.
  • FIG. 11 is a hardware architecture diagram of the computer device of the present application.
  • This application provides a storage space optimization method for optimizing the local storage space occupied by application programs (such as WeChat). As shown in FIG. 1, the method includes the following file storage steps:
  • a file storage table is generated to store storage information corresponding to each file stored locally by the application, and the storage information includes a local storage address, a network address, storage times, unique identification information, and storage time;
  • step S13 is executed, where the storage instruction includes a file to be stored.
  • step S13 Obtain the unique identification information of the file to be stored, and find whether the unique identification information of the file to be stored exists in the file storage table. If yes, it indicates that the stored file has been previously stored, then step S14 is executed, otherwise, it indicates that the stored file For the first storage, step S15 is executed.
  • the unique identification information of the file to be stored preferably adopts the MD5 value of the file to be stored.
  • the MD5 value of the file is used as the "digital fingerprint" of the file.
  • the MD5 value of different files is different. If any changes are made to the file , The MD5 value will change accordingly.
  • the storage information of the file to be stored is set as follows: the local storage address is set to the local storage address of the file to be stored, and the network address is set For the network download address of the file to be stored, the storage frequency is set to 1, the storage time is set to the current time, and the unique identification information is set to the MD5 value of the file to be stored.
  • the storage space optimization method further includes performing the following first automatic cleaning step before executing step S13 to determine the size of the file to be stored fileAmout and the total size of all files currently stored locally by the application LocalAmout When the sum is greater than MaxAmout, some files with a longer storage time are automatically cleaned up.
  • the specific process of the first automatic cleaning step is as follows:
  • step S21 Obtain the size of fileAmout to be stored and the total size of all files currently stored locally by the application LocalAmout, and determine whether the sum of the current values of fileAmout and LocalAmout is greater than the current value of MaxAmout. After the file is stored locally, the local storage upper limit will be exceeded, step S22 is executed, otherwise, it means that even if the file to be stored is stored locally, the local storage upper limit will not be exceeded, then step S13 is executed.
  • Delete all files stored by the current application in the local storage and the current time is greater than Tcleaning’s first timeout file, and delete the local storage address and network corresponding to the deleted first timeout file in the file storage table.
  • the address remains unchanged.
  • the network address is reserved because this step is an automatic cleaning step, and is not based on the deletion operation that the user needs to delete. Therefore, the network address is reserved so that the user can download the network address when the user needs to view the deleted first timeout file again in the future.
  • step S23 Obtain again the total size of all files currently stored locally by the application LocalAmout, and determine whether the sum of the current values of fileAmout and LocalAmout is still greater than the current value of MaxAmout. If so, it means that even after deleting the first timeout file, If storing the file to be stored locally will still exceed the local storage limit, execute step S24 to update MaxAmout, otherwise, it means that after deleting the first timeout file, the file to be stored will be stored locally without exceeding the local storage limit , Execute steps S13-S15 to store the file to be stored.
  • the storage space optimization method further includes performing a second automatic cleaning step as shown in FIG. 3 when the application starts or returns to the background or exits:
  • Delete all files stored locally by the current application and the current time is greater than Tcleaning’s second timeout file, and delete the local storage address and network corresponding to the deleted second timeout file in the file storage table.
  • the address remains unchanged.
  • the network address is reserved because this step is an automatic deletion step, rather than a deletion operation according to the user's deletion. Therefore, the network address is reserved so that the user can download it through the network address when the user needs to view the deleted second timeout file again in the future.
  • step S32 Determine whether the current value of MaxAmout is greater than the initial value of MaxAmout at this time, and if so, perform step S33.
  • step S33 Obtain the total size of all files currently stored locally by the application LocalAmout, and determine whether the current value of LocalAmout is less than the initial value of MaxAmout. If yes, perform step S34, otherwise perform step S35.
  • the purpose of performing steps S33-S36 in this embodiment is to automatically update the value of MaxAmout after the file cleaning step is completed. This is because in the process of storing the file, the value of MaxAmout may become larger due to the execution of step S24. After S31 deletes some files, the value of LocalAmout of the total file size will become smaller. At this time, the value of MaxAmout is adaptively adjusted back to its initial value (when LocalAmout is less than or equal to the initial value of MaxAmout) or equal to the value of the current total file size (When LocalAmout is greater than the initial value of MaxAmout), to prevent MaxAmout from becoming too large after multiple executions of step S24, causing the application to occupy too much local storage space.
  • this application only performs the second automatic cleaning step once when the application starts or returns to the background to run or exit information, and does not perform the second automatic cleaning step during the foreground operation of the application, because: During the foreground operation of the application, the second timeout file may need to be used. Unconditional cleanup may cause inconvenience.
  • the storage space optimization method of this application further includes the file deletion step shown in FIG. 4:
  • step S41 Determine whether a deletion instruction from the application program is received, the deletion instruction includes a file to be deleted, and if so, perform step S42.
  • step S42 In the file storage table, reduce the storage frequency corresponding to the file to be deleted by 1 and other storage information unchanged; and then determine whether the storage frequency corresponding to the file to be deleted is 0, and if so, determine the local storage address corresponding to the file to be deleted Whether it is empty, if yes, go to step S43, otherwise go to step S44;
  • the storage space optimization method further includes: when the user needs to clear all files stored locally by the application, the file clearing step shown in FIG. 5 is performed:
  • step S51 Determine whether an empty command for clearing all files stored locally by the application program is received, and if so, execute step S52;
  • the device includes a file storage module 11, as shown in FIG. 6, the file storage module 11 includes:
  • the storage table survival unit 111 is used to generate a file storage table to store storage information of each file stored locally by the application, wherein the storage information includes a local storage address, storage times, unique identification information, and storage time;
  • the initialization unit 112 is used to set the local storage upper limit parameter MaxAmout corresponding to the application program and assign an initial value to MaxAmou, and set the file cleaning time Tcleaning corresponding to the application program and assign an initial value to Tcleaning;
  • the storage instruction receiving judgment unit 113 is used to judge whether a storage instruction from an application program is received, the storage instruction includes a file to be stored;
  • the unique identification information obtaining unit 114 is used to obtain the unique identification information of the file to be stored;
  • the unique identification information searching unit 115 is used to find whether the unique identification information of the file to be stored exists in the file storage table;
  • the first local storage address search unit 116 is used to search whether the local storage address corresponding to the file to be stored exists in the file storage table when the search result of the unique identification information search module is yes;
  • the storage unit 117 is used for adding the storage times corresponding to the file to be stored by 1 to the current time when the search result of the first local storage address search module is yes; and also used to store the address search module in the first local
  • store the file to be stored and set the storage times corresponding to the file to be stored to 1, and set the storage time to the current time
  • Store the file to be stored and add the corresponding storage information of the file to be stored in the file storage table, where the storage frequency corresponding to the file to be stored is set to 1, and the storage time is set to the current time.
  • the storage space optimization device further includes a first automatic cleaning module 12, as shown in FIG. 7, the first automatic cleaning module 12 includes:
  • the first overcapacity judging unit 121 is used to obtain the size of fileAmout to be stored and the total size of all files currently stored locally by the application LocalAmout after receiving the storage instruction, and judge the current value of fileAmout and LocalAmout at this time Whether the sum is greater than the current value of MaxAmout;
  • the first deleting unit 122 is configured to delete the first timeout file whose time difference between the storage time of the current application and the current time is greater than Tcleaning in all files stored locally by the current application when the judgment result of the first overcapacity judgment unit is yes.
  • the file storage table delete the local storage address corresponding to the deleted first timeout file;
  • the second overcapacity judgment unit 123 is used to obtain the total size of all files currently stored locally by the application program LocalAmout after the first deletion unit performs the corresponding operation, and judge whether the sum of the current values of fileAmout and LocalAmout is still Greater than the current value of MaxAmout;
  • the storage space optimization device further includes a second automatic cleaning module 13, as shown in FIG. 8, the second automatic cleaning module 13 includes:
  • the second deleting unit 131 is used to delete files whose time difference between the storage time of the application in all files stored locally and the current time is greater than Tcleaning when the application starts or exits into the background or exits, and is also in the file storage table, Delete the local storage address corresponding to the deleted file;
  • the storage upper limit parameter judgment unit 132 is used to judge whether the current value of MaxAmout is greater than the initial value of MaxAmout;
  • the comparison unit 133 is used to obtain the total size of LocalAmout of all files currently stored locally by the application, and compare the current value of LocalAmout with the initial value of MaxAmout;
  • the second storage upper limit parameter updating unit 134 is configured to set the value of MaxAmout as the initial value of MaxAmout when the comparison unit determines that the current value of LocalAmout is less than the initial value of MaxAmout;
  • the third storage upper limit parameter updating unit 135 is configured to set the value of MaxAmout as the current value of LocalAmout when the comparison unit determines that the current value of LocalAmout is greater than or equal to the initial value of MaxAmout.
  • the storage space optimization device further includes a file deletion module 14, as shown in FIG. 9, the file deletion module 14 includes:
  • the delete instruction receiving judgment unit 141 is used to judge whether a delete instruction from the application program is received, and the delete instruction includes the file to be deleted;
  • the storage frequency decreasing unit 142 is used to reduce the storage frequency corresponding to the file to be deleted by 1 in the file storage table when the judgment result of the deletion instruction receiving judgment unit is YES;
  • the storage frequency judging unit 143 is used to judge whether the storage frequency decrementing unit reduces the storage frequency corresponding to the file to be deleted after the storage frequency corresponding to the file to be deleted is 0;
  • the second local storage address search unit 144 is used to search whether the local storage address corresponding to the file to be deleted is empty in the file storage table when the judgment result of the storage number judgment unit is yes;
  • the third deletion unit 145 is configured to delete the storage information corresponding to the file to be deleted in the file storage table when the search result of the second local storage address search unit is yes;
  • the fourth deletion unit 146 is configured to delete the file to be deleted locally and delete the storage information of the file to be deleted in the file storage table when the search result of the second local storage address search unit is no.
  • the storage space optimization device further includes a file clearing module 15, as shown in FIG. 10, the file clearing module 15 includes:
  • the clearing instruction receiving judgment unit 151 is used to judge whether a clearing instruction for clearing all files stored locally by the application program is received;
  • the clearing unit 152 is configured to delete all files stored locally by the application program and delete storage information corresponding to all files in the file storage table when the judgment result of the clearing instruction receiving judgment unit is yes.
  • This application also provides a computer device, such as a smartphone, tablet computer, notebook computer, desktop computer, rack server, blade server, tower server or rack server (including a stand-alone server, or multiple Server cluster composed of servers).
  • the computer device 20 of this embodiment includes at least but not limited to: a memory 21 and a processor 22 that can be communicatively connected to each other through a system bus, as shown in FIG. 11. It should be noted that FIG. 11 only shows the computer device 20 having the components 21-22, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
  • the memory 21 (ie, readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), Read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk, etc.
  • the memory 21 may be an internal storage unit of the computer device 20, such as a hard disk or memory of the computer device 20.
  • the memory 21 may also be an external storage device of the computer device 20, for example, a plug-in hard disk equipped on the computer device 20, a smart memory card (Smart Media, Card, SMC), and secure digital (Secure Digital, SD) card, flash card (Flash Card), etc.
  • the memory 21 may also include both the internal storage unit of the computer device 20 and its external storage device.
  • the memory 21 is generally used to store an operating system and various application software installed on the computer device 20, for example, program codes of the storage space optimization device 10 of the second embodiment.
  • the memory 21 can also be used to temporarily store various types of data that have been output or are to be output.
  • the processor 22 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments.
  • the processor 22 is generally used to control the overall operation of the computer device 20.
  • the processor 22 is used to run the program code or process data stored in the memory 21, for example, to run the storage space optimization device 10, so as to implement the storage space optimization method of Embodiment 1.
  • This application also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Programmable Read-Only Memory (PROM), Magnetic Memory, Magnetic Disk, CD-ROM, Server, App Store, etc., on which computer programs, programs are stored The corresponding function is realized when executed by the processor.
  • the computer-readable storage medium of this embodiment is used to store the storage space optimization apparatus 10, and when executed by a processor, implements the storage space optimization method of Embodiment 1.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

一种存储空间优化方法、装置、计算机设备及存储介质,该方法包括:S11、生成文件存储表;S12、判断是否接收到存储指令,若是,执行步骤S13;S13、获取待存储文件的唯一标识信息,并查找文件存储表中是否存在待存储文件的唯一标识信息,若是,执行步骤S14,否则执行步骤S15;S14、查找文件存储表中是否存在待存储文件对应的本地存储地址,若是,在文件存储表中,将待存储文件对应的存储次数加1,否则,存储待存储文件,并在文件存储表中,将待存储文件对应的存储次数设为1;S15、存储待存储文件,并在文件存储表中增加待存储文件的相应存储信息,其中,待存储文件对应的存储次数设为1。所述方法能够解决应用程序重复存储文件于本地的问题。

Description

存储空间优化方法、装置、计算机设备及存储介质
本申请申明享有2019年01月04日递交的申请号为CN2019100082362、名称为“存储空间优化方法、装置、计算机设备及存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。
技术领域
本申请涉及通信技术领域,尤其涉及一种存储空间优化方法、装置、计算机设备及存储介质。
背景技术
随着智能终端的发展,用户可以通过在终端上安装各种APP,存储各种文件比如图片、视频文件、下载文件等,而且往往会出现重复存储文件的情况。例如,在使用微信时,可能会收到不同微信好友发送的相同文件,这些文件重复下载并存储于本地。由于每个文件都会占用一定的存储空间,日积月累,终端有限资源会被逐渐用尽,导致终端本地存储资源不足。存储资源不足将导致操作系统反应慢,很多程序无法正常使用,比如导致应用软件无法在后台接收消息,或者使得用户无法增加或更新智能终端中的应用软件,无法存储更多的图像等,致使用户的期望操作无法正常进行,影响用户的终端使用体验。
发明内容
针对述上述现有技术的不足,本申请的目的在于提供一种存储空间优化方法、装置、计算机设备及存储介质,以解决应用程序重复存储文件于智能终端,浪费本地存储空间的问题。
为了实现上述目的,本申请提供一种存储空间优化方法,用于优化应用程序占用的本地存储空间,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
为了实现上述目的,本申请还提供一种存储空间优化装置,用于优化应用程序占用的本地存储空间,该装置包括文件存储模块,所述文件存储模块包括:
存储表生存单元,用于生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
存储指令接收判断单元,用于判断是否接收到来自所述应用程序的存储指令,所述存储指令包含待存储文件;
唯一标识信息获取单元,用于获取所述待存储文件的唯一标识信息;
唯一标识信息查找单元,用于查找所述文件存储表中是否存在所述待存储文件的唯一标识信息;
第一本地存储地址查找单元,用于在所述唯一标识信息查找模块的查找结果为是时,查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址;
存储单元,用于在所述第一本地存储地址查找模块的查找结果为是时,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间;还用于在所述第一本地存储地址查找模块的查找结果为否时,存储所述待存储文件,并将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;还用于在所述唯一标识信息查找模块的查找结果为否时,存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
为了实现上述目的,本申请还提供一种计算机设备,包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现存储空间优化方法,用于优化应用程序占用的本地存储空间,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息, 所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
为了实现上述目的,本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现存储空间优化方法,用于优化应用程序占用的本地存储空间,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
附图说明
图1为本申请存储空间优化方法的文件存储步骤的流程图;
图2为本申请存储空间优化方法的第一自动清理步骤的流程图;
图3为本申请存储空间优化方法的第二自动清理步骤的流程图;
图4为本申请存储空间优化方法的文件删除步骤的流程图;
图5为本申请存储空间优化方法的文件清空步骤的流程图;
图6为本申请存储空间优化装置中的文件存储模块的结构框图;
图7为本申请存储空间优化装置中的第一自动清理模块的结构框图;
图8为本申请存储空间优化装置中的第二自动清理模块的结构框图;
图9为本申请存储空间优化装置中的文件删除模块的结构框图;
图10为本申请存储空间优化装置中的文件清空模块的结构框图;
图11为本申请计算机设备的硬件架构图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
实施例一
本申请提供一种存储空间优化方法,用于优化应用程序(如微信)占用的本地存储空间,如图1所示,该方法包括以下文件存储步骤:
S11、在应用程序首次启动时,生成文件存储表以存储该应用程序在本地存储的各文件对应的存储信息,该存储信息包括本地存储地址、网络地址、存储次数、唯一标识信息和存储时间;同时设定应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初始值(如500M),以及设定应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值(如7天)。
S12、在应用程序处于前台运行的过程中,当安装应用程序的智能终端接收到来自应用程序的存储指令时,则执行步骤S13,其中,该存储指令包含待存储文件。
S13、获取待存储文件的唯一标识信息,并查找文件存储表中是否存在待存储文件的唯一标识信息,若是,表示该存储文件之前已被存储过,则执行步骤S14,否则,表示该存储文件为首次存储,则执行步骤S15。在本实施例中,待存储文件的唯一标识信息优选采用待存储文件的MD5值,文件的MD5值作为文件的“数 字指纹”,不同文件的MD5值是不同的,如果对文件做了任何改动,其MD5值也会相应发生变化。
S14、查找文件存储表中是否存在待存储文件对应的本地存储地址,若是,说明该待存储文件当前存储于本地,则不再重复存储该待存储文件,只要在文件存储表中,将待存储文件对应的存储次数加1、存储时间设为当前时间即可,否则,说明该待存储文件虽然被存储过,但已在自动清理步骤中被清理掉,因此需要再次将待存储文件存储于本地,并在文件存储表中,将待存储文件对应的存储次数设为1,且将存储时间设为当前时间。
S15、存储待存储文件,并在文件存储表中增加待存储文件的对应存储信息,其中,待存储文件的存储信息设置如下:本地存储地址设为待存储文件在本地的存储地址、网络地址设为待存储文件的网络下载地址、存储次数设为1、存储时间设为当前时间、唯一标识信息设为待存储文件的MD5值。
综上,本申请在存储待存储文件时,若查找到文件存储表中存在待存储文件对应的唯一标识信息和本地存储地址,说明该文件已被存储过,则不再进行存储而只在文件存储表中将该文件对应的存储次数加1,从而防止应用程序重复存储文件,导致占用的存储空间浪费。例如,在微信聊天过程中,假设有两个聊天框引用了文件A,根据本申请则仅在本地存储文件A一次,但文件A对应的存储次数设为2。
在本实施例中,存储空间优化方法还包括在执行步骤S13之前,执行以下第一自动清理步骤,以在待存储文件的大小fileAmout与应用程序当前在本地已存储的所有文件的总大小LocalAmout之和大于MaxAmout时,自动清理掉部分存储时间较长的文件,其中,如图2所示,第一自动清理步骤的具体过程如下:
S21、获取待存储文件的大小fileAmout以及应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值,若是,说明若将待存储文件存储于本地后将超过本地存储上限,则执行步骤S22,否则,说明即使将待存储文件存储于本地也不会超过本地存储上限,则执行步骤S13。
S22、删除当前应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在文件存储表中,将删除的第一超时文件对应的本地存储地址删除、网络地址保存不变。保留网络地址是因为本步骤为自动清理步骤,而并非根据用户删除需要进行的删除操作,因此保留网络地址以便以后用户需再次查看删除的第一超时文件时可以通过网络地址下载。
S23、再次获取应用程序当前在本地存储的所有文件的总大小LocalAmout, 并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值,若是,说明即使将第一超时文件删除后再将待存储文件存储于本地仍会超过本地存储上限,则执行步骤S24以对MaxAmout进行更新,否则,说明将第一超时文件删除后再将待存储文件存储于本地而并不会超过本地存储上限,则执行步骤S13-S15以对待存储文件进行存储。
S24、根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,而后执行步骤S13,其中,D为预设的预留空间大小,如5M。
在本实施例中,存储空间优化方法还包括在应用程序启动或回到后台运行或退出时,执行一次如图3所示的第二自动清理步骤:
S31、删除当前应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第二超时文件,同时在文件存储表中,将删除的第二超时文件对应的本地存储地址删除、网络地址保存不变。其中,保留网络地址是因为本步骤为自动删除步骤,而并非根据用户删除需要进行的删除操作,因此保留网络地址以便以后用户需再次查看删除的第二超时文件时可以通过网络地址下载。
S32、判断此时MaxAmout的当前值是否大于MaxAmout的初始值,若是,则执行步骤S33。
S33、获取应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断LocalAmout的当前值是否小于MaxAmout的初始值,若是,则执行步骤S34,否则执行步骤S35。
S34、将MaxAmout的值设为MaxAmout的初始值。
S35、将MaxAmout的值设为LocalAmout的当前值。
本实施例执行步骤S33-S36的目的是为了在文件清理步骤完成后自动更新MaxAmout的值,这是因为在:存储文件的过程中,可能因执行了步骤S24导致MaxAmout的值变大,当步骤S31删除一些文件后,文件总大小LocalAmout的值将变小,此时适应性地将MaxAmout的值调整回其初始值(当LocalAmout小于或等于MaxAmout的初始值)或者与当前文件总大小的值相等(当LocalAmout大于MaxAmout的初始值),以防止经过多次执行步骤S24后使MaxAmout变得过大,导致应用程序占用本地存储空间过大。其中,本申请仅在应用程序启动或回到后台运行或退出的信息时执行一次第二自动清理步骤,而并不会在应用程序的前台运行过程中执行第二自动清理步骤,这是因为:在应用程序的前台运行过程中,第二超时文件可能需要被用到,若无条件清理则可能带来不便。
在本实施例中,当应用程序处于前台运行过程中时,可能需要删除本地存储的指定文件,因此本申请存储空间优化方法还包括如图4所示的文件删除步骤:
S41、判断是否接收到来自应用程序的删除指令,该删除指令包含待删除文件,若是,执行步骤S42。
S42、在文件存储表中,将待删除文件对应的存储次数减1,其它存储信息不变;而后判断待删除文件对应的存储次数是否为0,若是,则判断待删除文件对应的本地存储地址是否为空,若是,执行步骤S43,否则执行步骤S44;
S43、当待删除文件对应的本地存储地址为空时,说明在前述自动清理过程中已经删除了待删除文件,无需再次对其进行删除,则在文件存储表中,删除待删文件对应的存储信息即可;
S44、当待删除文件对应的本地存储地址不为空时,说明待删除文件仍存储于要本地,则在本地删除该待删除文件,同时在文件存储表中删除待删文件的存储信息。
在本实施例中,存储空间优化方法还包括:当用户需要清空应用程序在本地存储的所有文件时,执行如图5所示的文件清空步骤:
S51、判断是否接收到清空应用程序在本地存储的所有文件的清空指令,若是,执行步骤S52;
S52、删除应用程序在本地存储的所有文件,并删除文件存储表中所有文件对应的存储信息。
实施例二
本实例提供一种存储空间优化装置,用于优化应用程序占用的本地存储空间。其中,该装置包括文件存储模块11,如图6所示,文件存储模块11包括:
存储表生存单元111,用于生成文件存储表以存储应用程序在本地存储的各文件的存储信息,其中,存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
初始化单元112,用于设定应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初始值,以及设定应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值;
存储指令接收判断单元113,用于判断是否接收到来自应用程序的存储指令,该存储指令包含待存储文件;
唯一标识信息获取单元114,用于获取待存储文件的唯一标识信息;
唯一标识信息查找单元115,用于查找文件存储表中是否存在待存储文件的唯一标识信息;
第一本地存储地址查找单元116,用于在唯一标识信息查找模块的查找结果 为是时,查找文件存储表中是否存在待存储文件对应的本地存储地址;
存储单元117,用于在第一本地存储地址查找模块的查找结果为是时,将待存储文件对应的存储次数加1、存储时间设为当前时间;还用于在第一本地存储地址查找模块的查找结果为否时,存储待存储文件,并将待存储文件对应的存储次数设为1,且将存储时间设为当前时间;还用于在唯一标识信息查找模块的查找结果为否时,存储待存储文件,并在文件存储表中增加待存储文件的相应存储信息,其中,待存储文件对应的存储次数设为1、存储时间设为当前时间。
在本实施例中,存储空间优化装置还包括第一自动清理模块12,如图7所示,第一自动清理模块12包括:
第一超容量判断单元121,用于在接收到存储指令后,获取待存储文件的大小fileAmout以及应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值;
第一删除单元122,用于在第一超容量判断单元的判断结果为是时,删除当前应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在文件存储表中,将删除的第一超时文件对应的本地存储地址删除;
第二超容量判断单元123,用于在第一删除单元执行相应操作后,再次获取应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值;
第一存储上限参数更新单元124,用于在第二超容量判断单元的判断结果为是时,根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,其中,D为预设的预留空间大小。
在本实施例中,存储空间优化装置还包括第二自动清理模块13,如图8所示,第二自动清理模块13包括:
第二删除单元131,用于在应用程序启动或退入后台运行或退出时,删除应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的文件,同时在文件存储表中,将删除的文件对应的本地存储地址删除;
存储上限参数判断单元132,用于判断MaxAmout的当前值是否大于MaxAmout的初始值;
比较单元133,用于获取应用程序当前在本地存储的所有文件的总大小LocalAmout,并比较LocalAmout的当前值与MaxAmout的初始值的大小;
第二存储上限参数更新单元134,用于在比较单元判定LocalAmout的当前值小于MaxAmout的初始值时,将MaxAmout的值设为MaxAmout的初始值;
第三存储上限参数更新单元135,用于在比较单元判定LocalAmout的当前值大于或等于MaxAmout的初始值时,将MaxAmout的值设为LocalAmout的当前值。
在本实施例中,存储空间优化装置还包括文件删除模块14,如图9所示,文件删除模块14包括:
删除指令接收判断单元141,用于判断是否接收到来自应用程序的删除指令,删除指令包含待删除文件;
存储次数递减单元142,用于在删除指令接收判断单元的判断结果为是时,在文件存储表中,将待删除文件对应的存储次数减1;
存储次数判断单元143,用于判断存储次数递减单元在将待删除文件对应的存储次数减1后,待删除文件对应的存储次数是否为0;
第二本地存储地址查找单元144,用于在存储次数判断单元的判断结果为是时,在文件存储表中,查找待删除文件对应的本地存储地址是否为空;
第三删除单元145,用于在第二本地存储地址查找单元的查找结果为是时,在文件存储表中,删除待删除文件对应的存储信息;
第四删除单元146,用于在第二本地存储地址查找单元的查找结果为否时,在本地删除待删除文件,同时在文件存储表中删除待删除文件的存储信息。
在本实施例中,存储空间优化装置还包括文件清空模块15,如图10所示,文件清空模块15包括:
清空指令接收判断单元151,用于判断是否接收到清空应用程序在本地存储的所有文件的清空指令;
清空单元152,用于在清空指令接收判断单元的判断结果为是时,删除应用程序在本地存储的所有文件,并删除文件存储表中所有文件对应的存储信息。
实施例三
本申请还提供一种计算机设备,如可以执行程序的智能手机、平板电脑、笔记本电脑、台式计算机、机架式服务器、刀片式服务器、塔式服务器或机柜式服务器(包括独立的服务器,或者多个服务器所组成的服务器集群)等。本实施例的计算机设备20至少包括但不限于:可通过系统总线相互通信连接的存储器21、处理器22,如图11所示。需要指出的是,图11仅示出了具有组件21-22的计算机设备20,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
本实施例中,存储器21(即可读存储介质)包括闪存、硬盘、多媒体卡、卡 型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,存储器21可以是计算机设备20的内部存储单元,例如该计算机设备20的硬盘或内存。在另一些实施例中,存储器21也可以是计算机设备20的外部存储设备,例如该计算机设备20上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,存储器21还可以既包括计算机设备20的内部存储单元也包括其外部存储设备。本实施例中,存储器21通常用于存储安装于计算机设备20的操作系统和各类应用软件,例如实施例二的存储空间优化装置10的程序代码等。此外,存储器21还可以用于暂时地存储已经输出或者将要输出的各类数据。
处理器22在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器22通常用于控制计算机设备20的总体操作。本实施例中,处理器22用于运行存储器21中存储的程序代码或者处理数据,例如运行存储空间优化装置10,以实现实施例一的存储空间优化方法。
实施例四
本申请还提供一种计算机可读存储介质,如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘、服务器、App应用商城等等,其上存储有计算机程序,程序被处理器执行时实现相应功能。本实施例的计算机可读存储介质用于存储存储空间优化装置10,被处理器执行时实现实施例一的存储空间优化方法。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种存储空间优化方法,用于优化应用程序占用的本地存储空间,其特征在于,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
    S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
    S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
    S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
    S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
    S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
  2. 根据权利要求1所述的存储空间优化方法,其特征在于,所述步骤S11还包括:设定所述应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初始值,以及设定所述应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值。
  3. 根据权利要求2所述的存储空间优化方法,其特征在于,所述存储空间优化方法还包括在执行所述步骤S13之前,执行以下第一自动清理步骤:
    S21、获取所述待存储文件的大小fileAmout以及所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值,若是,执行步骤S22,否则,执行步骤S13;
    S22、删除当前所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在所述文件存储表中,将删除的第一超时文件对应的本地存储地址删除;
    S23、再次获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值,若是执行步骤S24,否则执行步骤S13;
    S24、根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,而后执行步骤S13,其中,D为预设的预留空间大小。
  4. 根据权利要求3所述的存储空间优化方法,其特征在于,所述存储空间优化方法还包括在所述应用程序启动或退入后台运行或退出时,执行以下第二自动清理步骤:
    S31、删除当前所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第二超时文件,同时在所述文件存储表中,将删除的第二超时文件对应的本地存储地址删除。
  5. 根据权利要求2所述的存储空间优化方法,其特征在于,所述第二自动清理步骤还包括:在执行所述步骤S31之后,继续执行以下步骤:
    S32、判断MaxAmout的当前值是否大于MaxAmout的初始值,若是,则执行步骤S33;
    S33、获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断LocalAmout的当前值是否小于MaxAmout的初始值,若是,则执行步骤
    S34,否则执行步骤35;
    S34、将MaxAmout的值设为MaxAmout的初始值;
    S35、将MaxAmout的值设为LocalAmout的当前值。
  6. 根据权利要求1所述的存储空间优化方法,其特征在于,所述存储空间优化方法还包括在所述应用程序处于前台运行状态时,执行以下文件删除步骤:
    S41、判断是否接收到来自所述应用程序的删除指令,若是,则执行步骤S42,其中所述删除指令包含待删除文件;
    S42、在所述文件存储表中,将所述待删除文件对应的存储次数减1,而后判断所述待删除文件对应的存储次数是否为0,若是,则判断所述待删除文件对应的本地存储地址是否为空,若是,执行步骤S43,否则执行步骤44;
    S43、在所述文件存储表中,删除所述待删文件对应的所述存储信息;
    S44、在本地删除所述待删除文件,同时在所述文件存储表中删除所述待删文件的所述存储信息。
  7. 根据权利要求1所述的存储空间优化方法,其特征在于,所述存储空间优化方法还包括在所述应用程序处于前台运行状态时,执行以下文件清空步骤:
    S51、判断是否接收到清空所述应用程序在本地存储的所有文件的清空指令,若是,执行步骤S52;
    S52、删除所述应用程序在本地存储的所有文件,并删除所述文件存储表中所有文件对应的存储信息。
  8. 一种存储空间优化装置,用于优化应用程序占用的本地存储空间,其特征在于,该装置包括文件存储模块,所述文件存储模块包括:
    存储表生存单元,用于生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
    存储指令接收判断单元,用于判断是否接收到来自所述应用程序的存储指令,所述存储指令包含待存储文件;
    唯一标识信息获取单元,用于获取所述待存储文件的唯一标识信息;
    唯一标识信息查找单元,用于查找所述文件存储表中是否存在所述待存储文件的唯一标识信息;
    第一本地存储地址查找单元,用于在所述唯一标识信息查找模块的查找结果为是时,查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址;
    存储单元,用于在所述第一本地存储地址查找模块的查找结果为是时,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间;还用于在所述第一本地存储地址查找模块的查找结果为否时,存储所述待存储文件,并将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;还用于在所述唯一标识信息查找模块的查找结果为否时,存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
  9. 根据权利要求8所述的存储空间优化装置,其特征在于,所述文件存储模块还包括:初始化单元,用于设定所述应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初始值,以及设定所述应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值。
  10. 根据权利要求9所述的存储空间优化装置,其特征在于,所述存储空间优化装置还包括第一自动清理模块,所述第一自动清理模块包括:
    第一超容量判断单元,用于在接收到所述存储指令后,获取所述待存储文件的大小fileAmout以及所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值;
    第一删除单元,用于在所述第一超容量判断单元的判断结果为是时,删除当前所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在所述文件存储表中,将删除的第一超时文件对 应的本地存储地址删除;
    第二超容量判断单元,用于在所述第一删除单元执行相应操作后,再次获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值;
    第一存储上限参数更新单元,用于在所述第二超容量判断单元的判断结果为是时,根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,其中,D为预设的预留空间大小。
  11. 根据权利要求10所述的存储空间优化装置,其特征在于,所述存储空间优化装置还包括第二自动清理模块,所述第二自动清理模块包括:
    第二删除单元,用于在所述应用程序启动或退入后台运行或退出时,删除所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的文件,同时在所述文件存储表中,将删除的文件对应的本地存储地址删除。
  12. 根据权利要求9所述的存储空间优化装置,其特征在于,所述第二自动清理模块还包括:
    存储上限参数判断单元,用于判断MaxAmout的当前值是否大于MaxAmout的初始值;
    比较单元,用于获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并比较LocalAmout的当前值与MaxAmout的初始值的大小;
    第二存储上限参数更新单元,用于在所述比较单元判定LocalAmout的当前值小于MaxAmout的初始值时,将MaxAmout的值设为MaxAmout的初始值;
    第三存储上限参数更新单元,用于在所述比较单元判定LocalAmout的当前值大于或等于MaxAmout的初始值时,将MaxAmout的值设为LocalAmout的当前值。
  13. 根据权利要求8所述的存储空间优化装置,其特征在于,所述存储空间优化装置还包括文件删除模块,所述文件删除模块包括:
    删除指令接收判断单元,用于判断是否接收到来自所述应用程序的删除指令,所述删除指令包含待删除文件;
    存储次数递减单元,用于在所述删除指令接收判断单元的判断结果为是时,在所述文件存储表中,将所述待删除文件对应的存储次数减1;
    存储次数判断单元,用于判断所述存储次数递减单元在将所述待删除文件对应的存储次数减1后,所述待删除文件对应的存储次数是否为0;
    第二本地存储地址查找单元,用于在所述存储次数判断单元的判断结果为是 时,在所述文件存储表中,查找所述待删除文件对应的本地存储地址是否为空;
    第三删除单元,用于在所述第二本地存储地址查找单元的查找结果为是时,在所述文件存储表中,删除所述待删除文件对应的所述存储信息;
    第四删除单元,用于在所述第二本地存储地址查找单元的查找结果为否时,在本地删除所述待删除文件,同时在所述文件存储表中删除所述待删除文件的所述存储信息。
  14. 根据权利要求8所述的存储空间优化装置,其特征在于,所述存储空间优化装置还包括文件清空模块,所述文件清空模块包括:
    清空指令接收判断单元,用于判断是否接收到清空所述应用程序在本地存储的所有文件的清空指令;
    清空单元,用于在所述清空指令接收判断单元的判断结果为是时,删除所述应用程序在本地存储的所有文件,并删除所述文件存储表中所有文件对应的存储信息。
  15. 一种计算机设备,包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现存储空间优化方法,用于优化应用程序占用的本地存储空间,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
    S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
    S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
    S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
    S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
    S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设为当前时间。
  16. 根据权利要求15所述的计算机设备,其特征在于,所述步骤S11还包括:设定所述应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初 始值,以及设定所述应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值。
  17. 根据权利要求16所述的计算机设备,其特征在于,所述存储空间优化方法还包括在执行所述步骤S13之前,执行以下第一自动清理步骤:
    S21、获取所述待存储文件的大小fileAmout以及所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值,若是,执行步骤S22,否则,执行步骤S13;
    S22、删除当前所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在所述文件存储表中,将删除的第一超时文件对应的本地存储地址删除;
    S23、再次获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值,若是执行步骤S24,否则执行步骤S13;
    S24、根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,而后执行步骤S13,其中,D为预设的预留空间大小。
  18. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现存储空间优化方法,用于优化应用程序占用的本地存储空间,该方法包括在所述应用程序处于前台运行状态时,执行以下文件存储步骤:
    S11、生成文件存储表以存储所述应用程序在本地存储的各文件的存储信息,所述存储信息包括本地存储地址、存储次数、唯一标识信息和存储时间;
    S12、判断是否接收到来自所述应用程序的存储指令,若是,则执行步骤S13,其中所述存储指令包含待存储文件;
    S13、获取所述待存储文件的唯一标识信息,并查找所述文件存储表中是否存在所述待存储文件的唯一标识信息,若是,则执行步骤S14,否则执行步骤S15;
    S14、查找所述文件存储表中是否存在所述待存储文件对应的本地存储地址,若是,则在所述文件存储表中,将所述待存储文件对应的存储次数加1,且将存储时间设为当前时间,否则,存储所述待存储文件,并在所述文件存储表中,将所述待存储文件对应的存储次数设为1、存储时间设为当前时间;
    S15、存储所述待存储文件,并在所述文件存储表中增加所述待存储文件的相应所述存储信息,其中,所述待存储文件对应的存储次数设为1、存储时间设 为当前时间。
  19. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述步骤S11还包括:设定所述应用程序对应的本地存储上限参数MaxAmout并对MaxAmou赋初始值,以及设定所述应用程序对应的文件定时清理时间Tcleaning并对Tcleaning赋初始值。
  20. 根据权利要求19所述的计算机可读存储介质,其特征在于,所述存储空间优化方法还包括在执行所述步骤S13之前,执行以下第一自动清理步骤:
    S21、获取所述待存储文件的大小fileAmout以及所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否大于MaxAmout的当前值,若是,执行步骤S22,否则,执行步骤S13;
    S22、删除当前所述应用程序在本地存储的所有文件中存储时间与当前时间的时间差大于Tcleaning的第一超时文件,同时在所述文件存储表中,将删除的第一超时文件对应的本地存储地址删除;
    S23、再次获取所述应用程序当前在本地存储的所有文件的总大小LocalAmout,并判断此时fileAmout与LocalAmout的当前值之和是否仍大于MaxAmout的当前值,若是执行步骤S24,否则执行步骤S13;
    S24、根据公式MaxAmout=LocalAmout的当前值+fileAmout+D更新MaxAmout的值,而后执行步骤S13,其中,D为预设的预留空间大小。
PCT/CN2019/118353 2019-01-04 2019-11-14 存储空间优化方法、装置、计算机设备及存储介质 WO2020140634A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910008236.2A CN109857548B (zh) 2019-01-04 2019-01-04 存储空间优化方法、装置、计算机设备及存储介质
CN201910008236.2 2019-01-04

Publications (1)

Publication Number Publication Date
WO2020140634A1 true WO2020140634A1 (zh) 2020-07-09

Family

ID=66893965

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118353 WO2020140634A1 (zh) 2019-01-04 2019-11-14 存储空间优化方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN109857548B (zh)
WO (1) WO2020140634A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113051223A (zh) * 2021-03-30 2021-06-29 联想(北京)有限公司 一种数据处理方法及装置
CN113312561A (zh) * 2020-11-24 2021-08-27 芜湖达成储运有限公司 物料存储方法及系统

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857548B (zh) * 2019-01-04 2023-08-22 平安科技(深圳)有限公司 存储空间优化方法、装置、计算机设备及存储介质
CN111026728A (zh) * 2019-11-19 2020-04-17 山东中创软件商用中间件股份有限公司 一种日志数据处理方法及相关装置
CN111083222B (zh) * 2019-12-13 2022-11-18 中富通集团股份有限公司 数据上传方法及终端
CN112395463B (zh) * 2020-11-16 2024-02-23 深信服科技股份有限公司 数据的存储方法、装置、设备以及计算机可读存储介质
CN112511612A (zh) * 2020-11-19 2021-03-16 中国联合网络通信集团有限公司 云存储数据存储方法、装置、系统、设备及存储介质
CN112463079B (zh) * 2020-12-17 2023-12-22 北京浪潮数据技术有限公司 一种数据存储控制方法、装置、设备及可读存储介质
CN115185615B (zh) * 2022-09-09 2022-12-02 湖南三湘银行股份有限公司 基于内存空间优化的插件程序调用方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101908073A (zh) * 2010-08-13 2010-12-08 清华大学 一种文件系统中实时删除重复数据的方法
US20110302387A1 (en) * 2007-12-25 2011-12-08 Takashi Yasui Method for managing storage, program and system for the same
CN102629247A (zh) * 2011-12-31 2012-08-08 成都市华为赛门铁克科技有限公司 一种数据处理方法、装置和系统
CN108063818A (zh) * 2017-12-18 2018-05-22 深圳市中科明望通信软件有限公司 数据下载方法、装置、终端和计算机可读存储介质
CN109857548A (zh) * 2019-01-04 2019-06-07 平安科技(深圳)有限公司 存储空间优化方法、装置、计算机设备及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103559139B (zh) * 2013-10-23 2016-08-17 华为技术有限公司 一种数据存储方法及装置
CN105787012B (zh) * 2016-02-23 2019-08-27 深圳市瑞驰信息技术有限公司 一种提高存储系统处理小文件的方法以及存储系统
CN106101271A (zh) * 2016-08-08 2016-11-09 北京小米移动软件有限公司 优化存储空间的方法及装置
CN107577423A (zh) * 2017-08-15 2018-01-12 上海斐讯数据通信技术有限公司 一种优化存储空间的方法及系统
CN107678978A (zh) * 2017-10-12 2018-02-09 深圳辉烨通讯技术有限公司 一种智能终端的存储空间处理方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110302387A1 (en) * 2007-12-25 2011-12-08 Takashi Yasui Method for managing storage, program and system for the same
CN101908073A (zh) * 2010-08-13 2010-12-08 清华大学 一种文件系统中实时删除重复数据的方法
CN102629247A (zh) * 2011-12-31 2012-08-08 成都市华为赛门铁克科技有限公司 一种数据处理方法、装置和系统
CN108063818A (zh) * 2017-12-18 2018-05-22 深圳市中科明望通信软件有限公司 数据下载方法、装置、终端和计算机可读存储介质
CN109857548A (zh) * 2019-01-04 2019-06-07 平安科技(深圳)有限公司 存储空间优化方法、装置、计算机设备及存储介质

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113312561A (zh) * 2020-11-24 2021-08-27 芜湖达成储运有限公司 物料存储方法及系统
CN113312561B (zh) * 2020-11-24 2023-11-14 芜湖达成储运有限公司 物料存储方法及系统
CN113051223A (zh) * 2021-03-30 2021-06-29 联想(北京)有限公司 一种数据处理方法及装置

Also Published As

Publication number Publication date
CN109857548B (zh) 2023-08-22
CN109857548A (zh) 2019-06-07

Similar Documents

Publication Publication Date Title
WO2020140634A1 (zh) 存储空间优化方法、装置、计算机设备及存储介质
US20060015698A1 (en) Method and apparatus for data backup
CN106708608B (zh) 一种分布式锁服务方法、获取方法及相应装置
KR20110098567A (ko) 최소 부트 이미지의 생성 방법 및 장치
US20050235094A1 (en) Information processor capable of using past processing space
CN108196959B (zh) Etl系统的资源管理方法及装置
CN113961510B (zh) 一种文件处理方法、装置、设备及存储介质
CN107682389B (zh) 一种执行网络请求的方法、终端及计算机可读存储介质
CN111736915A (zh) 云主机实例硬件加速设备的管理方法、装置、设备及介质
CN112559127B (zh) 虚拟机创建方法、装置、主机及存储介质
US10552318B2 (en) Working set adjustment in a managed environment
CN108205559B (zh) 一种数据管理方法及其设备
CN110609710A (zh) 一种安卓系统开机速度控制方法、智能设备及存储介质
CN117008934A (zh) 自动制作信创操作系统镜像的方法、装置、设备及介质
WO2023066246A1 (zh) 云手机安装应用的方法、系统和客户端云手机
CN113742131A (zh) 用于存储管理的方法、电子设备和计算机程序产品
CN110555009A (zh) 一种网络文件系统nfs服务的处理方法及装置
CN115599299A (zh) 一种存储桶管理方法、装置及电子设备和存储介质
CN113986471A (zh) 虚拟机镜像文件安全删除方法、装置、设备及存储介质
CN113805801A (zh) 高效iOS端数据持久化方法及系统
CN108268285B (zh) Bios版本升级的方法、装置、设备及可读存储介质
CN113946275A (zh) 一种缓存管理方法及装置、存储介质
CN110960858A (zh) 一种游戏资源的处理方法、装置、设备及存储介质
CN104461382A (zh) 运行多个文件系统的文件服务器的内部写方法和服务器
WO2021254280A1 (zh) 磁盘挂载方法、装置、存储介质以及电子装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19907951

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19907951

Country of ref document: EP

Kind code of ref document: A1