CN112084443B - Page caching method and device - Google Patents

Page caching method and device Download PDF

Info

Publication number
CN112084443B
CN112084443B CN202010848061.9A CN202010848061A CN112084443B CN 112084443 B CN112084443 B CN 112084443B CN 202010848061 A CN202010848061 A CN 202010848061A CN 112084443 B CN112084443 B CN 112084443B
Authority
CN
China
Prior art keywords
page
subscript
pages
current page
cache array
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.)
Active
Application number
CN202010848061.9A
Other languages
Chinese (zh)
Other versions
CN112084443A (en
Inventor
张云帆
梁炯生
索俊晓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Fantasy Network Technology Co ltd
Original Assignee
Beijing Fantasy Network Technology Co ltd
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 Beijing Fantasy Network Technology Co ltd filed Critical Beijing Fantasy Network Technology Co ltd
Priority to CN202010848061.9A priority Critical patent/CN112084443B/en
Publication of CN112084443A publication Critical patent/CN112084443A/en
Application granted granted Critical
Publication of CN112084443B publication Critical patent/CN112084443B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/02Digital computers in general; Data processing equipment in general manually operated with input through keyboard and computation using a built-in program, e.g. pocket calculators
    • G06F15/025Digital computers in general; Data processing equipment in general manually operated with input through keyboard and computation using a built-in program, e.g. pocket calculators adapted to a specific application
    • G06F15/0291Digital computers in general; Data processing equipment in general manually operated with input through keyboard and computation using a built-in program, e.g. pocket calculators adapted to a specific application for reading, e.g. e-books
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/117Tagging; Marking up; Designating a block; Setting of attributes

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The application discloses a page caching method and device. The method comprises the following steps: initializing a cache array with the length of N, and determining a subscript from the cache array as a central coordinate; downloading N pages, taking a page positioned in the middle of the N pages as a current page, and determining a subscript corresponding to the current page as a subscript corresponding to a center coordinate; determining subscripts corresponding to the upper X pages of the current page and subscripts corresponding to the lower X pages of the current page according to the central coordinates; and respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array.

Description

Page caching method and device
Technical Field
The present application relates to the field of storage technologies, and in particular, to a page caching method.
Background
Users using readers are increasing, and the readers present reading contents to the users in a page form, so the reading contents need to be generated and cached page by page. At present, page sorting, caching and reading are generally realized by using a cache array with variable length, and the method mainly includes that the subscript of a current page is known first, and then the subscript of a previous page and the subscript of a next page are calculated. However, with the page turning operation, the number of pages cached in the cache array is increased, and the index of the current page is changed accordingly. The method occupies a large amount of memory, thereby affecting the overall performance of the reader.
Disclosure of Invention
In view of this, embodiments of the present invention provide a page caching method and apparatus, which can implement page sorting, caching, and reading under the condition of using a small amount of memory, so as to improve the overall performance of a reader.
To achieve the above object, in a first aspect, the present invention provides a creating method including:
initializing a cache array with the length of N, and determining a subscript from the cache array as a central coordinate, wherein N is a positive integer;
downloading N pages, taking a page positioned in the middle of the N pages as a current page, and determining a subscript corresponding to the current page as a subscript corresponding to a center coordinate;
determining subscripts corresponding to the upper X page of the current page and subscripts corresponding to the lower X page of the current page according to the central coordinates, wherein X is a positive integer and is less than or equal to (N-1)/2;
respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array;
when an operation instruction of turning up pages is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page;
updating the current page to the upper 1 st page, and updating the center coordinate to a subscript corresponding to the upper 1 st page;
when an operation instruction of turning down pages is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page;
and updating the current page to the next 1 st page, and updating the center coordinate to the subscript corresponding to the next 1 st page.
Preferably, the determining the subscript corresponding to the upper X th page of the current page and the subscript corresponding to the lower X th page of the current page according to the center coordinate includes: the subscript corresponding to the top X pages is calculated using the following formula: index (X) = (centerIndex-X + N)% N; the subscript corresponding to the next X pages is calculated using the following formula: index' (X) ═ N% (centenndex + X + N)%; wherein, the centrindex is a subscript corresponding to the central coordinate, Index (X) is a subscript corresponding to the upper X page, and Index' (X) is a subscript corresponding to the lower X page.
Preferably, after the current page is updated to the upper 1 st page, and the center coordinate is updated to the subscript corresponding to the upper 1 st page, the method further includes: recycling the corresponding positions of the subscripts corresponding to the lower (N-1)/2 pages of the original current page in the cache array; and caching the updated upper (N-1)/2 pages of the current page at the corresponding position in the cache array according to the subscript corresponding to the lower (N-1)/2 pages of the original current page.
Preferably, after the current page is updated to the upper 1 st page, and the center coordinate is updated to the subscript corresponding to the upper 1 st page, the method further includes: recycling the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array; and caching the updated lower (N-1)/2 pages of the current page at the corresponding position in the cache array according to the subscript corresponding to the upper (N-1)/2 pages of the original current page.
Preferably, N is an odd number.
In order to achieve the above object, in a second aspect, the present invention provides a page caching apparatus, including:
the device comprises a creating unit, a calculating unit and a processing unit, wherein the creating unit is used for initializing a cache array with the length of N and determining a subscript as a central coordinate from the cache array, and N is a positive integer;
the first determining unit is used for downloading the N pages, taking a page located in the middle position in the N pages as a current page, and determining a subscript corresponding to the current page as a subscript corresponding to a center coordinate;
a second determining unit, configured to determine, according to the center coordinate, a subscript corresponding to an upper X page of the current page and a subscript corresponding to a lower X page of the current page, where X is a positive integer and X is less than or equal to (N-1)/2;
the storage unit is used for respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array;
the reading unit is used for reading the upper 1 th page from the cache array according to the subscript corresponding to the upper 1 th page of the current page when an operation instruction of turning up the page is received;
the updating unit is used for updating the current page to the upper 1 st page and updating the center coordinate to the subscript corresponding to the upper 1 st page;
the reading unit is further configured to, when an operation instruction of turning down a page is received, read the next 1 st page from the cache array according to the subscript corresponding to the next 1 st page of the current page;
the updating unit is further configured to update the current page to the next 1 st page, and update the center coordinate to a subscript corresponding to the next 1 st page.
Preferably, the second determining unit is specifically configured to calculate the subscript corresponding to the top X pages by using the following formula: index (X) = (centerIndex-X + N)% N; the subscript corresponding to the next X pages is calculated using the following formula: index' (X) ═ N% (centenndex + X + N)%; wherein, the centrindex is a subscript corresponding to the central coordinate, Index (X) is a subscript corresponding to the upper X page, and Index' (X) is a subscript corresponding to the lower X page.
Preferably, the apparatus further comprises: the recovery unit is used for recovering the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array; the storage unit is further configured to cache the updated (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the (N-1)/2 th page of the original current page.
Preferably, the apparatus further comprises: the recovery unit is used for recovering the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array; the storage unit is further configured to cache the updated (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the (N-1)/2 th page of the original current page.
Preferably, N is an odd number.
In order to achieve the above object, in a third aspect, the present invention provides a computer-readable storage medium storing a computer program for executing the page caching method described in the first aspect.
In order to achieve the above object, in a fourth aspect, the present invention provides an electronic apparatus comprising: a processor; a memory for storing the processor-executable instructions; the processor is configured to read the executable instruction from the memory, and execute the instruction to implement the page caching method in the first aspect.
By utilizing the page caching method and the page caching device provided by the scheme, a cache array with the length of N is initialized, and a subscript is determined from the cache array as a center coordinate; downloading N pages, taking a page positioned in the middle of the N pages as a current page, determining subscripts corresponding to the current page as central coordinates, and then determining subscripts corresponding to the upper X pages of the current page and subscripts corresponding to the lower X pages of the current page according to the central coordinates; respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array; when an operation instruction of turning up the page is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page; updating the current page to the upper 1 st page, and updating the center coordinate to the subscript corresponding to the upper 1 st page; when an operation instruction of turning down the page is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page; and updating the current page to be the next 1 th page, and updating the center coordinate to be the subscript corresponding to the next 1 st page. According to the process, the cache array can be recycled, the length of the cache array is not required to be changed, so that less memory is occupied, and the pages can be sorted, cached and read under the condition of using a small amount of memory, so that the overall performance of the reader is improved.
Drawings
The above and other objects, features and advantages of the present application will become more apparent by describing in more detail embodiments of the present application with reference to the attached drawings. The accompanying drawings are included to provide a further understanding of the embodiments of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the principles of the application. In the drawings, like reference numbers generally represent like parts or steps.
Fig. 1 is a schematic flowchart of a page caching method according to an exemplary embodiment of the present application;
fig. 2 is a block diagram of a page caching apparatus according to an exemplary embodiment of the present application;
fig. 3 is a block diagram of a page caching apparatus according to another exemplary embodiment of the present application;
fig. 4 is a block diagram of an electronic device provided in an exemplary embodiment of the present application.
Detailed Description
Hereinafter, example embodiments according to the present application will be described in detail with reference to the accompanying drawings. It should be understood that the described embodiments are only some embodiments of the present application and not all embodiments of the present application, and that the present application is not limited by the example embodiments described herein.
Fig. 1 is a schematic flowchart of a page caching method according to an exemplary embodiment of the present application. The method is applied to a page caching device, and the page caching device can be configured on a reader.
The method comprises the following steps:
step 101, initializing a cache array with the length of N, and determining a subscript from the cache array as a center coordinate.
The cache array is a cache array with a fixed length, wherein N is a positive integer. Preferably, N is typically odd for ease of calculation. In a specific example, in order to occupy as little memory as possible, the value of N may be determined according to statistical reading habits (e.g., page turning speed) of the user, and for example, N may be 5 or 7.
The center coordinate may be any subscript in the cache array.
And 102, downloading N pages, taking a page positioned in the middle of the N pages as a current page, and determining that the subscript corresponding to the current page is the subscript corresponding to the center coordinate.
In a specific example, assuming that N takes a value of 5, determining a subscript 0 as a center coordinate, downloading 5 pages of read content, where the page numbers are pages 12, 13, 14, 15, and 16, respectively, and then the 14 th page of the middle page is a current page, and the corresponding subscript is the subscript 0 corresponding to the center coordinate.
And 103, determining subscripts corresponding to the upper X pages of the current page and subscripts corresponding to the lower X pages of the current page according to the central coordinates.
Wherein X is a positive integer and is less than or equal to (N-1)/2.
Specifically, the subscript corresponding to the top X pages is calculated by using the following formula:
index (X) = (centerIndex-X + N)% N; formula one
The subscript corresponding to the next X pages is calculated using the following formula:
index' (X) ═ N% (centenndex + X + N)%; formula two
Where, the centrindex is a subscript corresponding to the center coordinate, Index (X) is a subscript corresponding to the top X page, and Index' (X) is a subscript corresponding to the bottom X page.
In a specific example, based on the example in step 102, the subscript corresponding to the top 1 page (i.e., page 13) is (0-1+ 5)% 5 ═ 4, the subscript corresponding to the top 2 page (i.e., page 12) is (0-2+ 5)% 5 ═ 3, the subscript corresponding to the bottom 1 page (i.e., page 15) is (0+1+ 5)% 5 ═ 1, and the subscript corresponding to the bottom 2 page (i.e., page 16) is (0+2+ 5)% 5 ═ 2. The corresponding relationship among the current page, page number, subscript and center coordinate is shown in table one.
Watch 1
Page Top 2 page Top 1 page Current page The next 1 st page The next 2 pages
Page number 12 13 14 15 16
Subscript 3 4 0 1 2
Center coordinate 0 0 0 0 0
And 104, respectively storing the N pages in the positions corresponding to the subscripts corresponding to the pages in the cache array.
In a specific example, taking table one as an example, page 12 is stored in the cache array at a location corresponding to subscript 3, page 13 is stored in the cache array at a location corresponding to subscript 4, page 14 is stored in the cache array at a location corresponding to subscript 0, page 15 is stored in the cache array at a location corresponding to subscript 1, and page 16 is stored in the cache array at a location corresponding to subscript 2.
And 105, when an operation instruction of page turning up is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page.
Specifically, the subscript corresponding to the top 1 page of the current page may be calculated according to the formula one.
In a specific example, taking table one as an example, if the current page is the 14 th page, the first page is the 13 th page, and when an operation instruction of turning up the page is received, the 13 th page is read from the position with the index of 4 in the cache array and displayed.
And 106, updating the current page to the upper 1 st page, and updating the center coordinate to the subscript corresponding to the upper 1 st page.
It can be understood that when an operation instruction of turning up the page is received, the upper (N-1)/2 pages of the updated current page are downloaded and cached. Thus, after step 106, the method further comprises:
recycling the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array; and caching the updated upper (N-1)/2 pages of the current page at the corresponding positions in the cache array according to the subscripts corresponding to the lower (N-1)/2 pages of the original current page.
In a specific example, taking table one as an example, when an operation instruction for turning up a page is received, the 13 th page is updated to be the current page, and the center coordinate is updated to be the subscript 4 corresponding to the 13 th page. Before downloading the upper (N-1)/2 pages (11 th page) of the updated current page (13 th page) of the reading content, recovering the corresponding positions of the subscript 2 corresponding to the lower (N-1)/2 pages (16 th page) of the original current page (14 th page) in the cache array, and then caching the 11 th page at the position corresponding to the subscript 2. The correspondence between the page, page number, subscript, and center coordinate after turning up 1 page is shown in table two.
Watch two
Figure BDA0002643761450000081
Figure BDA0002643761450000091
It is understood that when the page-up operation command is received again, steps 105 and 106 are repeatedly executed.
And step 107, when an operation instruction of page turning down is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page.
Specifically, the subscript corresponding to the next 1 th page of the current page may be calculated according to formula two.
In a specific example, taking table one as an example, if the current page is the 14 th page, the first next page is the 15 th page, and when an operation instruction of turning up the page is received, the 15 th page is read from the position with the index of 1 in the cache array and displayed.
Step 108, updating the current page to the next 1 st page, and updating the center coordinate to the subscript corresponding to the next 1 st page.
It can be understood that, when the operation instruction of turning down the page is received, the lower (N-1)/2 pages of the updated current page are downloaded and cached. Thus, after step 108, the method further comprises:
recycling the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array; and caching the updated lower (N-1)/2 pages of the current page at the corresponding positions in the cache array according to the subscripts corresponding to the upper (N-1)/2 pages of the original current page.
In a specific example, taking table one as an example, when an operation instruction for turning down a page is received, the 15 th page is updated to be the current page, and the center coordinate is updated to be subscript 1 corresponding to the 15 th page. Before downloading the next (N-1)/2 pages (namely, the 17 th page) of the updated current page (namely, the 15 th page) of the reading content, recovering the corresponding positions of the subscripts 3 corresponding to the next (N-1)/2 pages (namely, the 12 th page) of the original current page (namely, the 14 th page) in the cache array, and then caching the 17 th page at the positions corresponding to the subscripts 3. The corresponding relationship among the page, page number, subscript, and center coordinate after turning down 1 page is shown in table three.
Watch III
Page Top 2 page Top 1 page Current page The next 1 st page The next 2 pages
Page number 13 14 15 16 17
Subscript 4 0 1 2 3
Center coordinate 1 1 1 1 1
It is understood that when the page-down operation command is received again, steps 107 and 108 are repeatedly executed.
By using the page caching method provided by the embodiment, a cache array with the length of N is initialized, and a subscript is determined from the cache array as a center coordinate; downloading N pages, taking a page positioned in the middle of the N pages as a current page, determining subscripts corresponding to the current page as central coordinates, and then determining subscripts corresponding to the upper X pages of the current page and subscripts corresponding to the lower X pages of the current page according to the central coordinates; respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array; when an operation instruction of turning up the page is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page; updating the current page to the upper 1 st page, and updating the center coordinate to the subscript corresponding to the upper 1 st page; when an operation instruction of turning down the page is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page; and updating the current page to be the next 1 th page, and updating the center coordinate to be the subscript corresponding to the next 1 st page. According to the process, the cache array can be recycled, the length of the cache array is not required to be changed, so that less memory is occupied, and the pages can be sorted, cached and read under the condition of using a small amount of memory, so that the overall performance of the reader is improved.
Fig. 2 is a block diagram of a page caching apparatus according to an exemplary embodiment of the present application. The page buffer device can be configured on the reader. As shown in fig. 2, a page caching apparatus according to an embodiment of the present application includes:
the creating unit 201 is configured to initialize a cache array with a length of N, and determine a subscript as a center coordinate from the cache array, where N is a positive integer;
a first determining unit 202, configured to download N pages, take a page located in a middle position of the N pages as a current page, and determine that a subscript corresponding to the current page is a subscript corresponding to a center coordinate;
a second determining unit 203, configured to determine, according to the center coordinate, a subscript corresponding to an upper X page of the current page and a subscript corresponding to a lower X page of the current page, where X is a positive integer and X is less than or equal to (N-1)/2;
the storage unit 204 is configured to store the N pages in corresponding positions of the subscripts corresponding to each page in the cache array, respectively;
a reading unit 205, configured to, when an operation instruction of turning up a page is received, read the upper 1 th page from the cache array according to a subscript corresponding to the upper 1 th page of the current page;
an updating unit 206, configured to update the current page to the top 1 page, and update the center coordinate to a subscript corresponding to the top 1 page;
the reading unit 205 is further configured to, when an operation instruction of turning a page down is received, read the next 1 th page from the cache array according to the subscript corresponding to the next 1 th page of the current page;
the updating unit 206 is further configured to update the current page to the next 1 st page, and update the center coordinate to a subscript corresponding to the next 1 st page.
Preferably, the second determining unit 203 is specifically configured to calculate the subscript corresponding to the top X page by using the following formula: index (X) = (centerIndex-X + N)% N; the subscript corresponding to the next X pages is calculated using the following formula: index' (X) ═ N% (centenndex + X + N)%; wherein, the centrindex is a subscript corresponding to the central coordinate, Index (X) is a subscript corresponding to the upper X page, and Index' (X) is a subscript corresponding to the lower X page.
Preferably, the apparatus further comprises:
a recycling unit 207, configured to recycle a corresponding position of a subscript corresponding to the (N-1)/2 th page of the original current page in the cache array;
the storage unit 204 is further configured to cache the updated upper (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the lower (N-1)/2 th page of the original current page.
Preferably, as shown in fig. 3, the apparatus may further include:
a recycling unit 207, configured to recycle a corresponding position of a subscript corresponding to the (N-1)/2 th page of the original current page in the cache array;
the storage unit 204 is further configured to cache the updated (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the (N-1)/2 th page of the original current page.
Preferably, N is an odd number.
By utilizing the page caching device provided by the embodiment, a cache array with the length of N is initialized, and a subscript is determined from the cache array as a center coordinate; downloading N pages, taking a page positioned in the middle of the N pages as a current page, determining subscripts corresponding to the current page as central coordinates, and then determining subscripts corresponding to the upper X pages of the current page and subscripts corresponding to the lower X pages of the current page according to the central coordinates; respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array; when an operation instruction of turning up the page is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page; updating the current page to the upper 1 st page, and updating the center coordinate to the subscript corresponding to the upper 1 st page; when an operation instruction of turning down the page is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page; and updating the current page to be the next 1 th page, and updating the center coordinate to be the subscript corresponding to the next 1 st page. According to the process, the cache array can be recycled, the length of the cache array is not required to be changed, so that less memory is occupied, and the pages can be sorted, cached and read under the condition of using a small amount of memory, so that the overall performance of the reader is improved.
Next, an electronic apparatus 11 according to an embodiment of the present application is described with reference to fig. 4. As shown in fig. 4, the electronic device 11 includes one or more processors 111 and memory 112.
The processor 111 may be a Central Processing Unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in the electronic device 11 to perform desired functions.
Memory 112 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, Random Access Memory (RAM), cache memory (cache), and/or the like. The non-volatile memory may include, for example, Read Only Memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium and executed by processor 111 to implement the creation methods of the various embodiments of the application described above and/or other desired functions. Various contents such as an input signal, a signal component, a noise component, etc. may also be stored in the computer-readable storage medium.
In one example, the electronic device 11 may further include: an input device 113 and an output device 114, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
The input device 113 may include, for example, a keyboard, a mouse, and the like.
The output device 114 may output various information including the determined distance information, direction information, and the like to the outside. The output devices 114 may include, for example, a display, speakers, a printer, and a communication network and remote output devices connected thereto, among others.
Of course, for the sake of simplicity, only some of the components of the electronic device 11 relevant to the present application are shown in fig. 4, and components such as buses, input/output interfaces, and the like are omitted. In addition, the electronic device 11 may include any other suitable components, depending on the particular application.
Exemplary computer program product and computer-readable storage Medium
In addition to the above-described methods and apparatus, embodiments of the present application may also be a computer program product comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the page caching method according to various embodiments of the present application described in the "exemplary methods" section of this specification, supra.
The computer program product may be written with program code for performing the operations of embodiments of the present application in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.
Furthermore, embodiments of the present application may also be a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, cause the processor to perform the steps in the page caching method according to various embodiments of the present application described in the "exemplary methods" section above in this specification.
The computer-readable storage medium may take any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing describes the general principles of the present application in conjunction with specific embodiments, however, it is noted that the advantages, effects, etc. mentioned in the present application are merely examples and are not limiting, and they should not be considered essential to the various embodiments of the present application. Furthermore, the foregoing disclosure of specific details is for the purpose of illustration and description and is not intended to be limiting, since the foregoing disclosure is not intended to be exhaustive or to limit the disclosure to the precise details disclosed.
The block diagrams of devices, apparatuses, systems referred to in this application are only given as illustrative examples and are not intended to require or imply that the connections, arrangements, configurations, etc. must be made in the manner shown in the block diagrams. These devices, apparatuses, devices, systems may be connected, arranged, configured in any manner, as will be appreciated by those skilled in the art. Words such as "including," "comprising," "having," and the like are open-ended words that mean "including, but not limited to," and are used interchangeably therewith. The words "or" and "as used herein mean, and are used interchangeably with, the word" and/or, "unless the context clearly dictates otherwise. The word "such as" is used herein to mean, and is used interchangeably with, the phrase "such as but not limited to".
It should also be noted that in the devices, apparatuses, and methods of the present application, the components or steps may be decomposed and/or recombined. These decompositions and/or recombinations are to be considered as equivalents of the present application.
The previous description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects without departing from the scope of the application. Thus, the present application is not intended to be limited to the aspects shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing description has been presented for purposes of illustration and description. Furthermore, the description is not intended to limit embodiments of the application to the form disclosed herein. While a number of example aspects and embodiments have been discussed above, those of skill in the art will recognize certain variations, modifications, alterations, additions and sub-combinations thereof.

Claims (12)

1. A page caching method, characterized in that the method comprises:
initializing a cache array with the length of N, and determining a subscript from the cache array as a central coordinate, wherein N is a positive integer and is an odd number;
downloading N pages, taking a page positioned in the middle of the N pages as a current page, and determining a subscript corresponding to the current page as a subscript corresponding to a center coordinate;
determining subscripts corresponding to the upper X page of the current page and subscripts corresponding to the lower X page of the current page according to the central coordinates, wherein X is a positive integer and is less than or equal to (N-1)/2;
respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array;
when an operation instruction of turning up pages is received, reading the upper 1 page from the cache array according to the subscript corresponding to the upper 1 page of the current page;
updating the current page to the upper 1 st page, and updating the center coordinate to a subscript corresponding to the upper 1 st page;
when an operation instruction of turning down pages is received, reading the next 1 page from the cache array according to the subscript corresponding to the next 1 page of the current page;
and updating the current page to the next 1 st page, and updating the center coordinate to the subscript corresponding to the next 1 st page.
2. The method according to claim 1, wherein the determining the subscript corresponding to the top X pages of the current page and the subscript corresponding to the bottom X pages of the current page according to the center coordinates comprises:
the subscript corresponding to the top X pages is calculated using the following formula:
Index(X)=(centerIndex-X+N)%N;
the subscript corresponding to the next X pages is calculated using the following formula:
Index’(X)=(centerIndex+X+N)%N;
wherein, the centrindex is a subscript corresponding to the central coordinate, Index (X) is a subscript corresponding to the upper X page, and Index' (X) is a subscript corresponding to the lower X page.
3. The method according to claim 1 or 2, wherein after the current page is updated to the upper 1 st page and the center coordinate is updated to the subscript corresponding to the upper 1 st page, the method further comprises:
recycling the corresponding positions of the subscripts corresponding to the lower (N-1)/2 pages of the original current page in the cache array;
and caching the updated upper (N-1)/2 pages of the current page at the corresponding position in the cache array according to the subscript corresponding to the lower (N-1)/2 pages of the original current page.
4. The method according to claim 1 or 2, wherein after the current page is updated to the upper 1 st page and the center coordinate is updated to the subscript corresponding to the upper 1 st page, the method further comprises:
recycling the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array;
and caching the updated lower (N-1)/2 pages of the current page at the corresponding position in the cache array according to the subscript corresponding to the upper (N-1)/2 pages of the original current page.
5. The method of claim 1, wherein N is an odd number.
6. A page caching apparatus, the apparatus comprising:
the device comprises a creating unit, a calculating unit and a processing unit, wherein the creating unit is used for initializing a cache array with the length of N and determining a subscript from the cache array as a central coordinate, N is a positive integer and N is an odd number;
the first determining unit is used for downloading the N pages, taking a page located in the middle position in the N pages as a current page, and determining a subscript corresponding to the current page as a subscript corresponding to a center coordinate;
a second determining unit, configured to determine, according to the center coordinate, a subscript corresponding to an upper X page of the current page and a subscript corresponding to a lower X page of the current page, where X is a positive integer and X is less than or equal to (N-1)/2;
the storage unit is used for respectively storing the N pages in the corresponding positions of the subscripts corresponding to each page in the cache array;
the reading unit is used for reading the upper 1 th page from the cache array according to the subscript corresponding to the upper 1 th page of the current page when an operation instruction of turning up the page is received;
the updating unit is used for updating the current page to the upper 1 st page and updating the center coordinate to the subscript corresponding to the upper 1 st page;
the reading unit is further configured to, when an operation instruction of turning down a page is received, read the next 1 st page from the cache array according to the subscript corresponding to the next 1 st page of the current page;
the updating unit is further configured to update the current page to the next 1 st page, and update the center coordinate to a subscript corresponding to the next 1 st page.
7. The apparatus according to claim 6, wherein the second determining unit is specifically configured to calculate the subscript corresponding to the top X pages by using the following formula:
Index(X)=(centerIndex-X+N)%N;
the subscript corresponding to the next X pages is calculated using the following formula:
Index’(X)=(centerIndex+X+N)%N;
wherein, the centrindex is a subscript corresponding to the central coordinate, Index (X) is a subscript corresponding to the upper X page, and Index' (X) is a subscript corresponding to the lower X page.
8. The apparatus of claim 6 or 7, further comprising:
the recovery unit is used for recovering the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array;
the storage unit is further configured to cache the updated (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the (N-1)/2 th page of the original current page.
9. The apparatus of claim 6 or 7, further comprising:
the recovery unit is used for recovering the corresponding positions of the subscripts corresponding to the (N-1)/2 th page of the original current page in the cache array;
the storage unit is further configured to cache the updated (N-1)/2 th page of the current page at the corresponding position in the cache array at the subscript corresponding to the (N-1)/2 th page of the original current page.
10. The apparatus of claim 6, wherein N is an odd number.
11. A computer-readable storage medium storing a computer program for executing the page caching method of any one of claims 1 to 5.
12. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is configured to read the executable instructions from the memory and execute the instructions to implement the page caching method according to any one of claims 1 to 5.
CN202010848061.9A 2020-08-21 2020-08-21 Page caching method and device Active CN112084443B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010848061.9A CN112084443B (en) 2020-08-21 2020-08-21 Page caching method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010848061.9A CN112084443B (en) 2020-08-21 2020-08-21 Page caching method and device

Publications (2)

Publication Number Publication Date
CN112084443A CN112084443A (en) 2020-12-15
CN112084443B true CN112084443B (en) 2021-09-07

Family

ID=73729497

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010848061.9A Active CN112084443B (en) 2020-08-21 2020-08-21 Page caching method and device

Country Status (1)

Country Link
CN (1) CN112084443B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033334B (en) * 2022-08-10 2022-12-06 长沙朗源电子科技有限公司 Page turning method, system, equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103777868A (en) * 2012-10-23 2014-05-07 福建星网视易信息系统有限公司 Screen sliding method using page as unit and having background loading function and cache logic function
CN108491546A (en) * 2018-04-04 2018-09-04 武汉斗鱼网络科技有限公司 A kind of page switching method and electronic equipment
CN110362771A (en) * 2019-07-26 2019-10-22 北京明略软件系统有限公司 Method and device, storage medium and the electronic device of page cache

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10521117B2 (en) * 2015-11-24 2019-12-31 Sap Se Unified table delta dictionary memory size and load time optimization

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103777868A (en) * 2012-10-23 2014-05-07 福建星网视易信息系统有限公司 Screen sliding method using page as unit and having background loading function and cache logic function
CN108491546A (en) * 2018-04-04 2018-09-04 武汉斗鱼网络科技有限公司 A kind of page switching method and electronic equipment
CN110362771A (en) * 2019-07-26 2019-10-22 北京明略软件系统有限公司 Method and device, storage medium and the electronic device of page cache

Also Published As

Publication number Publication date
CN112084443A (en) 2020-12-15

Similar Documents

Publication Publication Date Title
US10496755B2 (en) Information processing apparatus, information processing method, and non-transitory computer readable medium storing program
AU2016225947B2 (en) System and method for multimedia document summarization
US11409374B2 (en) Method and device for input prediction
JP2014032665A (en) Selective display of ocr'ed text and corresponding images from publications on client device
US9910589B2 (en) Virtual keyboard with adaptive character recognition zones
CN111767508B (en) Method, device, medium and equipment for computing tensor data by computer
CN111105029A (en) Neural network generation method and device and electronic equipment
CN112084443B (en) Page caching method and device
CN111708720A (en) Data caching method, device, equipment and medium
CN110837531B (en) Data source read-write separation method and device and computer readable storage medium
CN114880289A (en) File grouping display method and computing device
CN112596868A (en) Model training method and device
CN116933728A (en) Text processing method, electronic device and storage medium
CN108875036B (en) Page data caching method and device and electronic equipment
CN111475156B (en) Page code generation method and device, electronic equipment and storage medium
US11809806B2 (en) Glyph accessibility system
RU2626657C1 (en) Determination of text outcome sequence in pdf documents
CN110781354B (en) Object selection method, device and system and computing equipment
CN114020864A (en) Search result display method, device and equipment
CN113343137A (en) Optimized SEO page generation method and device, electronic equipment and storage medium
CN112749256A (en) Text processing method, device, equipment and storage medium
CN110866406A (en) Translation integration service optimization method, electronic device and storage medium
CN113920333B (en) Intelligent management method and system for improving resident experience degree
CN117195840B (en) Method and device for marking and inserting special-shaped objects in web editor in real time
CN117932184A (en) Page automatic layout method and device according to different languages

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant