A paging cache method and related device
By configuring a unified cache paging size for the same data list, calculating the cache page number and data index range based on the query request, and intercepting the paging data from the cache data list, the problem of large storage space occupied by caches of different interface types is solved, and storage efficiency and performance are improved.
Patent Information
- Application Number
- CN202510473284.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-04-16
AI Technical Summary
In the prior art, different page sizes are required when displaying the same data list on different web pages, which causes the web service to cache paged data lists of multiple interface types, occupying a large amount of storage space.
By configuring the same cache paging size, multiple interface types under the target data list are cached, and the cache page number is calculated based on the query paging size and page number, the data index range of the cache data list is obtained, and the paged data list is intercepted from the cache data list using the intersection.
This enables various interfaces to share a cache, reduces storage space usage, and improves the storage efficiency and performance of web services.
Smart Images

Figure CN119988769B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a paging cache method and related devices. Background Art
[0002] Currently, the same data list needs to be displayed in different page sizes on different web pages. The browser will request the required paged data list from the web service interface based on the display requirements of the current web page.
[0003] In order to bear the pressure of interface requests, web services will set up caches for paged data lists of various interfaces. This means that one data list will cache paged data lists of different interface types, which greatly occupies the storage space of web services. Summary of the Invention
[0004] In view of the above problems, the present application provides a page caching method and related devices to achieve the purpose of reducing the storage space occupied by caching various page data lists. The specific solution is as follows:
[0005] A first aspect of the present application provides a paging cache method, the paging cache method comprising:
[0006] Receive a query request for a target data list, wherein the query request includes a query paging size and a query page number corresponding to the target interface type;
[0007] Calculating a cache page number according to the query page size, the query page number, and a configured cache page size, wherein the cache page size is configured for a plurality of interface types under the target data list;
[0008] Obtaining a cache data list corresponding to the cache page number, and determining a first data subscript range corresponding to the cache data list;
[0009] A second data subscript range is calculated using the query paging size and the query page number, a paging data list of the target interface type is obtained from the cached data list according to the intersection of the first data subscript range and the second data subscript range, and the paging data list is output.
[0010] In a possible implementation, the cache paging size is configured as follows:
[0011] Acquire multiple initial page sizes corresponding to the multiple interface types, where one interface type corresponds to one initial page size;
[0012] taking the least common multiple of the plurality of initial page sizes as a candidate page size;
[0013] Determining whether the candidate page size is smaller than a preset page size threshold;
[0014] If so, using the candidate page size as the cache page size;
[0015] If not, the cache page size is selected from the multiple initial page sizes.
[0016] In a possible implementation, calculating the cache page number according to the query page size, the query page number, and the configured cache page size includes:
[0017] Comparing the query page size with the cache page size;
[0018] If the query page size is smaller than the cache page size, determining whether the cache page size is divisible by the query page size; if so, processing the cache page size, the query page size, and the query page number in a rounding-up manner to obtain the cache page number; if not, calculating a first data subscript boundary based on the query page number and the query page size, and processing the first data subscript boundary and the cache page size in a rounding-up manner to obtain the cache page number;
[0019] When the query page size is equal to the cache page size, using the query page number as the cache page number;
[0020] When the query page size is larger than the cache page size, determine whether the query page size is divisible by the cache page size; if so, calculate a second data subscript boundary based on the query page number and the query page size, and use the second data subscript boundary and the cache page size to calculate the cache page number; if not, calculate a third data subscript boundary based on the query page number and the query page size, and round the third data subscript boundary and the cache page size to obtain the cache page number.
[0021] In a possible implementation, obtaining the cache data list corresponding to the cache page number includes:
[0022] In the case where there are multiple cache page numbers, a concurrent thread is used to obtain the cache data list corresponding to each cache page number.
[0023] In a possible implementation, obtaining the cache data list corresponding to the cache page number includes:
[0024] Querying the cache resource using the cache page number to determine whether the cache data list exists;
[0025] If so, obtain the cache data list;
[0026] If not, a fourth data subscript boundary is calculated according to the cache page number and the cache paging size, and an original data list in the database is obtained by querying according to the fourth data subscript boundary, and the original data list is cached to obtain the cached data list.
[0027] In a possible implementation, determining the first data subscript range corresponding to the cached data list includes:
[0028] Determining a data subscript starting boundary in the fourth data subscript boundary;
[0029] Merging the cache data lists according to the cache page numbers, and counting the total number of data items in the merged cache data lists;
[0030] The data subscript starting boundary and the total number of data items are used to determine the real data subscript ending boundary, and the data subscript starting boundary and the real data subscript ending boundary constitute the first data subscript range.
[0031] A second aspect of the present application provides a paging cache device, the paging cache device comprising:
[0032] A request receiving module, configured to receive a query request for a target data list, wherein the query request includes a query paging size and a query page number corresponding to the target interface type;
[0033] a cache processing module, configured to calculate a cache page number based on the query page size, the query page number, and a configured cache page size, wherein the cache page size is configured for multiple interface types under the target data list; obtain a cache data list corresponding to the cache page number, and determine a first data subscript range corresponding to the cache data list;
[0034] A cache output module is used to calculate a second data subscript range using the query paging size and the query page number, intercept the paging data list of the target interface type from the cache data list according to the intersection of the first data subscript range and the second data subscript range, and output the paging data list.
[0035] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the paging cache method of the first aspect or any implementation of the first aspect.
[0036] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0037] The memory is used to store computer programs;
[0038] The processor is configured to execute the computer program so that the electronic device can implement the paging cache method of the first aspect or any implementation of the first aspect.
[0039] In a fifth aspect, the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the paging cache method of the above-mentioned first aspect or any implementation method of the first aspect.
[0040] By means of the above technical solution, the present application provides a paging cache method and related device, which configure the same cache page size for multiple interface types under a target data list. A query request for a target data list is received, the query request including the query page size and query page number corresponding to the target interface type; the cache page number is calculated based on the query page size, query page number, and cache page size; the cache data list corresponding to the cache page number is obtained, and the first data subscript range corresponding to the cache data list is determined; the second data subscript range is calculated using the query page size and query page number, and a paging data list of the target interface type is obtained from the cache data list according to the intersection of the first data subscript range and the second data subscript range, and the paging data list is output. This application can configure a cache paging size for the same data list. When facing a query request of the target interface type, the cache page number can be calculated based on the query paging size, query page number and cache paging size to obtain the cached data list and determine the corresponding data index range. The query paging size and query page number are used to calculate the data index range to be queried, and the paging data list is intercepted from the cache data list with the intersection of the data index range for output. This allows various interfaces to share a cache, converting interface requests into cache internal operations, and saving storage space to the greatest extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0042] Figure 1 A schematic diagram of a flow chart of a paging cache method provided in an embodiment of the present application;
[0043] Figure 2 A partial flow chart of a paging cache method provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of another portion of the flow chart of a paging cache method provided in an embodiment of the present application;
[0045] Figure 4 A schematic diagram of another portion of the flow chart of a paging cache method provided in an embodiment of the present application;
[0046] Figure 5 A schematic diagram of the structure of a paging cache device provided in an embodiment of the present application;
[0047] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The following describes the embodiments of the present application in conjunction with the accompanying drawings. The terms used in the implementation methods of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application.
[0049] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0050] The terms "first", "second" etc. in the specification of the application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0051] For ease of understanding, this application will be described using a video list as an example. It is understood that data lists include, but are not limited to, video lists and may also be other types of lists, such as a fan list, and this embodiment of the application does not limit this. A video list contains descriptive information for multiple video objects, including, but not limited to, the video subscript (i.e., the serial number of the video object), the video ID, the video title, the user who uploaded the video, the address of the video cover image, the address of the video playback file, and so on.
[0052] Generally speaking, the same video list needs to display different paging size effects on different web pages. For example, the user homepage needs to display a paging data list with 4 video objects per page, while the user video details page needs to display a paging data list with 40 video objects per page. The paging data list is the result of splitting the row records in the video list according to the paging size.
[0053] Based on the current webpage's display requirements, the browser will request the required paginated data list from the web service's interface. The request includes the page size and page number. To manage the pressure of interface requests and prevent database crashes caused by high-concurrency queries, the web service caches the paginated data list using the page size and page number in the request as the key. Assuming the video list contains descriptions of 100 video objects and 1MB of storage space, two types of cache data are required for the user homepage and user video details page:
[0054] User homepage: key = user ID + paging size (equal to 4) + page number, value = paging data list of the page number, a total of 25 paging data lists;
[0055] User video details page: key = user ID + paging size (equal to 40) + page number, value = paging data list of the page number, a total of 3 paging data lists.
[0056] Because cached data for the user homepage and video details pages requires 2MB of storage space for the web service, N types of interfaces require N times the storage space to cache the paginated data lists. However, cache typically uses server memory, which is not only expensive in physical resources but also affects the performance of the web service.
[0057] To solve the above problems, an embodiment of the present application provides a page caching method. The page caching method of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0058] See also Figure 1 , Figure 1 A schematic diagram of a paging cache method provided in an embodiment of the present application. Figure 1 As shown, a paging cache method provided by an embodiment of the present application is applied to web services and may include steps S101 to S104. These steps are described in detail below.
[0059] S101, receiving a query request for a target data list, where the query request includes a query paging size and a query page number corresponding to a target interface type.
[0060] In the embodiment of the present application, the target data list is the data list to be queried by the browser, which can be a video list, a fan list, etc. The target interface type is a certain interface type under the target data list queried by the browser, such as the user homepage under the video list, or the user video details interface type.
[0061] Based on the current webpage's display requirements, the browser requests a paginated data list of the target interface type from the web service. The query request includes the page size (i.e., the query page size) and page number (i.e., the query page number). The web service receives the browser's query request and parses it to obtain the query page size and page number.
[0062] S102 , calculating a cache page number according to the query page size, the query page number, and the configured cache page size, where the cache page size is configured for multiple interface types under the target data list.
[0063] In this embodiment of the present application, the same cache page size is configured for different interface types within the same data list. Multiple interface types within the target data list share the same cache page size. The data index range to be queried is determined based on the query page size and the query page number. For example, in the video list, this data index range is the video index range. Furthermore, the page number (i.e., the cache page number) for this data index range is determined based on the cache page size.
[0064] In one possible implementation, the cache page size can be configured according to the page size required to be displayed by different interface types. Figure 2 , Figure 2 This is a partial flow chart of a paging cache method provided in an embodiment of the present application. Figure 2 As shown, an embodiment of the present application provides a paging cache method, wherein the configuration method of the cache page size may include steps S201 to S205, and these steps are described in detail below.
[0065] S201 , obtaining multiple initial page sizes corresponding to multiple interface types, where one interface type corresponds to one initial page size.
[0066] In the embodiment of the present application, for each interface type in the target data list, the page size required by the interface type (ie, the initial page size) is obtained. Thus, the initial page sizes of multiple interface types can be obtained, ie, multiple initial page sizes.
[0067] S202: Taking the least common multiple of a plurality of initial page sizes as a candidate page size.
[0068] In this embodiment of the present application, the least common multiple of multiple initial page sizes is calculated and used as a candidate page size. For ease of understanding, assume that there are three interface types under the video list, and the initial page sizes are 4 (i.e., 4 video objects per page), 10 (i.e., 10 video objects per page), and 20 (i.e., 20 video objects per page). The least common multiple of 20 can be determined as a candidate page size.
[0069] S203, determining whether the candidate page size is smaller than a preset page size threshold; if so, executing step S204; if not, executing step S205.
[0070] In the embodiment of the present application, a paging size threshold is determined based on the size of a single data block of a cache service and is compared with a candidate paging size.
[0071] S204: Use the candidate page size as the cache page size.
[0072] In the embodiment of the present application, if the candidate page size is less than the page size threshold, the candidate page size can be used as the cache page size. Continuing with the above video list as an example, assuming the page size threshold is 25, the cache page size can be determined to be 20.
[0073] S205: Select a cache page size from a plurality of initial page sizes.
[0074] In an embodiment of the present application, if the candidate page size is greater than or equal to the page size threshold, one of the multiple initial page sizes can be selected as the cache page size in a compromise manner, and the cache page size can be ensured to be divisible by the largest number of initial page sizes. This can minimize the data transmission time between the cache service.
[0075] In one possible implementation, the cache page number can be calculated based on the size relationship between the query page size and the cache page size. To this end, an embodiment of the present application provides a paging cache method, wherein step S102 of "calculating the cache page number based on the query page size, the query page number, and the configured cache page size" can include the following steps, which are described in detail below.
[0076] Compare query page size and cache page size;
[0077] If the query page size is smaller than the cache page size, determining whether the cache page size is divisible by the query page size; if so, processing the cache page size, the query page size, and the query page number in a rounded-up manner to obtain a cache page number; if not, calculating a first data subscript boundary based on the query page number and the query page size, and processing the first data subscript boundary and the cache page size in a rounded-up manner to obtain a cache page number;
[0078] When the query page size is equal to the cache page size, the query page number is used as the cache page number;
[0079] When the query page size is larger than the cache page size, determine whether the query page size is divisible by the cache page size; if so, calculate the second data subscript boundary based on the query page number and the query page size, and use the second data subscript boundary and the cache page size to calculate the cache page number; if not, calculate the third data subscript boundary based on the query page number and the query page size, and process the third data subscript boundary and the cache page size in a rounded manner to obtain the cache page number.
[0080] In the embodiment of the present application, for ease of understanding, the query page size is defined as pageSize, the cache page size is defined as cacheSize, the query page number is defined as pageNo, and the cache page number is defined as cacheNo.
[0081] Compare pageSize and cacheSize.
[0082] 1) PageSize is smaller than cacheSize. Determine whether cacheSize is divisible by pageSize. Specifically, determine whether cacheSize% pageSize is equal to 0.
[0083] If cacheSize%pageSize is equal to 0, that is, cacheSize is divisible by pageSize, then cacheNo=round up (pageNo / (cacheSize / pageSize))
[0084] If cacheSize% pageSize is not equal to 0, that is, cacheSize is not divisible by pageSize, then there will be a situation where the cache spans multiple pages. In this case, the corresponding data subscript boundary (that is, the first data subscript boundary) is calculated, and the data subscript start boundary in the first data subscript boundary is defined as cacheNoMin1, and the data subscript end boundary is defined as cacheNoMax1. cacheNoMin1 = ((pageNo-1)×pageSize / cacheSize)+1, and cacheNoMax1 = ((pageNo×pageSize-1) / cacheSize)+1.
[0085] 2) pageSize equals cacheSize. cacheNo = pageNo.
[0086] 3) PageSize is greater than cacheSize. Determine whether pageSize is divisible by cacheSize. Specifically, determine whether pageSize%cacheSize equals 0.
[0087] If pageSize%cacheSize is equal to 0, that is, pageSize is divisible by cacheSize, there will be a situation where the cache spans multiple pages. In this case, the corresponding data subscript boundary (that is, the second data subscript boundary) is calculated, and the data subscript start boundary in the second data subscript boundary is defined as cacheNoMin2, and the data subscript end boundary is defined as cacheNoMax2. cacheNoMin2=(pageNo-1)×pageSize / cacheSize+1, cacheNoMax2=pageNo×pageSize / cacheSize.
[0088] If pageSize%cacheSize is not equal to 0, that is, pageSize is not divisible by cacheSize, there will be a situation where the cache spans multiple pages. In this case, the corresponding data subscript boundary (that is, the third data subscript boundary) is calculated, and the data subscript start boundary in the third data subscript boundary is defined as cacheNoMin3, and the data subscript end boundary is defined as cacheNoMax3. cacheNoMin3 = ((pageNo-1)×pageSize / cacheSize)+1, cacheNoMax3 = ((pageNo×pageSize-1) / cacheSize)+1.
[0089] S103: Acquire a cache data list corresponding to the cache page number, and determine a first data index range corresponding to the cache data list.
[0090] In an embodiment of the present application, the cache page number can be used as a key to obtain the corresponding cache data list from the cache resource, and then the data subscript range of the cache data list (i.e., the first data subscript range) is determined. The first data subscript range represents the data subscript range of the data object in the cache data list.
[0091] In one possible implementation, since the cache page number may be one or multiple consecutive cache pages, the cache data lists of multiple cache page numbers can be obtained simultaneously using concurrent threads. In this regard, an embodiment of the present application provides a paging cache method, wherein in step S103, "obtaining the cache data list corresponding to the cache page number" can be performed using the following steps:
[0092] When there are multiple cache page numbers, use concurrent threads to obtain the cache data list corresponding to each cache page number.
[0093] In an embodiment of the present application, if there are multiple cache page numbers, a thread can be assigned to each cache page number, and multiple threads can be executed concurrently, while obtaining a cache data list corresponding to each cache page number.
[0094] In a possible implementation, for query requests that do not hit the cache, the corresponding original data list can be obtained from the database and cached as a cached data list, so that the next time the same query request hits the cache. Figure 3 , Figure 3 This is another partial flow chart of a paging cache method provided by an embodiment of the present application. Figure 3 As shown, an embodiment of the present application provides a paging cache method, wherein "obtaining a cache data list corresponding to a cache page number" in step S103 may include steps S301 to S303, and these steps are described in detail below.
[0095] S301, query whether there is a cache data list in the cache resource using the cache page number; if so, execute step S302; if not, execute step S303.
[0096] In an embodiment of the present application, the cache page number is used as a key to query the cache resource to determine whether a corresponding cache data list exists therein.
[0097] S302: Obtain a cached data list.
[0098] In an embodiment of the present application, if a cache data list corresponding to a cache page number exists in the cache resource, the cache data list is obtained.
[0099] S303: Calculate a fourth data subscript boundary according to the cache page number and the cache paging size, query and obtain an original data list in the database according to the fourth data subscript boundary, and cache the original data list to obtain a cached data list.
[0100] In an embodiment of the present application, if there is no corresponding cache data list in the cache resource, the corresponding data subscript boundary (i.e., the fourth data subscript boundary) is calculated, and the data subscript starting boundary in the fourth data subscript boundary is defined as queryNoMin, and the data subscript ending boundary is defined as queryNoMax, queryNoMin=(cacheNo-1)×cacheSize, queryNoMax=queryNoMin+cacheSize.
[0101] The database is queried with queryNoMin and queryNoMax to obtain rows of data objects whose indexes are between [queryNoMin, queryNoMax). This is used to form a corresponding raw data list, which is then cached to form a cached data list. This ensures that the next request for the same resource will hit the cache.
[0102] On this basis, since cached resources may be lost, it is necessary to count the actual data index range of the cached data list. Figure 4 , Figure 4 This is another partial flow chart of a paging cache method provided by an embodiment of the present application. Figure 4 As shown, an embodiment of the present application provides a paging cache method, wherein "determining the first data index range corresponding to the cached data list" in step S103 may include steps S401 to S403, and these steps are described in detail below.
[0103] S401, determining a data subscript starting boundary in a fourth data subscript boundary.
[0104] In the embodiment of the present application, a data subscript starting boundary in the fourth data subscript boundary is determined.
[0105] S402: Merge the cached data lists according to the cache page numbers, and count the total number of data items in the merged cached data lists.
[0106] In the embodiment of the present application, if there are multiple cache page numbers, the multiple cache data lists can be merged into one list in the order of the multiple cache page numbers, and the total number of data items in the list can be counted. The total number of data items is defined as dataSize. If dataSize is equal to 0, an empty list is directly returned.
[0107] S403: Determine the real data subscript end boundary using the data subscript start boundary and the total number of data items. The data subscript start boundary and the real data subscript end boundary constitute a first data subscript range.
[0108] In this embodiment of the present application, if dataSize is greater than 0, the actual data index end boundary of the cached data list (i.e., the actual data index end boundary) can be determined. The actual data index end boundary is defined as dataNoMax, and dataNoMax = queryNoMin + dataSize. In this case, the first data index range can be determined as [queryNoMin, dataNoMax).
[0109] S104: Calculate the second data subscript range using the query page size and the query page number, obtain a page data list of the target interface type from the cached data list according to the intersection of the first data subscript range and the second data subscript range, and output the page data list.
[0110] In this embodiment of the present application, the query paging size and the query page number can be used to calculate the data subscript range of the query request (i.e., the second data subscript range). This second data subscript range represents the data subscript range of the requested data object. The request starting subscript is defined as requestNoMin and the request ending subscript is defined as requestNoMax. Then, requestNoMin = (pageNo - 1) × pageSize, and requestNoMax = requestNoMin + pageSize. This yields the second data subscript range [requestNoMin, requestNoMax).
[0111] The intersection of [queryNoMin, dataNoMax) and [requestNoMin, requestNoMax) is taken, and the corresponding row records are intercepted from the cached data list according to the intersection to form a paginated data list of the target interface type, and the paginated data list is returned to the browser.
[0112] It should be noted that if the intersection of the first data subscript range and the second data subscript range is empty, an empty list is output.
[0113] Through the above description, a paging cache method provided by an embodiment of the present application can configure a cache paging size for the same data list. When facing a query request of the target interface type, the cache page number can be calculated based on the query paging size, query page number and cache paging size to obtain the cache data list and determine the corresponding data index range. The query paging size and query page number are used to calculate the data index range to be queried, and the paging data list is intercepted from the cache data list with the intersection of the data index range for output. This can realize that various interfaces share a cache, convert interface requests into cache internal operations, and save storage space to the greatest extent.
[0114] A paging cache method provided by an embodiment of the present application is described above. The following describes a device for executing the paging cache method.
[0115] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of a paging cache device provided in an embodiment of the present application. Figure 5 As shown, an embodiment of the present application provides a paging cache device, comprising:
[0116] The request receiving module 501 is used to receive a query request for a target data list, wherein the query request includes a query paging size and a query page number corresponding to the target interface type;
[0117] The cache processing module 502 is configured to calculate a cache page number based on the query page size, the query page number, and the configured cache page size, where the cache page size is configured for multiple interface types under the target data list; obtain a cache data list corresponding to the cache page number, and determine a first data index range corresponding to the cache data list;
[0118] The cache output module 503 is used to calculate the second data subscript range using the query page size and the query page number, obtain the page data list of the target interface type from the cache data list according to the intersection of the first data subscript range and the second data subscript range, and output the page data list.
[0119] In one possible implementation, the cache processing module 502 configures the cache page size in the following manner:
[0120] Obtain multiple initial page sizes corresponding to multiple interface types, with one initial page size corresponding to each interface type; use the lowest common multiple of the multiple initial page sizes as a candidate page size; determine whether the candidate page size is less than a preset page size threshold; if so, use the candidate page size as the cache page size; if not, select the cache page size from the multiple initial page sizes.
[0121] In one possible implementation, the cache processing module 502 for calculating the cache page number based on the query page size, the query page number, and the configured cache page size is specifically configured to:
[0122] Compare the query page size and the cache page size; if the query page size is smaller than the cache page size, determine whether the cache page size is divisible by the query page size; if so, process the cache page size, the query page size, and the query page number in a rounded-up manner to obtain the cache page number; if not, calculate a first data subscript boundary based on the query page number and the query page size, and process the first data subscript boundary and the cache page size in a rounded-up manner to obtain the cache page number; if the query page size is equal to the cache page size, use the query page number as the cache page number; if the query page size is larger than the cache page size, determine whether the query page size is divisible by the cache page size; if so, calculate a second data subscript boundary based on the query page number and the query page size, and calculate the cache page number using the second data subscript boundary and the cache page size; if not, calculate a third data subscript boundary based on the query page number and the query page size, and process the third data subscript boundary and the cache page size in a rounded-up manner to obtain the cache page number.
[0123] In a possible implementation, the cache processing module 502 for obtaining a cache data list corresponding to a cache page number is specifically configured to:
[0124] When there are multiple cache page numbers, use concurrent threads to obtain the cache data list corresponding to each cache page number.
[0125] In a possible implementation, the cache processing module 502 for obtaining a cache data list corresponding to a cache page number is specifically configured to:
[0126] Use the cache page number to query whether there is a cache data list in the cache resource; if so, obtain the cache data list; if not, calculate the fourth data subscript boundary according to the cache page number and the cache paging size, and query the original data list in the database according to the fourth data subscript boundary, and cache the original data list to obtain the cache data list.
[0127] In a possible implementation, the cache processing module 502 for determining the first data index range corresponding to the cached data list is specifically configured to:
[0128] Determine the data subscript starting boundary in the fourth data subscript boundary; merge the cache data list according to the cache page number, and count the total number of data items in the merged cache data list; use the data subscript starting boundary and the total number of data items to determine the real data subscript ending boundary, and the data subscript starting boundary and the real data subscript ending boundary constitute the first data subscript range.
[0129] It should be noted that the detailed functions of each module in the embodiment of the present application can be found in the corresponding disclosed part of the above-mentioned paging cache method embodiment, and will not be repeated here.
[0130] The present application also provides an electronic device. Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device in the embodiment of the present application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0131] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 602 or programs loaded from a storage device 608 into a random access memory (RAM) 603. When the electronic device is powered on, the RAM 603 also stores various programs and data required for the operation of the electronic device. The processing device 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0132] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Figure 6 The electronic device is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0133] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any of the paging cache methods provided in the embodiments of the present application.
[0134] An embodiment of the present application also provides a computer-readable storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any paging cache method provided in the embodiment of the present application.
[0135] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0136] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0137] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0138] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A paging cache method, characterized in that: The paging cache method includes: Receive a query request for a target data list, wherein the query request includes a query paging size and a query page number corresponding to the target interface type; Comparing the query page size with the cache page size; If the query page size is smaller than the cache page size, determining whether the cache page size is divisible by the query page size; if so, processing the cache page size, the query page size, and the query page number in a rounded-up manner to obtain a cache page number; if not, calculating a first data subscript boundary based on the query page number and the query page size, and processing the first data subscript boundary and the cache page size in a rounded-up manner to obtain the cache page number; When the query page size is equal to the cache page size, using the query page number as the cache page number; If the query page size is larger than the cache page size, determine whether the query page size is divisible by the cache page size; if so, calculate a second data subscript boundary based on the query page number and the query page size, and calculate the cache page number using the second data subscript boundary and the cache page size; if not, calculate a third data subscript boundary based on the query page number and the query page size, and round the third data subscript boundary and the cache page size to obtain the cache page number, where the cache page size is the same page size uniformly configured for multiple interface types under the target data list; Obtaining a cache data list corresponding to the cache page number, and determining a first data subscript range corresponding to the cache data list; Calculating a second data subscript range using the query paging size and the query page number, intercepting a paging data list of the target interface type from the cached data list according to the intersection of the first data subscript range and the second data subscript range, and outputting the paging data list; The configuration method of the cache paging size specifically includes: Acquire multiple initial page sizes corresponding to the multiple interface types, where one interface type corresponds to one initial page size; taking the least common multiple of the plurality of initial page sizes as a candidate page size; Determining whether the candidate page size is smaller than a preset page size threshold, where the page size threshold is determined based on the size of a single data block of a cache service; If so, using the candidate page size as the cache page size; If not, an initial page size that is divisible by the largest initial page size is selected from the multiple initial page sizes as the cache page size.
2. The paging cache method according to claim 1, wherein: The obtaining of the cache data list corresponding to the cache page number includes: In the case where there are multiple cache page numbers, a concurrent thread is used to obtain the cache data list corresponding to each cache page number.
3. The paging cache method according to claim 1, wherein: The obtaining of the cache data list corresponding to the cache page number includes: Querying the cache resource using the cache page number to determine whether the cache data list exists; If so, obtain the cache data list; If not, a fourth data subscript boundary is calculated according to the cache page number and the cache paging size, and an original data list in the database is obtained by querying according to the fourth data subscript boundary, and the original data list is cached to obtain the cached data list.
4. The paging cache method according to claim 3, wherein: The determining the first data subscript range corresponding to the cached data list includes: Determining a data subscript starting boundary in the fourth data subscript boundary; Merging the cache data lists according to the cache page numbers, and counting the total number of data items in the merged cache data lists; The data subscript starting boundary and the total number of data items are used to determine the real data subscript ending boundary, and the data subscript starting boundary and the real data subscript ending boundary constitute the first data subscript range.
5. A paging cache device, characterized in that: The paging cache device includes: A request receiving module, configured to receive a query request for a target data list, wherein the query request includes a query paging size and a query page number corresponding to the target interface type; A cache processing module is configured to compare the query page size with the cache page size; if the query page size is smaller than the cache page size, determine whether the cache page size is divisible by the query page size; if so, process the cache page size, the query page size, and the query page number in a rounded-up manner to obtain a cache page number; if not, calculate a first data subscript boundary based on the query page number and the query page size, and process the first data subscript boundary and the cache page size in a rounded-up manner to obtain the cache page number; if the query page size is equal to the cache page size, use the query page number as the cache page number; if the query page size is larger than the cache page size, calculate the cache page number. In the case of a paging size, determine whether the query page size is divisible by the cache page size; if so, calculate a second data subscript boundary based on the query page number and the query page size, and calculate the cache page number using the second data subscript boundary and the cache page size; if not, calculate a third data subscript boundary based on the query page number and the query page size, and process the third data subscript boundary and the cache page size in a rounded manner to obtain the cache page number, where the cache page size is the same page size uniformly configured for multiple interface types under the target data list; obtain a cache data list corresponding to the cache page number, and determine a first data subscript range corresponding to the cache data list; a cache output module, configured to calculate a second data subscript range using the query paging size and the query page number, intercept the paging data list of the target interface type from the cached data list according to the intersection of the first data subscript range and the second data subscript range, and output the paging data list; The configuration method of the cache paging size in the cache processing module specifically includes: Acquire multiple initial page sizes corresponding to the multiple interface types, where one interface type corresponds to one initial page size; taking the least common multiple of the plurality of initial page sizes as a candidate page size; Determining whether the candidate page size is smaller than a preset page size threshold, where the page size threshold is determined based on the size of a single data block of a cache service; If so, using the candidate page size as the cache page size; If not, an initial page size that is divisible by the largest initial page size is selected from the multiple initial page sizes as the cache page size.
6. A computer program product, characterized in that The method comprises computer-readable instructions, which, when executed on an electronic device, enable the electronic device to implement the paging cache method according to any one of claims 1 to 4.
7. An electronic device, characterized in that: comprising at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program so as to enable the electronic device to implement the paging cache method according to any one of claims 1 to 4.
8. A computer storage medium, characterized in that The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the paging cache method according to any one of claims 1 to 4.
Citation Information
Patent Citations
List paging method, device and electronic equipment
CN108153847A
Paging query method and device, equipment and medium
CN117609245A