A document page caching method, system, storage medium and electronic device
Patent Information
- Application Number
- CN202211103388.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-09-09
AI Technical Summary
[0003]现有的多页面文档的渲染与显示技术通常存在加载时间过长、耗费内存过大、翻页发生闪烁现象等诸多问题
[0011]本发明的方法通过不断对缓存的渲染结果进行替换,能够提高缓存的效率,从而最大程度降低文档阅读软件的卡顿和闪烁现象,提高文档阅读体验效果。
Smart Images

Figure CN115640780B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document processing technology, and in particular to a document page caching method, system, storage medium, and electronic device. Background Technology
[0002] With the widespread use of electronic devices, more and more people are choosing to read multi-page documents in formats such as Word, PDF, or OFD on these devices. Multi-page documents are characterized by complex page structures and a wide variety of objects, resulting in longer rendering times for readers with significant variations in rendering time. This can easily lead to stuttering or flickering during rendering, thus degrading the user's reading experience. A common solution is for readers to employ specific page caching strategies, pre-caching some page rendering results before displaying the target page. If the target page is within the cached page range, the cached result is displayed directly without real-time rendering of the target page. This greatly reduces the possibility of stuttering and flickering, improving the reading experience of multi-page documents.
[0003] Existing rendering and display technologies for multi-page documents often suffer from numerous problems, such as long loading times, excessive memory consumption, and flickering during page turns. Therefore, there is an urgent need to provide a technical solution to address these issues. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a document page caching method, system, storage medium, and electronic device.
[0005] The technical solution of the document page caching method of the present invention is as follows:
[0006] S1. When a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain the determination result;
[0007] S2. When the judgment result is yes, the rendering result of any page is obtained from the current cached rendering result and displayed.
[0008] S3. Based on the page position of any page, determine at least one target cache page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain the target cache sequence.
[0009] S4. Determine the pages corresponding to the first m cache replacement values in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer.
[0010] The beneficial effects of the document page caching method of the present invention are as follows:
[0011] The method of this invention improves caching efficiency by continuously replacing the cached rendering results, thereby minimizing lag and flickering in document reading software and enhancing the document reading experience.
[0012] Based on the above solution, the document page caching method of the present invention can be further improved as follows.
[0013] Furthermore, determining at least one target cached page based on the page position of any of the pages includes:
[0014] Based on the page position of any page and the maximum number of page caches for the target document, the target cache range is determined; wherein, the target cache range is: [Max(1, tN / 2), Min(N, t+N / 2)], where N is the maximum number of page caches and t is the page position of any page;
[0015] All pages within the target cache range are identified as at least one target cache page of the target document.
[0016] Furthermore, the process of obtaining the maximum number of page caches is as follows: based on the formula for calculating the number of page caches, the maximum number of page caches for the target document is obtained;
[0017] The formula for calculating the number of page caches is: N max =M avail ×R / P mem N max M is the maximum number of pages cached. avail R is the available memory size of the device running the target document, R is the proportion of the running device used for page caching, and P is the available memory size of the device running the target document. mem The memory size occupied by the single-page buffer in the target document.
[0018] Furthermore, the process of obtaining the cache replacement cost value of each target cache page and each current cache page is as follows: based on the preset page cache replacement cost formula, obtain the cache replacement cost value of each target cache page and the cache replacement cost value of each current cache page;
[0019] The formula for the preset page cache replacement cost is: E i =T i / T avg +2 / (1+D it ); E i T is the cache replacement cost of the i-th page in the target document. iLet T be the rendering complexity of the i-th page in the target document. avg D is the average rendering complexity of all cached pages. it Let be the distance between the i-th page and the t-th page in the target document, where t is any page, i ∈ [tN / 2, t+N / 2], and i is a positive integer.
[0020] The beneficial effects of adopting the above-mentioned further technical solutions are as follows: by caching pages with high rendering complexity and long rendering time, and rendering pages with low complexity in real time, it is possible to cache higher-value time-consuming pages with limited cache resources, expand the scope of page caching, and improve caching efficiency.
[0021] Furthermore, it also includes: when the judgment result is negative, rendering and displaying any of the pages, and executing step S3.
[0022] The beneficial effects of adopting the above-mentioned further technical solutions are as follows: by caching pages with high rendering complexity and long rendering time, and rendering pages with low complexity in real time, it is possible to cache higher-value time-consuming pages with limited cache resources, expand the scope of page caching, and improve caching efficiency.
[0023] The technical solution of the document page caching system of the present invention is as follows:
[0024] It includes: a judgment module, a first processing module, a second processing module, and a running module;
[0025] The judgment module is used to: when a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain the judgment result;
[0026] The first processing module is configured to: when the judgment result is yes, obtain the rendering result of any page from the current cached rendering result and display it;
[0027] The second processing module is used to: determine at least one target cache page based on the page position of any page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain a target cache sequence;
[0028] The running module is used to: determine the pages corresponding to the first m cache replacement values in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer.
[0029] The beneficial effects of the document page caching system of the present invention are as follows:
[0030] The system of this invention improves caching efficiency by continuously replacing the cached rendering results, thereby minimizing lag and flickering in document reading software and enhancing the document reading experience.
[0031] Based on the above solution, the document page caching system of the present invention can be further improved as follows.
[0032] Furthermore, the second processing module is specifically used for:
[0033] Based on the page position of any page and the maximum number of page caches for the target document, the target cache range is determined; wherein, the target cache range is: [Max(1, tN / 2), Min(N, t+N / 2)], where N is the maximum number of page caches and t is the page position of any page;
[0034] All pages within the target cache range are identified as at least one target cache page of the target document.
[0035] Furthermore, the process of obtaining the maximum number of page caches is as follows: based on the formula for calculating the number of page caches, the maximum number of page caches for the target document is obtained;
[0036] The formula for calculating the number of page caches is: N max =M avail ×R / P mem N max M is the maximum number of pages cached. avail R is the available memory size of the device running the target document, R is the proportion of the running device used for page caching, and P is the available memory size of the device running the target document. mem The memory size occupied by the single-page buffer in the target document.
[0037] The technical solution of a storage medium according to the present invention is as follows:
[0038] The storage medium stores instructions that, when read by a computer, cause the computer to execute steps of a document page caching method according to the present invention.
[0039] The technical solution of an electronic device according to the present invention is as follows:
[0040] The invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, when the processor executes the computer program, it causes the computer to perform the steps of a document page caching method according to the present invention. Attached Figure Description
[0041] Figure 1This is a flowchart illustrating a document page caching method according to an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the structure of a document page caching system according to an embodiment of the present invention. Detailed Implementation
[0043] like Figure 1 As shown, a document page caching method according to an embodiment of the present invention includes the following steps:
[0044] S1. When a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain the determination result.
[0045] The target document is either a PDF or OFD document containing multiple pages.
[0046] The current cached rendering result is the rendering result of at least one page of the target document cached by the user's running device.
[0047] S2. When the judgment result is yes, the rendering result of any page is obtained from the current cached rendering result and displayed.
[0048] Specifically, if the current cached rendering results contain the rendering results of any page, then the rendering results of that page will be directly retrieved from the current cached rendering results and displayed.
[0049] S3. Based on the page position of any page, determine at least one target cache page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain the target cache sequence.
[0050] The target cached page is determined based on the page position of any page (the current page). The current cached page is the page corresponding to the current cache rendering result.
[0051] The page cache replacement cost is obtained using a preset page cache replacement cost formula. The preset page cache replacement cost formula is: E i =T i / T avg +2 / (1+D it ); E i T is the cache replacement cost of the i-th page in the target document. i Let T be the rendering complexity of the i-th page in the target document. avg D is the average rendering complexity of all cached pages. itLet be the distance between the i-th page and the t-th page in the target document, where t is any page, i ∈ [tN / 2, t+N / 2], and i is a positive integer.
[0052] It should be noted that the rendering complexity of the page is the page rendering time.
[0053] For example, if a user opens page 8, the target cached pages are pages 3-13, and the current cached pages are pages 1-10, then the cache replacement value for pages 1-13 is calculated respectively, and all cache replacement values are arranged in descending order to obtain the target cache sequence.
[0054] S4. Determine the pages corresponding to the first m cache replacement values in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer.
[0055] In this embodiment, the value of m is the maximum number of pages cached for the target document. This value can be adjusted according to user needs and is not limited here.
[0056] Specifically, the first m pages with the highest cache replacement value in the target cache sequence are determined as replacement cache pages, and the rendering result of each replacement cache page is used as the current cache rendering result.
[0057] For example, if m is 4, the cache replacement costs for the current cached pages (pages 1-4) are 2, 3, 4, and 5 respectively, and the cache replacement costs for the target cached pages (pages 5-8) are 2, 3, 6, and 7 respectively. Therefore, the first four cache replacement costs in the target cache sequence are 4, 5, 6, and 7, resulting in the page numbers of the replaced cached pages being 3, 4, 6, and 7. The rendering results of pages 3, 4, 6, and 7 will be used as the current cache rendering results to replace the rendering results of pages 1-4.
[0058] Preferably, determining at least one target cached page based on the page position of any of the pages includes:
[0059] The target cache range of the target document is determined based on the page position of any page and the maximum number of page caches for the target document; wherein the target cache range is: [Max(1, tN / 2), Min(N, t+N / 2)], where N is the maximum number of page caches and t is the page position of any page.
[0060] The page position is the page number. The process for obtaining the maximum number of cached pages is as follows: based on the formula for calculating the number of cached pages, the maximum number of cached pages for the target document is obtained. The formula for calculating the number of cached pages is: N... max =Mavail ×R / P mem N max M is the maximum number of pages cached. avail R is the available memory size of the device running the target document, R is the proportion of the running device used for page caching, and P is the available memory size of the device running the target document. mem The memory size occupied by the single-page buffer in the target document.
[0061] It should be noted that there are generally two methods for determining the specific number of cached pages. One method uses a fixed number of pages, such as caching 5 pages of rendering results. The other method dynamically sets the number of pages based on the available resources of the device on which the reader is running. This embodiment uses the second method, and the specific calculation process is shown in the formula above. R (the proportion of the running device used for page caching) is set to 25% by default, but it can also be set according to requirements; no limit is set here.
[0062] Furthermore, the memory size occupied by each page buffer is only related to the page size (width × height). Assuming that each page of the document has the same size, then the memory size occupied by each page is the same.
[0063] All pages within the target cache range are identified as at least one target cache page of the target document.
[0064] For example, if the target cache range is pages 5-15, then pages 5-15 are all target cache pages.
[0065] Preferably, the method further includes: if the determination result is negative, rendering and displaying any of the pages, and executing step S3.
[0066] Specifically, if the current cached rendering result does not contain the rendering result of any page, then the page is directly loaded, rendered, and displayed, and step S3 is executed.
[0067] This embodiment's technical solution starts from the essence of page caching, caching only pages with high rendering complexity and long rendering time; for pages with low complexity, rendering time is short, and real-time rendering will not affect the smoothness of document reading, so no caching is performed. Through this embodiment's technical solution, limited caching resources can be used to cache higher-value, time-consuming pages, expanding the scope of page caching. While improving caching efficiency, it minimizes lag and flickering in document reading software, thus improving the document reading experience.
[0068] like Figure 2 As shown, a document page caching system 200 according to an embodiment of the present invention includes: a judgment module 210, a first processing module 220, a second processing module 230, and a running module 240;
[0069] The judgment module 210 is used to: when a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain a judgment result;
[0070] The first processing module 220 is configured to: when the determination result is yes, obtain the rendering result of any page from the current cached rendering result and display it;
[0071] The second processing module 230 is used to: determine at least one target cache page according to the page position of any page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain a target cache sequence;
[0072] The running module 240 is used to: determine the pages corresponding to the first m cache replacement values in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer.
[0073] Preferably, the second processing module 230 is specifically used for:
[0074] Based on the page position of any page and the maximum number of page caches for the target document, the target cache range is determined; wherein, the target cache range is: [Max(1, tN / 2), Min(N, t+N / 2)], where N is the maximum number of page caches and t is the page position of any page;
[0075] All pages within the target cache range are identified as at least one target cache page of the target document.
[0076] Preferably, the process of obtaining the maximum number of page caches is as follows: based on the formula for calculating the number of page caches, the maximum number of page caches for the target document is obtained;
[0077] The formula for calculating the number of page caches is: N max =M avail ×R / P mem N max M is the maximum number of pages cached. avail R is the available memory size of the device running the target document, R is the proportion of the running device used for page caching, and P is the available memory size of the device running the target document. mem The memory size occupied by the single-page buffer in the target document.
[0078] The technical solution in this embodiment improves caching efficiency by continuously replacing the cached rendering results, thereby minimizing the lag and flickering of document reading software and enhancing the document reading experience.
[0079] The parameters and steps for implementing the corresponding functions of each module in the document page caching system 200 of this embodiment described above can be referred to the parameters and steps in the embodiment of the document page caching method described above, and will not be repeated here.
[0080] An embodiment of the present invention provides a storage medium, comprising: the storage medium storing instructions, which, when a computer reads the instructions, cause the computer to execute steps such as a document page caching method. For details, please refer to the parameters and steps in the embodiment of the document page caching method above, which will not be repeated here.
[0081] Computer storage media include, for example, USB flash drives and external hard drives.
[0082] An electronic device provided by an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The device is characterized in that, when the processor executes the computer program, it causes the computer to perform steps such as a document page caching method. Specific details regarding the parameters and steps in the above embodiment of a document page caching method are provided and will not be repeated here.
[0083] Those skilled in the art will know that the present invention can be implemented as a method, system, storage medium, and electronic device.
[0084] Therefore, the present invention can be implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the present invention can also be implemented as a computer program product contained in one or more computer-readable media, which contains computer-readable program code. Any combination of one or more computer-readable media can be used. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. Although embodiments of the invention have been shown and described above, it is to be understood that these embodiments are exemplary and should not be construed as limiting the invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the invention.
Claims
1. A document page caching method, characterized in that, include: S1. When a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain the determination result; S2. When the judgment result is yes, the rendering result of any page is obtained from the current cached rendering result and displayed. S3. Based on the page position of any page, determine at least one target cache page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain the target cache sequence. S4. Determine the pages corresponding to the first m cache replacement values in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer; Determining at least one target cached page based on the page position of any of the pages includes: Based on the page position of any page and the maximum page cache size of the target document, the target cache range of the target document is determined; wherein, the target cache range is: [ Max (1, t - N / 2), Min ( N , t + N / 2)], N The maximum number of pages to cache. t The page position of any of the aforementioned pages; All pages within the target cache range are identified as at least one target cache page of the target document; The process of obtaining the maximum number of page caches is as follows: based on the formula for calculating the number of page caches, the maximum number of page caches for the target document is obtained; The formula for calculating the number of page caches is as follows: N max = M avail × R / P mem ; N max The maximum number of pages to cache. M avail The available memory size of the device on which the target document is running. R The proportion of the running device used for page caching. P mem The memory size occupied by the single-page buffer in the target document; The process of obtaining the cache replacement cost value of each target cache page and each current cache page is as follows: based on the preset page cache replacement cost formula, obtain the cache replacement cost value of each target cache page and the cache replacement cost value of each current cache page; The formula for the preset page cache replacement cost is: E i =T i / T avg +2 / (1+D) it ); E i For the first in the target document i The cache replacement value of a single page, T i For the first in the target document i The rendering complexity of a single page, T avg D is the average rendering complexity of all cached pages. it For the first in the target document i Page 1 to Page 2 t The distance between pages t For any of the aforementioned pages, i ∈[ t - N / 2, t + N / 2], i It is a positive integer.
2. The document page caching method according to claim 1, characterized in that, Also includes: If the judgment result is negative, then any page is rendered and displayed, and step S3 is executed.
3. A document page caching system, characterized in that, include: The system comprises a judgment module, a first processing module, a second processing module, and a running module. The judgment module is used to: when a user opens any page of the target document, determine whether the rendering result of any page exists in the current cached rendering result of the target document, and obtain the judgment result; The first processing module is configured to: when the judgment result is yes, obtain the rendering result of any page from the current cached rendering result and display it; The second processing module is used to: determine at least one target cache page based on the page position of any page, and sort the cache replacement value of each target cache page and the cache replacement value of each current cache page in descending order to obtain a target cache sequence; The running module is used to: determine the pages corresponding to the first m cache replacement costs in the target cache sequence as replacement cache pages, and use the rendering result of each replacement cache page as the current cache rendering result; where m is a positive integer; The second processing module is specifically used for: Based on the page position of any page and the maximum page cache size of the target document, the target cache range of the target document is determined; wherein, the target cache range is: [ Max (1, t - N / 2), Min ( N , t + N / 2)], N The maximum number of pages to cache. t The page position of any of the aforementioned pages; All pages within the target cache range are identified as at least one target cache page of the target document; The process of obtaining the maximum number of page caches is as follows: based on the formula for calculating the number of page caches, the maximum number of page caches for the target document is obtained; The formula for calculating the number of page caches is as follows: N max = M avail × R / P mem ; N max The maximum number of pages to cache. M avail The available memory size of the device on which the target document is running. R The proportion of the running device used for page caching. P mem The memory size occupied by the single-page buffer in the target document; The process of obtaining the cache replacement cost value of each target cache page and each current cache page is as follows: based on the preset page cache replacement cost formula, obtain the cache replacement cost value of each target cache page and the cache replacement cost value of each current cache page; The formula for the preset page cache replacement cost is: E i =T i / T avg +2 / (1+D) it ); E i For the first in the target document i The cache replacement value of a single page, T i For the first in the target document i The rendering complexity of a single page, T avg D is the average rendering complexity of all cached pages. it For the first in the target document i Page 1 to Page 2 t The distance between pages t For any of the aforementioned pages, i ∈[ t - N / 2, t + N / 2], i It is a positive integer.
4. A storage medium, characterized in that, The storage medium stores instructions that, when read by a computer, cause the computer to execute a document page caching method as described in claim 1 or 2.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it causes the computer to perform a document page caching method as described in claim 1 or 2.
Citation Information
Patent Citations
Page caching method and device, electronic equipment and storage medium
CN110633434A
OFD document processing method
CN111897780A