WO2017166758A1 - 缓存管理方法、装置、移动终端和电子设备 - Google Patents
缓存管理方法、装置、移动终端和电子设备 Download PDFInfo
- Publication number
- WO2017166758A1 WO2017166758A1 PCT/CN2016/100288 CN2016100288W WO2017166758A1 WO 2017166758 A1 WO2017166758 A1 WO 2017166758A1 CN 2016100288 W CN2016100288 W CN 2016100288W WO 2017166758 A1 WO2017166758 A1 WO 2017166758A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- cache
- image file
- file
- bitmap format
- preset value
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
Definitions
- the present application relates to the field of computer mobile terminal technologies, and in particular, to a cache management method, apparatus, mobile terminal, and electronic device.
- the technical problem to be solved by the present application is that the mobile terminal continuously loads the image file and occupies too much cache, which causes the mobile terminal to run slowly, even crashes and crashes.
- the embodiment of the present application provides a cache management method, including: calculating a size of an image file to be loaded; loading the image file into a cache; determining whether the cache occupancy exceeds a preset value, when the preset is exceeded. The value removes at least a portion of the previously cached image file to free up cache space.
- the step of removing at least a part of the previously cached image file includes: using an LRU algorithm, moving the least recently used image file out of the cache.
- the step of removing at least a part of the previously cached image files includes: sorting the oldest cached image files out of the cache according to a cache time order.
- the image file is a bitmap format file.
- the non-bitmap format file is downloaded, and the non-bitmap format file is converted into a bitmap format file.
- the embodiment of the present application further provides a cache management apparatus, including: a calculating unit, configured to calculate a size of an image file to be loaded; a loading unit, configured to load the image file into a cache; and a determining unit, configured to determine a cache Whether the occupation exceeds a preset value; the removal unit is configured to remove at least a part of the previously cached image file to release the buffer space when the determining unit determines that the buffer occupancy exceeds a preset value.
- the removal unit uses an LRU algorithm to move the least recently used image file out of the cache.
- the removal unit sorts according to the cache time sequence, and moves the oldest cached image file out of the cache.
- the image file is a bitmap format file.
- the embodiment of the present application further provides a mobile terminal, including the cache management apparatus according to any one of the preceding claims.
- An embodiment of the present application further provides an electronic device including at least one processor; and a memory communicably coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor Executing, by the at least one processor, the at least one processor to calculate a size of an image file to be loaded; loading the image file into a cache; determining whether a cache occupancy exceeds a preset value, when When the preset value is exceeded, at least a portion of the previously cached image file is removed to free up the cache space.
- the removing at least a part of the previously cached image file includes: using an LRU algorithm, moving the least recently used image file out of the cache.
- the removing at least a part of the previously cached image files includes: sorting the earliest cached image files out of the cache according to a cache time order.
- the image file is a bitmap format file.
- the non-bitmap format file is downloaded, and the non-bitmap format file is converted into a bitmap format file.
- Embodiments of the present application also provide a non-volatile computer storage medium storing the computer-executable instructions of computer-executable instructions that, when executed by an electronic device, enable an electronic device to calculate an image to be loaded The size of the file; loading the image file into the cache; determining whether the cache occupancy exceeds a preset value, and removing at least a portion of the previously cached image file to release the cache space when the preset value is exceeded.
- the removing at least a part of the previously cached image file includes: using an LRU algorithm, moving the least recently used image file out of the cache.
- the removing at least a part of the previously cached image files includes: sorting the oldest cached image files out of the cache according to the cache time order.
- the image file is a bitmap format file.
- the non-bitmap format file is downloaded, and the non-bitmap format file is converted into a bitmap format file.
- the embodiment of the present application further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer
- the computer is caused to perform any of the above methods.
- the cache management method and apparatus, the mobile terminal, the electronic device, and the storage medium provided by the embodiments of the present application remove at least a portion of the previous image file from the cache to release the cache space when the cache occupancy exceeds a preset value, thereby maintaining the cache. Do not take up too much, keep the mobile terminal running smoothly.
- FIG. 1 shows a flow chart of a cache management method according to an embodiment of the present application
- FIG. 2 is a schematic diagram of a cache management apparatus according to an embodiment of the present application.
- FIG. 3 is a schematic diagram showing the hardware structure of an electronic device according to an embodiment of the present application.
- connection or integral connection; may be mechanical connection or electrical connection; may be directly connected, may also be indirectly connected through an intermediate medium, or may be internal communication of two components, may be wireless connection, or may be wired connection.
- connection or integral connection; may be mechanical connection or electrical connection; may be directly connected, may also be indirectly connected through an intermediate medium, or may be internal communication of two components, may be wireless connection, or may be wired connection.
- the embodiment of the present application provides a cache management method, which can be applied to mobile terminals such as mobile phones and tablet computers. As shown in FIG. 1 , the method includes the following steps:
- the image files may be image files of various formats, such as bmp, jpg, tif, png, and the like.
- the preset value can be set by the user, for example, can be set to 60%-90% of the total cache space, and preferably can be set to 80% of the total cache space.
- the mobile terminal when the cache occupancy exceeds the preset value, the mobile terminal removes at least a part of the previous image file from the cache to release the buffer space, so that the cache can be kept from being occupied too much, and the mobile terminal is kept running smoothly.
- the mobile terminal may move all the image files previously cached out of the cache, or may only move a part of the image files out of the cache, preferably only a part of the image files, and keep the cache occupancy at, for example, 80% or less. It is possible to balance the smooth running of the mobile terminal and the speed of opening the image file.
- the mobile terminal may adopt the LRU (Least Recently Used) algorithm, that is, the least recently used algorithm, and move the least recently used image file out of the cache; the mobile terminal may also sort the cached time and move the oldest cached image file out of the cache. This allows the user to get a better browsing image file experience.
- LRU Least Recently Used
- the image file is a bitmap (bmp) format file, so that the mobile terminal can directly display when the file is loaded without opening the decoding operation.
- the image file to be loaded is not a bitmap format file, for example, in the jpg format
- the mobile terminal downloads the jpg image file into the ROM memory of the mobile terminal, and then converts it into a bit.
- the format of the map, and the bitmap format file is loaded into the cache, so that the file can be opened quickly.
- the embodiment of the present application provides a cache management device, which can be applied to mobile terminals such as mobile phones and tablet computers.
- the device includes:
- the calculating unit 21 is configured to calculate the size of the image file to be loaded.
- the image files may be image files of various formats, such as bmp, jpg, tif, png, and the like.
- the loading unit 22 is configured to load the image file into the cache. This makes it easy for the user to quickly open the image file when performing operations such as viewing back.
- the determining unit 23 is configured to determine whether the buffer occupancy exceeds a preset value.
- the preset value can be set by the user, for example, can be set to 60%-90% of the total cache space, and preferably can be set to 80% of the total cache space.
- the removing unit 24 is configured to remove at least a portion of the previously cached image file to release the buffer space when the determining unit 23 determines that the buffer occupancy exceeds a preset value.
- the mobile terminal when the cache occupancy exceeds a preset value, the mobile terminal removes at least a part of the previous image file from the cache to release the cache space, so that the cache can be kept from being occupied too much, and the mobile terminal is kept running smoothly.
- the removal unit 24 may move all the image files previously cached out of the cache, or may only move a part of the image files out of the cache, preferably only a part of the image files, so that the cache occupancy is always kept below, for example, 80%, so that Both the mobile terminal runs smoothly and the image file is opened quickly.
- the removal unit 24 may adopt an LRU (Least Recently Used) algorithm, that is, a least recently used algorithm, to move the least recently used image file out of the cache; the removal unit 24 may also sort the cached time and remove the oldest cached image file. Cache, which allows users to get a better browsing image file experience.
- LRU Least Recently Used
- the embodiment of the present application further provides a mobile terminal, which includes the cache management device as described above, so that the mobile terminal can remove at least a part of the previous image file from the cache to release the cache space when the cache occupancy exceeds a preset value. Therefore, the cache can be kept from being used too much, and the mobile terminal can be kept running smoothly.
- FIG. 3 Another embodiment of the present application further provides an electronic device, as shown in FIG. 3, including at least one processor 810; and a memory 800 communicably coupled to the at least one processor 810; wherein the memory 800 Storing instructions executable by the at least one processor 810, the instructions being executed by the at least one processor 810 to enable the at least one processor 810 to calculate a size of an image file to be loaded;
- the image file is loaded into the cache; it is determined whether the cache occupancy exceeds a preset value, and when the preset value is exceeded, at least a part of the previously cached image file is removed to release the cache space.
- the electronic device also includes an input device 830 and an output device 840 that are electrically coupled to the memory 800 and the processor, the electrical connection preferably being through a total Wire connection.
- the removing at least a part of the previously cached image file comprises: using an LRU algorithm, moving the least recently used image file out of the cache.
- the removing at least a part of the previously cached image files comprises: sorting the oldest cached image files out of the cache according to a cache time order.
- the image file is a bitmap format file.
- the non-bitmap format file is downloaded, and the non-bitmap format file is converted into a bitmap format file.
- Another embodiment of the present application also provides a non-volatile computer storage medium storing the computer-executable instructions of computer-executable instructions that, when executed by an electronic device, enable an electronic device to calculate The size of the loaded image file; loading the image file into the cache; determining whether the cache occupancy exceeds a preset value, and removing at least a portion of the previously cached image file to release the cache space when the preset value is exceeded.
- the removing at least a portion of the previously cached image files comprises: using an LRU algorithm, moving the least recently used image files out of the cache.
- the removing at least a part of the previously cached image files comprises: sorting the oldest cached image files out of the cache according to a cache time order.
- the image file is a bitmap format file.
- the non-bitmap format file is downloaded, and the non-bitmap format file is converted into a bitmap format file.
- Another embodiment of the present application also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions When executed by a computer, the computer is caused to perform any of the above methods.
- embodiments of the present application can be provided as a method, system, or computer program product. Therefore, the present application can adopt an entirely hardware embodiment, complete software implementation. For example, or in combination with an embodiment of software and hardware aspects.
- the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
- the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种缓存管理方法、装置、移动终端和电子设备,涉及计算机移动终端技术领域,其中所述方法包括:计算所要打开的图像文件的大小(S11);将所述图像文件加载到缓存(S12);判断缓存占用是否超出预设值(S13),当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间(S14)。由此,在缓存占用超出预设值时,从缓存中移出至少一部分先前的图像文件以释放缓存空间,从而可以保持缓存不会占用过多,保持移动终端运行流畅。
Description
交叉引用
本申请为在2016年04月01日提交中国专利局、申请号为201610204157.5、发明名称为“缓存管理方法、装置和移动终端”的中国专利申请的继续申请,本申请要求在2016年04月01日提交中国专利局、申请号为201610204157.5、发明名称为“缓存管理方法、装置和移动终端”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机移动终端技术领域,具体涉及一种缓存管理方法、装置、移动终端和电子设备。
在移动互联网时代,用户越来越习惯于用手机等移动终端来浏览照片、带有图像文件的网页等。当用户在浏览图像文件时,移动终端会不断将图像文件加载到缓存中,以便于用户在执行回看等操作时能够迅速显示图像文件,这样对于存在移动终端存储器内的照片文件而言,无需再进行一次解码操作,而对于处于网络端的图像文件而言,用户也不需要再耗费流量重新下载该图像文件,可以给用户带来极好的用户体验。
然而,随着移动终端显示的图像文件越来越多,会占用越来越多的缓存空间,受限于目前移动终端的缓存和处理器的处理能力,这样会导致移动终端运行缓慢,甚至于死机、崩溃。
发明内容
本申请要解决的技术问题在于移动终端不断加载图像文件会占用过多缓存,导致移动终端运行缓慢,甚至于死机、崩溃。
为此,本申请实施例提供了一种缓存管理方法,包括:计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
本申请实施例所述的缓存管理方法,优选地,所述移出至少一部分先前缓存的图像文件的步骤包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
本申请实施例所述的缓存管理方法,优选地,所述移出至少一部分先前缓存的图像文件的步骤包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本申请实施例所述的缓存管理方法,优选地,所述图像文件是位图格式文件。
本申请实施例所述的缓存管理方法,优选地,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
本申请实施例还提供了一种缓存管理装置,包括:计算单元,用于计算所要加载的图像文件的大小;加载单元,用于将所述图像文件加载到缓存;判断单元,用于判断缓存占用是否超出预设值;移出单元,用于在所述判断单元判断缓存占用超出预设值时,移出至少一部分先前缓存的图像文件以释放缓存空间。
本申请实施例所述的缓存管理装置,优选地,所述移出单元采用LRU算法,将近期最少使用的图像文件移出缓存。
本申请实施例所述的缓存管理装置,优选地,所述移出单元按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本申请实施例所述的缓存管理装置,优选地,所述图像文件是位图格式文件。
本申请实施例还提供了一种移动终端,包括上述任一项所述的缓存管理装置。
本申请实施例还提供了一种电子设备,包括至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
本申请实施例所述的电子设备,优选地,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
本申请实施例所述的电子设备,优选地,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本申请实施例所述的电子设备,优选地,所述图像文件是位图格式文件。
本申请实施例所述的电子设备,优选地,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
本申请实施例还提供了一种非易失性计算机存储介质,所述存储介质存储有计算机可执行指令的所述计算机可执行指令,当由电子设备执行时使得电子设备能够计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
本申请实施例所述的存储介质,优选地,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
本申请实施例所述的存储介质,优选地,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本申请实施例所述的存储介质,优选地,所述图像文件是位图格式文件。
本申请实施例所述的存储介质,优选地,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
本申请实施例还提出了一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述任一种方法。本申请实施例所提供的缓存管理方法、装置、移动终端和电子设备及存储介质,在缓存占用超出预设值时,从缓存中移出至少一部分先前的图像文件以释放缓存空间,从而可以保持缓存不会占用过多,保持移动终端运行流畅。
为了更清楚地说明本申请具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
通过参考附图会更加清楚的理解本申请的特征和优点,附图是示意性的而不应理解为对本申请进行任何限制,在附图中:
图1示出了根据本申请实施例的缓存管理方法的流程图;
图2示出了根据本申请实施例的缓存管理装置的示意图;
图3示出了根据本申请实施例的电子设备的硬件结构示意图。
下面将结合附图对本申请的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申
请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
在本申请的描述中,需要说明的是,术语“中心”、“上”、“下”、“左”、“右”、“竖直”、“水平”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本申请和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本申请的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。
在本申请的描述中,需要说明的是,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,还可以是两个元件内部的连通,可以是无线连接,也可以是有线连接。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。
此外,下面所描述的本申请不同实施方式中所涉及的技术特征只要彼此之间未构成冲突就可以相互结合。
下面将结合附图对本申请的实施例进行详细描述。
本申请实施例提供了一种缓存管理方法,该方法可以适用于手机、平板电脑等移动终端,如图1所示,该方法包括如下步骤:
S11.计算所要加载的图像文件的大小。在这里,图像文件可以是各种格式的图像文件,例如bmp、jpg、tif、png等。
S12.将图像文件加载到缓存。这样便于用户在执行回看等操作时能够迅速打开该图像文件。
S13.判断缓存占用是否超出预设值,当超出预设值时执行步骤S14,
当未超出预设值时,说明缓存空间仍有大量富余,无需执行任何操作。在这里,预设值可以由用户自行设定,例如可以设置为全部缓存空间的60%-90%,优选可以设置为全部缓存空间的80%。
S14.移出至少一部分先前缓存的图像文件以释放缓存空间。
通过上述步骤,移动终端在缓存占用超出预设值时,从缓存中移出至少一部分先前的图像文件以释放缓存空间,从而可以保持缓存不会占用过多,保持移动终端运行流畅。
在步骤S14中,移动终端可以将先前缓存所有的图像文件都移出缓存,也可以仅将一部分图像文件移出缓存,优选地仅移出一部分图像文件,而使缓存占用始终保持在例如80%以下,从而可以兼顾移动终端运行流畅和打开图像文件速度快。
优选地,移动终端可以采用LRU(Least Recently Used)算法,即近期最少使用算法,将近期最少使用的图像文件移出缓存;移动终端也可以按照缓存时间先后排序,将最早缓存的图像文件移出缓存,从而可以使用户获得更佳的浏览图像文件体验。
作为一种优选实施方式,图像文件是位图(bmp)格式文件,这样移动终端在加载该文件时可以直接显示,而无需解码操作,打开更为迅速。优选地,用户在浏览网页时,当所要加载的图像文件不是位图格式文件时,例如为jpg格式时,移动终端将该jpg图像文件下载到移动终端的ROM存储器中,然后将其转换成位图格式,并将该位图格式文件加载到缓存中,由此即可以迅速打开该文件。
相应地,本申请实施例提供了一种缓存管理装置,该装置可以适用于手机、平板电脑等移动终端,如图2所示,该装置包括:
计算单元21,用于计算所要加载的图像文件的大小。在这里,图像文件可以是各种格式的图像文件,例如bmp、jpg、tif、png等。
加载单元22,用于将图像文件加载到缓存。这样便于用户在执行回看等操作时能够迅速打开该图像文件。
判断单元23,用于判断缓存占用是否超出预设值。当未超出预设值时,
说明缓存空间仍有大量富余,无需执行任何操作。在这里,预设值可以由用户自行设定,例如可以设置为全部缓存空间的60%-90%,优选可以设置为全部缓存空间的80%。
移出单元24,用于在判断单元23判断缓存占用超出预设值时,移出至少一部分先前缓存的图像文件以释放缓存空间。
通过上述装置,移动终端在缓存占用超出预设值时,从缓存中移出至少一部分先前的图像文件以释放缓存空间,从而可以保持缓存不会占用过多,保持移动终端运行流畅。
在这里,移出单元24可以将先前缓存所有的图像文件都移出缓存,也可以仅将一部分图像文件移出缓存,优选地仅移出一部分图像文件,而使缓存占用始终保持在例如80%以下,从而可以兼顾移动终端运行流畅和打开图像文件速度快。
优选地,移出单元24可以采用LRU(Least Recently Used)算法,即近期最少使用算法,将近期最少使用的图像文件移出缓存;移出单元24也可以按照缓存时间先后排序,将最早缓存的图像文件移出缓存,从而可以使用户获得更佳的浏览图像文件体验。
本申请实施例还提供了一种移动终端,其包括如上所述的缓存管理装置,从而移动终端可以在缓存占用超出预设值时,从缓存中移出至少一部分先前的图像文件以释放缓存空间,从而可以保持缓存不会占用过多,保持移动终端运行流畅。
本申请的另一实施例还提供了一种电子设备,如图3所示,包括至少一个处理器810;以及,与所述至少一个处理器810通信连接的存储器800;其中,所述存储器800存储有可被所述至少一个处理器810执行的指令,所述指令被所述至少一个处理器810执行,以使所述至少一个处理器810能够计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。所述电子设备还包括与所述存储器800和所述处理器电连接的输入装置830和输出装置840,所述电连接优选为通过总
线连接。
本实施例的所述电子设备,优选地,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
本实施例的所述电子设备,优选地,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本实施例的所述电子设备,优选地,所述图像文件是位图格式文件。
本实施例的所述电子设备,优选地,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
本申请的另一实施例还提供了一种非易失性计算机存储介质,所述存储介质存储有计算机可执行指令的所述计算机可执行指令,当由电子设备执行时使得电子设备能够计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
本实施例的所述存储介质,优选地,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
本实施例的所述存储介质,优选地,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
本实施例的所述存储介质,优选地,所述图像文件是位图格式文件。
本实施例的所述存储介质,优选地,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
本申请的另一实施例还提供了一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述任一种方法。
本领域内的技术人员还应理解,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施
例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的,应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,上述实施例仅仅是为清楚地说明所作的举例,而并非对实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其它不同形式的变化或变动。这里无需也无法对所有的实施方式予以穷举。而由此所引伸出的显而易见的变化或变动仍处于本发明创造的保护范围之中。
Claims (21)
- 一种缓存管理方法,其特征在于,包括:计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
- 根据权利要求1所述的缓存管理方法,其特征在于,所述移出至少一部分先前缓存的图像文件的步骤包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
- 根据权利要求1所述的缓存管理方法,其特征在于,所述移出至少一部分先前缓存的图像文件的步骤包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
- 根据权利要求1-3中任一项所述的缓存管理方法,其特征在于,所述图像文件是位图格式文件。
- 根据权利要求1-3中任一项所述的缓存管理方法,其特征在于,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
- 一种缓存管理装置,其特征在于,包括:计算单元,用于计算所要加载的图像文件的大小;加载单元,用于将所述图像文件加载到缓存;判断单元,用于判断缓存占用是否超出预设值;移出单元,用于在所述判断单元判断缓存占用超出预设值时,移出至少一部分先前缓存的图像文件以释放缓存空间。
- 根据权利要求6所述的缓存管理装置,其特征在于,所述移出单元采用LRU算法,将近期最少使用的图像文件移出缓存。
- 根据权利要求6所述的缓存管理装置,其特征在于,所述移出单元按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
- 根据权利要求6-8中任一项所述的缓存管理装置,其特征在于,所 述图像文件是位图格式文件。
- 一种移动终端,其特征在于,包括权利要求6-9中任一项所述的缓存管理装置。
- 一种电子设备,其特征在于包括至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
- 根据权利要求11所述的电子设备,其特征在于,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
- 根据权利要求11所述的电子设备,其特征在于,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
- 根据权利要求11-13任一项所述的电子设备,其特征在于,所述图像文件是位图格式文件。
- 根据权利要求11-13任一项所述的电子设备,其特征在于,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
- 一种非易失性计算机存储介质,其特征在于:所述存储介质存储有计算机可执行指令的所述计算机可执行指令,当由电子设备执行时使得电子设备能够:计算所要加载的图像文件的大小;将所述图像文件加载到缓存;判断缓存占用是否超出预设值,当超出所述预设值时移出至少一部分先前缓存的图像文件以释放缓存空间。
- 根据权利要求16所述的非易失性计算机存储介质,其特征在于,所述移出至少一部分先前缓存的图像文件包括:采用LRU算法,将近期最少使用的图像文件移出缓存。
- 根据权利要求16所述的非易失性计算机存储介质,其特征在于,所述移出至少一部分先前缓存的图像文件包括:按照缓存时间先后排序,将最早缓存的图像文件移出缓存。
- 根据权利要求16-18任一项所述的非易失性计算机存储介质,其特征在于,所述图像文件是位图格式文件。
- 根据权利要求16-18任一项所述的非易失性计算机存储介质,其特征在于,当所述图像文件是非位图格式文件时,下载所述非位图格式文件,将所述非位图格式文件转换成位图格式文件。
- 一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,其特征在于,当所述程序指令被计算机执行时,使所述计算机执行上述任一权利要求所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610204157.5 | 2016-04-01 | ||
| CN201610204157.5A CN105912592A (zh) | 2016-04-01 | 2016-04-01 | 缓存管理方法、装置和移动终端 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2017166758A1 true WO2017166758A1 (zh) | 2017-10-05 |
Family
ID=56745441
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2016/100288 Ceased WO2017166758A1 (zh) | 2016-04-01 | 2016-09-27 | 缓存管理方法、装置、移动终端和电子设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN105912592A (zh) |
| WO (1) | WO2017166758A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113282855A (zh) * | 2021-06-01 | 2021-08-20 | 广州欢网科技有限责任公司 | Android系统的图片加载方法及装置 |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105912592A (zh) * | 2016-04-01 | 2016-08-31 | 乐视控股(北京)有限公司 | 缓存管理方法、装置和移动终端 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102831111A (zh) * | 2011-06-14 | 2012-12-19 | 腾讯科技(深圳)有限公司 | 一种图片显示方法和装置 |
| CN103677942A (zh) * | 2013-12-30 | 2014-03-26 | Tcl集团股份有限公司 | 一种移动终端浏览网络图片的方法和装置 |
| CN104267918A (zh) * | 2014-09-17 | 2015-01-07 | 深圳市九洲电器有限公司 | 一种图片显示方法及系统 |
| CN104657378A (zh) * | 2013-11-20 | 2015-05-27 | 青岛海信移动通信技术股份有限公司 | 一种文件缓存方法及装置 |
| CN105912592A (zh) * | 2016-04-01 | 2016-08-31 | 乐视控股(北京)有限公司 | 缓存管理方法、装置和移动终端 |
-
2016
- 2016-04-01 CN CN201610204157.5A patent/CN105912592A/zh active Pending
- 2016-09-27 WO PCT/CN2016/100288 patent/WO2017166758A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102831111A (zh) * | 2011-06-14 | 2012-12-19 | 腾讯科技(深圳)有限公司 | 一种图片显示方法和装置 |
| CN104657378A (zh) * | 2013-11-20 | 2015-05-27 | 青岛海信移动通信技术股份有限公司 | 一种文件缓存方法及装置 |
| CN103677942A (zh) * | 2013-12-30 | 2014-03-26 | Tcl集团股份有限公司 | 一种移动终端浏览网络图片的方法和装置 |
| CN104267918A (zh) * | 2014-09-17 | 2015-01-07 | 深圳市九洲电器有限公司 | 一种图片显示方法及系统 |
| CN105912592A (zh) * | 2016-04-01 | 2016-08-31 | 乐视控股(北京)有限公司 | 缓存管理方法、装置和移动终端 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113282855A (zh) * | 2021-06-01 | 2021-08-20 | 广州欢网科技有限责任公司 | Android系统的图片加载方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105912592A (zh) | 2016-08-31 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103473142B (zh) | 一种云计算操作系统下的虚拟机迁移方法及装置 | |
| RU2615682C2 (ru) | Способ, устройство, сервер и терминал для посещения веб-страницы | |
| CN108063818B (zh) | 数据下载方法、装置、终端和计算机可读存储介质 | |
| CN110688595A (zh) | 一种文件在线预览方法、装置、设备和存储介质 | |
| EP2992453A1 (en) | Hydration and dehydration with placeholders | |
| CN103973731B (zh) | 一种云存储的回收站管理方法和装置 | |
| CN106453572B (zh) | 基于云服务器同步图像的方法及系统 | |
| CN104572922A (zh) | 一种基于移动设备的图片处理方法和装置 | |
| CN107577711B (zh) | 一种图片缓存的方法和装置 | |
| CN114185850B (zh) | 一种基于滑动窗口分块优化算法的云存储去重方法及设备 | |
| JP7617939B2 (ja) | ステッカー処理方法及び装置 | |
| US20150324357A1 (en) | Blended storage allocation on a storage agent | |
| CN106161523A (zh) | 一种数据处理方法和设备 | |
| CN104657378A (zh) | 一种文件缓存方法及装置 | |
| CN106708478B (zh) | 滚动视图显示方法及装置 | |
| CN105721340A (zh) | 一种在线阅读预加载量计算方法和装置 | |
| US20170205980A1 (en) | Method and an apparatus for providing a multitasking view | |
| CN110633434A (zh) | 一种页面缓存方法、装置、电子设备及存储介质 | |
| CN115470427A (zh) | 页面加载方法、装置、设备以及存储介质 | |
| CN107885741A (zh) | 图片缓存管理方法及移动终端 | |
| WO2017166760A1 (zh) | 回看图像文件的方法、装置、移动终端和电子设备 | |
| CN104636464A (zh) | 访问文件的方法和装置 | |
| CN103631616B (zh) | 图片快速加载及缓存方法与系统 | |
| WO2019062615A1 (zh) | 一种用户界面渲染方法及装置 | |
| CN102779181B (zh) | 基于html5的浏览器离线存储数据处理方法及浏览器 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16896528 Country of ref document: EP Kind code of ref document: A1 |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 16896528 Country of ref document: EP Kind code of ref document: A1 |