Business data query method and device, electronic equipment and readable storage medium
By using cache identifiers and the page number to be queried to retrieve paginated records from the pre-stored cache when the data query request is not the first pagination request, the problems of poor performance of deep pagination and insufficient database stability are solved, and efficient data location and resource utilization are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JIZHI DIGITAL TECH CO LTD
- Filing Date
- 2026-04-08
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies suffer from significant positioning overhead during deep pagination. In high-concurrency scenarios, the database is continuously subjected to complex query impacts, and computing resources are repeatedly consumed on demand, resulting in poor performance, insufficient stability, and low resource utilization of deep pagination.
When the data query request is not the first pagination request, the cache identifier and the page number to be queried are obtained through parameter extraction processing. Based on the cache identifier and the page number to be queried, the pagination record is queried in the pre-stored cache to obtain the data range information, thus avoiding the repeated execution of complex query conditions.
It improves the reuse rate of computing resources, enhances query response speed in deep pagination scenarios, strengthens database stability in high-concurrency environments, and improves resource utilization efficiency.
Smart Images

Figure CN122489573A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data query technology, and in particular to a business data query method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] When providing pagination query interfaces for batch data, traditional methods such as pagination based on offsets (OFFSET) or cursors (maxId) have inherent drawbacks such as a sharp drop in performance, excessive database pressure, and repeated consumption of computing resources in deep pagination and high-concurrency scenarios. In existing technologies, to address the performance issues of deep pagination, cursor pagination based on ordered fields (such as maxId) is usually used to avoid offset scanning. However, this method still suffers from input / output (I / O) losses during deep positioning.
[0003] However, existing technologies suffer from poor performance, instability, and low resource utilization due to high positioning costs during deep pagination, continuous pressure on the database from complex queries in high-concurrency scenarios, and repeated consumption of computing resources on demand. Summary of the Invention
[0004] In view of this, embodiments of this disclosure provide a business data query method, apparatus, electronic device, and readable storage medium to solve the problems in the prior art, such as poor performance, insufficient stability, and low resource utilization caused by large positioning loss during deep pagination, continuous complex query impact on the database in high-concurrency scenarios, and repeated consumption of computing resources on demand.
[0005] A first aspect of this disclosure provides a business data query method, comprising: when the data query request is not the first pagination request, performing parameter extraction processing on the data query request to obtain a cache identifier and a page number to be queried; performing pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried to obtain pagination records; and performing data range information acquisition processing on the pagination records to obtain the target data corresponding to the data query request.
[0006] In some embodiments, before performing pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried to obtain the paginated records, the method further includes: if the data query request is the first pagination request, performing query condition parsing processing on the data query request to obtain the first pagination query conditions; performing identifier set acquisition processing on the preset business database based on the first pagination query conditions to obtain the target data entry identifier set; performing pagination pre-calculation processing on the target data entry identifier set and the preset single-page data volume to obtain the pagination structure; performing cache identifier generation processing on the data query request to obtain the session cache identifier; and performing associated storage processing on the session cache identifier and the pagination structure to obtain the pre-stored cache.
[0007] In some embodiments, a cache identifier generation process is performed on the data query request to obtain a session cache identifier, including: extracting the interface identifier from the data query request to obtain an interface identifier; extracting the request identifier from the data query request to obtain a request identifier; extracting the caller identifier from the data query request to obtain a caller identifier; and combining the interface identifier, request identifier, and caller identifier to obtain a session cache identifier.
[0008] In some embodiments, the session cache identifier and the pagination structure are associated and stored to obtain a pre-stored cache, including: extracting the pagination page number from the pagination structure to obtain the pagination record page number; constructing a composite index from the session cache identifier and the pagination record page number to obtain a target index key; and persistently writing the session cache identifier and the pagination structure based on the target index key to obtain the pre-stored cache.
[0009] In some embodiments, data range information acquisition processing is performed on paginated records to obtain target data corresponding to the data query request, including: extracting a start identifier from the paginated records to obtain a start identifier; extracting an end identifier from the paginated records to obtain an end identifier; and performing range query processing on a preset business database based on the start identifier and the end identifier to obtain target data corresponding to the data query request.
[0010] In some embodiments, before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: performing pagination parameter extraction processing on the data query request to obtain a single-page data volume parameter; and performing parameter over-limit response processing on the data query request to obtain a parameter error message when the single-page data volume parameter is greater than a preset single-page data volume threshold.
[0011] In some embodiments, before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: performing cache identifier validity verification processing on the data query request to obtain the cache identifier validity verification result; and performing exception response processing on the data query request to obtain cache error message when the cache identifier validity verification result is invalid.
[0012] A second aspect of this disclosure provides a business data query apparatus, comprising: a first processing module, configured to perform parameter extraction processing on a data query request to obtain a cache identifier and a page number to be queried when the data query request is not the first pagination request; a second processing module, configured to perform pagination record query processing on a pre-stored cache based on the cache identifier and the page number to be queried to obtain pagination records; and a third processing module, configured to perform data range information acquisition processing on the pagination records to obtain the target data corresponding to the data query request.
[0013] A third aspect of this disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0014] A fourth aspect of this disclosure provides a readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0015] The beneficial effects of this disclosed embodiment compared with the prior art are as follows: When the data query request is not the first pagination request, parameter extraction processing is performed on the data query request to obtain the cache identifier and the page number to be queried; based on the cache identifier and the page number to be queried, pagination record query processing is performed on the pre-stored cache to obtain the pagination record; data range information acquisition processing is performed on the pagination record to obtain the target data corresponding to the data query request. This allows for rapid location of the pagination record in the pre-stored cache using the cache identifier and the page number to be queried, avoiding repeated execution of complex query conditions, improving the reuse rate of computing resources, enhancing the query response speed in deep pagination scenarios, strengthening the stability of the database in high-concurrency environments, and improving resource utilization efficiency. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram illustrating an application scenario of an embodiment of this disclosure; Figure 2 This is a flowchart illustrating a business data query method provided in an embodiment of this disclosure; Figure 3 This is a flowchart illustrating another business data query method provided in this embodiment of the disclosure; Figure 4 This is a schematic diagram of the structure of a business data query device provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0018] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, so as to provide a thorough understanding of the embodiments of this disclosure. However, those skilled in the art will understand that this disclosure may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this disclosure with unnecessary detail.
[0019] It should be noted that the user information (including but not limited to terminal device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0020] A business data query method and apparatus according to an embodiment of the present disclosure will now be described in detail with reference to the accompanying drawings.
[0021] Figure 1 This is a schematic diagram illustrating an application scenario of an embodiment of this disclosure. The application scenario may include terminal devices 1, 2, and 3, server 4, and network 5.
[0022] Terminal devices 1, 2, and 3 can be hardware or software. When terminal devices 1, 2, and 3 are hardware, they can be various electronic devices with displays and supporting communication with server 4, including but not limited to smartphones, tablets, laptops, and desktop computers. When terminal devices 1, 2, and 3 are software, they can be installed in the aforementioned electronic devices. Terminal devices 1, 2, and 3 can be implemented as multiple software programs or software modules, or as a single software program or software module; this disclosure does not limit this. Furthermore, various applications can be installed on terminal devices 1, 2, and 3, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0023] Server 4 can be a server that provides various services, such as a backend server that receives requests sent by terminal devices with which it has established communication connections. This backend server can receive and analyze the requests sent by the terminal devices and generate processing results. Server 4 can be a single server, a server cluster consisting of several servers, or a cloud computing service center. This disclosure embodiment does not limit this.
[0024] It should be noted that server 4 can be either hardware or software. When server 4 is hardware, it can be various electronic devices that provide various services to terminal devices 1, 2, and 3. When server 4 is software, it can be multiple software programs or software modules that provide various services to terminal devices 1, 2, and 3, or it can be a single software program or software module that provides various services to terminal devices 1, 2, and 3. This disclosure does not limit the scope of the embodiments.
[0025] Network 5 can be a wired network using coaxial cable, twisted pair, and fiber optic connection, or it can be a wireless network that enables interconnection of various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), and Infrared. This disclosure does not limit the scope of the network.
[0026] Users can establish a communication connection with server 4 via network 5 through terminal devices 1, 2, and 3 to receive or send information. Specifically, server 4 can obtain data query requests through terminal devices 1, 2, and 3. If the data query request is not the first pagination request, it performs parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried; based on the cache identifier and the page number to be queried, it performs pagination record query processing on the pre-stored cache to obtain the pagination record; and it performs data range information acquisition processing on the pagination record to obtain the target data corresponding to the data query request.
[0027] It should be noted that the specific types, quantities, and combinations of terminal devices 1, 2, and 3, server 4, and network 5 can be adjusted according to the actual needs of the application scenario, and this disclosure embodiment does not impose any restrictions on this.
[0028] Figure 2 This is a flowchart illustrating a business data query method provided in an embodiment of this disclosure. Figure 2 Business data query methods can be provided by Figure 1 The server executes this. For example... Figure 2 As shown, the business data query method includes: S201, if the data query request is not the first pagination request, perform parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried.
[0029] Specifically, a data query request can be initiated by a downstream system to a data provider system, and can be used to obtain the pagination results of business data under specific query conditions; in non-first pagination scenarios, this data query request can be used to provide the key parameters necessary to perform subsequent data location operations.
[0030] A non-first pagination request can be a pagination request made by a downstream system after receiving a response to the first pagination request for the same query conditions. This response may include context information for subsequent pagination.
[0031] Parameter extraction processing can be a data processing procedure that parses and obtains specific parameters from a received data query request. This parameter extraction processing can be used to identify and separate information in the data query request used to locate cached records and determine the target data page, obtaining the cache identifier and the page number to be queried. The cache identifier can be a string used to uniquely identify a specific query session and its pre-computed result set. The cache identifier can be a composite key, which can be generated by combining elements such as interface identifier, global request identifier, and downstream system identifier. This can be used as the primary key to access the pre-computed pagination record table, ensuring data isolation between different query sessions and providing an index basis for subsequent data location. The cache identifier can be generated when processing the first pagination request and can be returned to the downstream system with the first pagination response. The downstream system must carry this identifier in subsequent non-first pagination requests.
[0032] The page number to be queried can be the sequence number of the data page that the downstream system expects to retrieve. This page number can be an integer value representing the pagination order. It can be used to indicate the page number and position information from the pre-calculated pagination records from which the system needs to retrieve data, thereby obtaining the specific data range corresponding to that page.
[0033] Furthermore, parameter extraction processing can specifically involve parsing parameters named "cache_key" and "page number" from the query string or request body of a Hypertext Transfer Protocol (HTTP) request. Upon receiving a non-first pagination request, the request format can be verified, and the parameter parser can be invoked to extract and convert the original parameter values in the data query request into a cache identifier string and an integer value for the page number to be queried, according to predefined parameter mapping rules. For example, for a GET request carrying the query parameter "cache_key=voucher_req123_clientA&page=5", the cache identifier "voucher_req123_clientA" and the page number "5" to be queried can be obtained through parameter extraction processing.
[0034] In this embodiment, when the data query request is not the first pagination request, parameter extraction processing is performed on the data query request. By parsing the query string or request body of the HTTP request, parameter values are extracted according to predefined parameter mapping rules to obtain the cache identifier and the page number to be queried. This enhances the parameter identification and extraction capability of non-first pagination requests, improves the accuracy and efficiency of obtaining the cache identifier and the page number to be queried, and provides a reliable index basis for subsequent data location operations.
[0035] S202, based on the cache identifier and the page number to be queried, perform pagination record query processing on the pre-stored cache to obtain the pagination record.
[0036] Specifically, the pre-store cache can be a data structure used to store pagination information of the query result set. The form of the pre-store cache can be a pagination record table in a relational database. The pre-store cache can be used to store the mapping relationship between all page numbers calculated during the first query and their corresponding data record identifier ranges, providing the basis for subsequent pagination queries. The pre-store cache can be established by sharding the full set of data identifiers according to the page size and writing them to the pagination record table when the first query is performed and the data volume exceeds the size of a single page. The pre-store cache can be managed by table partitioning based on date to control the data volume of a single table, and a data cleanup mechanism can be set.
[0037] Furthermore, the pagination record query process can be a data retrieval process that searches for the corresponding record in the storage system based on a given key-value pair. This pagination record query process can use the cache identifier and the page number to be queried as a composite query condition to retrieve the start data identifier and end data identifier corresponding to the target page number from the pre-stored cache, thereby obtaining the paginated record.
[0038] The pagination record can be a record containing data range information corresponding to the target page number. The form of the pagination record can include a start identifier and an end identifier. The pagination record can be used to provide the key range conditions required to obtain a complete page of data from the business database. The pagination record can be obtained by performing a query operation on the pre-stored cache, and its content can come from the pre-calculated results during the first query.
[0039] For example, pagination record query processing can specifically involve executing a parameterized query through the database client. This query statement could be "SELECT start_id, end_id FROM page_cache_table WHERE cache_key=? AND page_no=?", where the question marks can be filled with the received cache identifier and the actual value of the page number to be queried. In financial voucher data synchronization, after obtaining the cache identifier "voucher_req123_clientA" returned by the initial query, if it's necessary to retrieve page 500, this non-initial request can be received, retrieving the cache identifier and the page number 500 to be queried. Based on this cache identifier and page number 500, a query can be initiated to the pagination record table "page_cache_20241120" which is partitioned by day. The pagination record query can be performed using the cache_key, end_id, and page_no values established on this pagination record table. The page_no) composite index locates the target record and retrieves the starting voucher entry identifier (ID) "499001" and the ending voucher entry ID "500000" stored in that target record. This page record is the key range condition required to subsequently retrieve the complete 500th page of data from the master voucher table.
[0040] This application embodiment performs pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried. By using the cache identifier and the page number to be queried as composite query conditions, the start data identifier and end data identifier corresponding to the target page number are efficiently retrieved from the pre-stored cache to obtain the paginated record. This enhances the data location capability of subsequent pagination requests, improves the query response speed and stability of pagination at any depth, and reduces the computational pressure on the database caused by repeatedly executing complex queries.
[0041] S203, perform data range information acquisition processing on the paginated records to obtain the target data corresponding to the data query request.
[0042] Specifically, the data range information acquisition process can be a data processing procedure that extracts the start and end values of the data identifier corresponding to the currently requested page number from the pagination records. This data range information can be used to identify the specific position range of the target data in the ordered result set, which can then be used to construct a data range query statement to replace the filtering based on the original complex query conditions. This data range information can be obtained by querying the pagination record table and using the cached primary key and the requested page number as query conditions.
[0043] The target data can be a complete set of business data records that meet the original query conditions and are located within a specified page number, which needs to be returned to the requester. The acquisition of this target data can bypass the repeated parsing and evaluation of the original complex query conditions and only rely on the pre-generated pagination structure information.
[0044] For example, after obtaining the data range information, a range query statement can be constructed based on the start and end values for the primary key or ordered index field of the business data table. For instance, the BETWEEN operator in Structured Query Language (SQL) can be used. This query statement can leverage the ordered nature of the database index to locate and retrieve all data records between the start and end values with near constant time efficiency. In financial voucher data queries, after retrieving the first page of data and its corresponding cached primary key, the 120th page of data can be requested. The cached primary key and page number can be parsed from the request parameters, allowing a query of the paginated record table for the current day. This can be achieved by executing an efficient index query: "SELECT start_id, end_id FROM page_cache_20241120 WHERE cache_key='voucher_pg_req_xyz456_client_002' AND..." By setting `page_number=120`, we can obtain the starting ID of page 120 as 119001 and the ending ID as 120000. Then, we can construct and execute a range query "SELECT * FROM voucher_items WHERE voucher_item_id BETWEEN 119001 AND 120000" to retrieve all voucher entries within this ID range from the business data table. This record is the target data corresponding to this request.
[0045] This application embodiment obtains data range information from pre-calculated and persistently stored pagination records, extracts the start and end values of the data identifier corresponding to the currently requested page number from the pagination records, constructs a range query statement based on this data range information, and obtains a complete set of business data records that meet the original query conditions and are located within the specified page number as the target data. This eliminates the query performance bottleneck in deep pagination scenarios; achieves stable and predictable low-latency response; reduces the computational overhead caused by the database repeatedly parsing complex query conditions; and improves the interface performance and stability of batch data pagination queries.
[0046] According to the technical solution provided in this disclosure, when the data query request is not the first pagination request, parameter extraction processing is performed on the request. By parsing the query string or request body of the HTTP request, parameter values are extracted according to predefined parameter mapping rules to obtain the cache identifier and the page number to be queried. Based on the cache identifier and the page number to be queried, pagination record query processing is performed on the pre-stored cache. Using the cache identifier and the page number to be queried as composite query conditions, the start data identifier and end data identifier corresponding to the target page number are retrieved from the pre-stored cache to obtain the pagination record. Data range information acquisition processing is performed on the pagination record, and the page number corresponding to the current request is extracted from the pagination record. The corresponding data identifier start and end values are used to construct a range query statement based on this data range information. This yields a complete set of business data records that meet the original query conditions and are located within the specified page number as the target data. This enhances the parameter identification and extraction capabilities for non-first pagination requests; improves the accuracy and efficiency of obtaining cache identifiers and the page number to be queried; enhances the data location capabilities for subsequent pagination requests; improves the query response speed and stability for pagination at any depth; avoids repeatedly executing complex query conditions; improves the reuse rate of computing resources; enhances the query response speed in deep pagination scenarios; enhances the stability of the database in high-concurrency environments; and improves resource utilization efficiency.
[0047] In some embodiments, before performing pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried to obtain the paginated records, the method further includes: if the data query request is the first pagination request, performing query condition parsing processing on the data query request to obtain the first pagination query conditions; performing identifier set acquisition processing on the preset business database based on the first pagination query conditions to obtain the target data entry identifier set; performing pagination pre-calculation processing on the target data entry identifier set and the preset single-page data volume to obtain the pagination structure; performing cache identifier generation processing on the data query request to obtain the session cache identifier; and performing associated storage processing on the session cache identifier and the pagination structure to obtain the pre-stored cache.
[0048] Specifically, the first pagination request can be the first pagination data retrieval process initiated by the downstream system for specific query conditions. This first pagination request can be used to start a new query session, and it may not carry a cache identifier.
[0049] Furthermore, parsing query conditions for data query requests can be a data processing procedure that extracts and structures query parameters from the received request. This parsing process can be used to obtain the initial pagination query conditions, which can be used to determine the range of data to be retrieved in this query session. This parsing process can support nested query conditions and can convert them into database-executable query language fragments.
[0050] Furthermore, the process of obtaining the identifier set of the preset business database based on the initial pagination query conditions can be described as a data processing procedure that constructs and executes database operation instructions that can be used to query the primary key identifiers of target data based on the parsed query conditions. This identifier set acquisition process can be used to obtain the identifier set of target data entries. This identifier set of target data entries can be a set of identifiers of all business data records that meet the query conditions, which can provide a data foundation for subsequent pagination calculations. This identifier set acquisition process can be achieved by leveraging the ordered nature of the database index and by executing structured query language statements, thereby reducing the input / output load of the database and the amount of data transmitted over the network.
[0051] Furthermore, the pagination pre-calculation process, which involves dividing the target data entry identifier set and the preset single-page data volume into several consecutive subsets of equal or smaller size based on the single-page data volume, and calculating the start and end identifiers for each subset, can be used to obtain a pagination structure. This pagination structure can represent the processing information of the query result set being divided into multiple logical pages. This pagination pre-calculation process can be completed at the application service layer. It can determine the total number of pages based on the total number of records in the target data entry identifier set and the preset single-page data volume through integer division and modulo operations, and then divide the data range of each page by sequentially traversing the identifier set. The preset single-page data volume can be a predefined upper limit for the number of data records returned in each pagination, or a parameter specified by the request. This preset single-page data volume can be used as a baseline parameter for the pagination pre-calculation process. This allows us to determine how many shards to divide the target data entry identifier set into, control the amount of data returned in a single query, and avoid network transmission and memory pressure caused by excessively large result sets. The pagination structure can represent the processing information that the query result set is divided into multiple logical pages. The form of the pagination structure can include the total number of pages, the start data identifier and end data identifier corresponding to each page number. This pagination structure can be used to provide a location data index for all subsequent pagination requests based on the same query conditions, thereby replacing the original complex query conditions and enabling the retrieval of data ranges at any depth of pagination through simple key-value queries. This pagination structure can be generated by dividing the target data entry identifier set into several consecutive subsets of equal size or with the last one possibly being smaller, based on the size of the single page data, and calculating the start identifier and end identifier corresponding to each subset. This pagination structure can be associated with the session cache identifier and persistently stored in the pre-storage cache.
[0052] Furthermore, the cache identifier generation process for data query requests can be a data processing procedure that creates a globally unique string identifier for the current query session. This cache identifier generation process can be used to obtain a session cache identifier. The generation rule for this session cache identifier can combine the interface identifier, the unique request identifier of this request, and the downstream client identifier to ensure its uniqueness and session isolation in a distributed environment. The request identifier in this generation rule can be generated by the gateway or application entry middleware and run through the entire call chain. The session cache identifier can be a globally unique string identifier created for the current query session. The form of this session cache identifier can be a composite key generated by combining the interface identifier, the unique request identifier of this request, and the downstream client identifier to ensure its uniqueness and session isolation in a distributed environment. This session cache identifier can be used as a unique primary key to access the pre-stored cache to ensure data isolation between different query sessions and to provide an index for subsequent pagination requests. This session cache identifier can be generated during the first pagination request and can be returned to the downstream client with the first pagination response. The downstream client can carry this identifier in subsequent non-first pagination requests.
[0053] Associating the session cache identifier with the pagination structure involves persistently storing the calculated pagination structure information, including the data identifier range corresponding to each page number, with the session cache identifier as the association key, on a specific storage medium. This association storage process can be used to obtain a pre-stored cache, which can provide a location data index for all subsequent pagination requests based on the same query conditions. This storage medium can be a dedicated table in a relational database, on which an index can be created using the session cache identifier and page number as a composite primary key, enabling millisecond-level queries. Alternatively, the storage medium can be a distributed cache, where the pagination structure is serialized and stored with the session cache identifier as the key. When storing the pagination structure in the database table, batch insert operations can be used to improve performance. The table structure includes, but is not limited to, fields such as cache identifier, page number, start data identifier, and end data identifier.
[0054] For example, a downstream client needs to retrieve all general ledger voucher data for December 2023. Its initial query condition can be that the accounting period equals "202312" and the voucher type equals "general ledger". After parsing this condition, a query can be initiated to the business database to obtain all voucher entry identifiers that meet the conditions. Assuming a total of 11 million identifiers are obtained, and the preset single page data volume can be 1,000 records, the 11 million identifiers can be divided into 11,000 pages by calculation. Session cache identifiers such as "voucher_req123_clientA" can be generated. The correspondence between "voucher_req123_clientA" and the start and end identifiers of each of the above 11,000 pages can be recorded in a database table named page_cache, thereby completing the construction of the pre-stored cache.
[0055] According to the technical solution provided in this disclosure, when the data query request is the first pagination request, the query conditions of the data query request are parsed to obtain the first pagination query conditions. Based on the first pagination query conditions, the target data entry identifier set is obtained by obtaining the identifier set of the preset business database. The pagination pre-calculation processing of the target data entry identifier set and the preset single-page data volume is performed to obtain the pagination structure. The cache identifier generation processing of the data query request is performed to obtain the session cache identifier. The session cache identifier and the pagination structure are associated and stored to obtain the pre-stored cache, thereby establishing a lightweight pre-stored cache index. This avoids the continuous pressure on the database caused by deep pagination under high concurrency, improves the interface response speed and stability, and realizes the reuse of computing resources for one-time calculation.
[0056] In some embodiments, a cache identifier generation process is performed on the data query request to obtain a session cache identifier, including: extracting the interface identifier from the data query request to obtain an interface identifier; extracting the request identifier from the data query request to obtain a request identifier; extracting the caller identifier from the data query request to obtain a caller identifier; and combining the interface identifier, request identifier, and caller identifier to obtain a session cache identifier.
[0057] Specifically, the interface identifier can be a string or code used to uniquely identify a specific query interface exposed by the data provider. This interface identifier can be used to distinguish different data query endpoints, and thus can be used as a component of the session cache identifier to ensure that query sessions of different interfaces and their pre-calculated results are isolated from each other and avoid cache key conflicts. This interface identifier can be derived from the interface configuration or routing rules predefined by the data provider. When a data query request is received, it can be extracted based on the Uniform Resource Locator path or protocol information of the request.
[0058] In addition, the request identifier can be a globally unique identifier generated in a single request processing chain. This request identifier can be used to track and distinguish an independent request session, thus serving as a core component of the session cache identifier. This ensures that even if the same caller makes multiple independent queries to the same interface, the generated cache key is unique, thereby establishing an independent pre-computation context for each query session. This request identifier can be generated by the gateway, interceptor, or request receiving module at the system entry point and can be passed to subsequent processing along with the request context.
[0059] In addition, the caller identifier can be an identifier used to identify the downstream client that initiated the data query request. This caller identifier can be used to characterize the identity information of the request source, and thus can be used as a component of the session cache identifier to achieve data access isolation between different downstream clients, prevent one client's query cache from being misused or overwritten by another client, and ensure data security and call standardization. This caller identifier can be derived from the authentication information carried in the data query request, such as the application interface key, application identifier, or client identifier obtained through request header parsing.
[0060] Furthermore, the combination processing can be a data processing procedure that connects or concatenates multiple independent strings into a composite string according to predetermined rules and formats. This combination processing can be used to generate a structured unique key containing multidimensional information, which can then be used as the primary key for subsequent storage and retrieval of pre-calculated results. The input to this combination processing can be the extracted interface identifier, request identifier, and caller identifier, and the output can be the session cache identifier.
[0061] For example, in the financial voucher data open platform, the interface identifier "voucher", the request identifier "req_xyz456" and the caller identifier "client_report" can be extracted and combined to generate the session cache identifier "voucher_req_xyz456_client_report". The pagination structure and the session cache identifier are then associated and stored in the pre-stored cache table.
[0062] According to the technical solution provided in this disclosure, by performing interface identifier extraction processing on the data query request, the interface identifier is extracted based on the Uniform Resource Locator (URL) path or protocol information of the request. Then, request identifier extraction processing is performed on the data query request, obtaining the request identifier from the generated globally unique identifier. Finally, caller identifier extraction processing is performed on the data query request, parsing the caller identifier from authentication information or request headers. The interface identifier, request identifier, and caller identifier are combined according to predetermined rules to form a composite string, thus obtaining the session cache identifier. This enhances the uniqueness of the cache identifier generation and the multi-dimensional information integration capability; improves the accuracy of cache isolation between different interfaces, different sessions, and different callers; and enhances the level of cache key conflict avoidance and data access security.
[0063] In some embodiments, the session cache identifier and the pagination structure are associated and stored to obtain a pre-stored cache, including: extracting the pagination page number from the pagination structure to obtain the pagination record page number; constructing a composite index from the session cache identifier and the pagination record page number to obtain a target index key; and persistently writing the session cache identifier and the pagination structure based on the target index key to obtain the pre-stored cache.
[0064] Specifically, the pagination record page number can be a sequence number extracted from the pagination structure that can be used to identify a specific data page. The pagination record page number can be a number representing the position of the data page in the pagination sequence. The pagination record page number can be used together with the session cache identifier to form a unique index key, thereby allowing querying the data range information of a specific page. The pagination record page number can be derived from the pagination structure. The pagination page number extraction process can be implemented by traversing the list of page information contained in the pagination structure, reading and recording the page number value associated with each page entry one by one.
[0065] In addition, the target index key can be a composite key used to quickly retrieve specific page records in the storage system. The target index key can be a composite key composed of the session cache identifier and the page number of the page record. This target index key can be used as the sole basis for locating a specific page record in the page record table, thereby achieving millisecond-level query performance. The target index key can be composed of the session cache identifier and the page number of the page record through string concatenation or specific encoding rules. The composite index construction process can be a data processing process that uses the session cache identifier as a prefix, the page number of the page record as a suffix, and connects them with a specific delimiter to form a complete key string.
[0066] Furthermore, persistent write processing can be a data processing procedure that writes data to non-volatile storage media for long-term or subsequent access. This persistent write processing can be used to ensure that data still exists after system restart or service interruption, thereby saving the calculated paging structure and providing stable data location services for subsequent persistent paging sessions. The operation objects of this persistent write processing can be paging structure data and target index keys generated by index building processing.
[0067] For example, in the synchronization of financial voucher data, the pagination structure can be processed by extracting page numbers. For instance, 11,000 page entries can be traversed to obtain a sequence of page numbers from 1 to 11,000. The session cache identifier "voucher_req123_clientA" can be combined with each page number to form a composite index. By connecting these with underscores, a target index key in the form of "voucher_req123_clientA_120" can be obtained. Based on the target index key, the starting voucher entry identifier and ending voucher entry identifier corresponding to each page, as well as the target index key, can be persistently written to the pagination record database table for the current day through batch operations, thereby completing the establishment of the pre-stored cache.
[0068] According to the technical solution provided in this disclosure, by extracting page numbers from the pagination structure, extracting the page number value associated with each page entry by traversing the page information list, the page number of the pagination record is obtained. A joint index is constructed using the session cache identifier and the page number of the pagination record. A target index key is formed by string concatenation or a specific encoding rule. Based on this target index key, the session cache identifier and the pagination structure are persistently written, and the pagination data is written to a non-volatile storage medium to obtain a pre-stored cache. This enhances the associated storage capability of pagination records and cache identifiers; improves the index positioning efficiency of pagination queries; and enhances the reliability of pre-calculated result persistence and query performance.
[0069] In some embodiments, data range information acquisition processing is performed on paginated records to obtain target data corresponding to the data query request, including: extracting a start identifier from the paginated records to obtain a start identifier; extracting an end identifier from the paginated records to obtain an end identifier; and performing range query processing on a preset business database based on the start identifier and the end identifier to obtain target data corresponding to the data query request.
[0070] Specifically, the start identifier can be a data value in the pagination record used to identify the starting position of a certain page of data in the ordered result set. The start identifier can be in the form of the primary key value of the data record. This start identifier can be used to provide the starting boundary for subsequent range queries. When processing a data query request for the first time, the start identifier can be used to obtain the primary key set of the full data based on the query conditions, and can be used to perform sharding calculation based on the page size of the data query request, thereby determining the corresponding start primary key value for each page of data, and writing it as the start identifier along with the page number and cached primary key into the pagination record table. The start identifier extraction process can be implemented by performing a query operation on the pagination record table. This query can use the received cached primary key and the requested page number as conditions to retrieve the corresponding start identifier field value from the pagination record table.
[0071] For example, in a financial voucher query, if a downstream client requests data from page 120 and carries a valid cached primary key, it can execute the structured query language statement "SELECT start_id FROM page_cache WHERE cache_key=? AND page_no=?" to obtain the starting primary key identifier of that page's data in the voucher entry table.
[0072] Additionally, the end identifier can be a data value in the pagination record used to identify the end position of a certain page of data in the ordered result set. The form of the end identifier can be the primary key value of the data record. The end identifier can be used to provide the end boundary for subsequent range queries. The end identifier can be the end primary key value corresponding to each page of data determined during the sharding calculation. The end identifier extraction process can be achieved by performing a query operation on the pagination record table, using the cached primary key and the requested page number as conditions to retrieve the corresponding end identifier field value.
[0073] In addition, the preset business database can be a database system for storing core business entity data. The preset business database can be a relational database for storing financial voucher entries and can be used to provide business data records.
[0074] Range query processing can be a database query process that retrieves all data records falling between a specified start value and an end value based on an ordered index using conditions such as "BETWEEN ... AND ..." or ">= ... AND <= ...". This range query processing can be used to retrieve complete data for a specified page from a pre-calculated business database using a pre-calculated identifier range, without having to re-execute complex original query conditions. The structured query language statement form constructed by this range query processing can be "SELECT * FROM [business table name] WHERE [primary key field] BETWEEN [start identifier] AND [end identifier]". This range query processing can rely on the primary key index, avoiding full table scans or complex condition filtering, and improving the stability of high-performance data retrieval. The start identifier and end identifier can be used as upstream inputs to the range query processing to determine the data boundaries of the query.
[0075] For example, in a financial voucher query, after obtaining the start identifier 119001 and the end identifier 120000, you can construct and execute the query "SELECT * FROM voucher_items WHERE voucher_item_id BETWEEN 119001AND 120000" to obtain the complete data of 1,000 voucher entries on page 120 as the target data.
[0076] According to the technical solution provided in this disclosure, by extracting the start identifier of the pagination records, retrieving the start identifier from the pagination record table by executing a query based on the cached primary key and the requested page number, extracting the end identifier of the pagination records, retrieving the end identifier by retrieving the same condition, and performing a range query on the preset business database based on the start and end identifiers, a structured query language statement is constructed, and all data records falling within the specified range are retrieved by relying on the ordered index, thereby obtaining the target data corresponding to the data query request. This enhances the ability to extract data boundary identifiers from pagination records; improves the efficiency and stability of data querying based on a pre-calculated range; and reduces the computational overhead caused by the database repeatedly executing complex condition filtering.
[0077] In some embodiments, before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: performing pagination parameter extraction processing on the data query request to obtain a single-page data volume parameter; and performing parameter over-limit response processing on the data query request to obtain a parameter error message when the single-page data volume parameter is greater than a preset single-page data volume threshold.
[0078] Specifically, pagination parameter extraction processing can be a data processing procedure that parses parameters from data query requests to control pagination behavior. The single-page data volume parameter can be a numerical parameter indicating the number of data records the downstream client expects to retrieve in a single response. This single-page data volume parameter can control the amount of data returned in each pagination query and can serve as the basis for data sharding and pre-computation. This single-page data volume parameter can be specified by the downstream client in the request, for example, through the "size" or "page_size" parameter in a Hypertext Transfer Protocol request. This single-page data volume parameter can originate from the original data query request initiated by the downstream client and is part of the request parameters. The pagination parameter extraction processing can obtain the value of this parameter by parsing the Uniform Resource Locator query string or the Data Interchange Format (JSON) field in the request body.
[0079] In addition, the preset single-page data volume threshold can be a pre-set upper limit value in the configuration. This preset single-page data volume threshold can be used to limit the maximum amount of data that can be returned in a single query. This can serve as a protection mechanism to prevent downstream clients from specifying excessive single-page data volume due to accidental operation or malicious requests, thereby avoiding excessive query pressure on the database, excessive consumption of network bandwidth and memory resources, and ensuring the stability and performance of the system. This preset single-page data volume threshold can be part of the system configuration and can be preset according to database performance, network conditions and business needs.
[0080] The parameter over-limit response handling is a data processing process that interrupts the normal business process and generates and returns an error response when the system detects that the request parameters do not conform to the system rules. This parameter over-limit response handling can be used to intercept illegal or abnormal requests in a timely manner, preventing them from entering the core business logic and thus protecting the backend service. This parameter over-limit response handling can be triggered during the parameter validation phase, and its input can be the extracted single-page data volume parameter and a preset threshold.
[0081] Parameter error messages can be structured response data used to inform the requester that there are errors in its request parameters. These messages can provide a clear reason for the error, guide downstream clients to adjust their request parameters, and implement standardized interface calls. Parameter error messages can be generated by parameter over-limit response processing and can be returned to downstream clients as the target response.
[0082] For example, in a financial voucher data query, a downstream client can initiate a non-first pagination request, such as requesting to retrieve page 5 data, specifying a single-page data volume of 15,000 records in the request parameters. Upon receiving this request, pagination parameter extraction processing can be performed, parsing the single-page data volume parameter value of 15,000 from the request. This parameter value can be compared with a preset single-page data volume threshold. Assuming the preset threshold is 10,000 records, since 15,000 is greater than 10,000, it can be determined that the parameter exceeds the limit, thus triggering parameter limit exceedance response processing. Subsequent steps such as cache identifier extraction and database query can be skipped, and a parameter error message can be constructed, such as a Hypertext Transfer Protocol 400 status code response, with the response body including the error code and descriptive information, such as "Single-page data volume exceeds the maximum limit allowed by the system." This response can be immediately returned to the downstream client.
[0083] According to the technical solution provided in this disclosure, pagination parameters are extracted from data query requests, and the single-page data volume parameter is obtained by parsing the URL query string or JSON field of the request. If the single-page data volume parameter exceeds a preset single-page data volume threshold, a parameter over-limit response is initiated for the data query request, interrupting the normal business processing flow and generating and returning parameter error messages. This enhances the validity verification capability of pagination request parameters, improves the defense capability against abnormal or malicious requests, and ensures the stability and security of the backend database and network resources.
[0084] In some embodiments, before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: performing cache identifier validity verification processing on the data query request to obtain the cache identifier validity verification result; and performing exception response processing on the data query request to obtain cache error message when the cache identifier validity verification result is invalid.
[0085] Specifically, the cache identifier validity verification process can be a data processing procedure that verifies the cache identifier carried in the data query request. This cache identifier validity verification process can be used to ensure that subsequent pagination requests can safely locate the pre-calculated results established during the first query, and can serve as the basis for verifying the legality of the request. The cache identifier can be a string generated by the cache primary key generation process during the first pagination request, which can be returned to the downstream client and can be used to uniquely identify a query session and its pre-calculated result set. The cache identifier validity verification result can be a judgment result that characterizes whether the cache identifier has passed the verification.
[0086] Furthermore, the cache identifier validity verification process can specifically include checking whether the format of the cache identifier conforms to preset rules, checking whether the cache identifier exists in the pagination record table, and checking whether the query session associated with the cache identifier is still valid. By querying the pagination record table, it can be confirmed whether the pre-calculated record corresponding to the cache identifier exists. If it does not exist or has expired, it can be determined to be invalid.
[0087] In addition, the cache identifier validity verification process can also include consistency verification of request parameters. Consistency verification can be a data processing procedure that compares a small number of core query parameters carried in non-first pagination requests with the parameters used to build the cache during the first request. This consistency verification can be used to ensure that the query conditions on which all pagination requests are based remain consistent within the same query session. This can prevent downstream clients from tampering with query conditions during the pagination process and thus accessing unexpected data, thereby ensuring the accuracy and security of data queries. The benchmark for this consistency verification can be the information of the query parameters of the first request that has been recorded or hashed when generating the cache identifier. The query condition summary of the first request can be parsed from the cache identifier or queried based on the cache identifier and compared with the parameters in the current request. If they are inconsistent, the cache identifier validity verification result can also be determined to be invalid.
[0088] In addition, exception response handling can interrupt the normal business process and generate and return an error response when the cache identifier validity check result is invalid. This exception response handling can be used to avoid meaningless query operations on invalid cache identifiers, reduce the unnecessary consumption of database and computing resources. The cache error message can be a structured response data used to inform the requester that its cache identifier has a problem. The cache error message can be used to provide a clear error reason and guide downstream clients to correct the error. For example, the client can re-initiate the initial query to obtain a new valid cache identifier, thereby improving the robustness of the data query interface and the user experience.
[0089] According to the technical solution provided in this disclosure, by performing cache identifier validity verification on data query requests, the cache identifier's format, existence in the pagination record table, and validity period of the associated query session are checked, and request parameter consistency verification is performed to obtain the cache identifier validity verification result. If the verification result is invalid, an abnormal response is handled for the data query request, interrupting the normal business process and generating a cache error message. This enhances the validity and timeliness verification capabilities of the cache identifier; improves the accuracy and consistency guarantee level of pagination request parameters; reduces resource consumption caused by invalid cache identifiers; and enhances the robustness of interface calls and user experience.
[0090] All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of this disclosure, and will not be described in detail here.
[0091] Figure 3 This is a schematic diagram of another business data query method provided in an embodiment of this disclosure. For example... Figure 3 As shown, the business data query method includes: The system roles included in this disclosure are: Data provider system: The carrier of this invention, responsible for receiving requests, processing business logic, accessing the database, and returning results. This data provider system may include multiple functional modules.
[0092] Downstream systems: Data consumers, which can be used to call open interfaces provided by data providers.
[0093] Database: Stores business data (such as voucher data) and generated paginated record tables.
[0094] 1. Request reception and initial judgment The process corresponds to: from the starting node A to the decision node B.
[0095] The specific process is as follows: The request receiving module of the data provider system receives the query request (data query request) initiated by the downstream system through an open Application Programming Interface (API). This data query request includes, but is not limited to: query conditions (such as period=202312), pagination parameters (page number page_no, page size page_size). The system can then proceed to the decision-making logic.
[0096] 2. The path of the first page request processing flow (core: pre-computation and cache establishment) can be: B [Yes], step C, step D, judgment E, step F / step G, step H.
[0097] Step C involves generating a cached primary key: Since this is the first page request, the cached primary key generation module can be called to create a globally unique identifier for this query session. The generation rule is: {interface identifier}_{RequestId of this request}_{downstream system identifier}.
[0098] The RequestId can be generated in the request entry middleware (such as a gateway or interceptor) and persists throughout the entire call chain, ensuring uniqueness. Downstream system identifiers can be used for data isolation. The generation of this key establishes a namespace for all subsequent operations.
[0099] Step D can be used to query the full data ID: Based on the query conditions in the request, construct a Structured Query Language (SQL) statement that only queries the primary key ID (such as voucher_item_id) and execute it. For example: SELECT voucher_item_id FROM voucher_items WHERE accounting_period='202312' ORDER BY voucher_item_id ASC.
[0100] Step D only retrieves the ID, not all fields, reducing network transmission and database memory usage, and preparing the data foundation for subsequent pre-calculations.
[0101] Decision E and step F can be used for pagination decisions and pre-caching: Judgment: The total number of IDs obtained can be calculated.
[0102] If the total number of records exceeds `page_size`, the pre-computation and caching module can be invoked. This module partitions the entire ID set into shards based on `page_size`. For example, if the total data size N = 11,000 and `page_size` = 1000, then 11 pages are calculated, and the following is determined: Page 1: ID1-1000; Page 2: ID1001-2000; Page 11: ID10001-11000, etc.
[0103] Persistence: The pagination information is persisted to the pagination record table (page_cache). The core fields of this pagination record table structure may include: cache_key (cache primary key), page_no (page number), start_id (start ID), and end_id (end ID). A composite unique index with (cache_key, page_no) as the column can be created on this pagination record table to ensure the performance of subsequent queries. The table structure design is as follows: Table 1. Page Break Record Table
[0104] If the total number is less than or equal to page_size, proceed directly to steps G and H.
[0105] Steps G and H can be used to assemble and return the first page of data: regardless of whether pre-caching has been performed, the complete data of the first page needs to be returned.
[0106] If not pre-cached (step G, data volume less than one page), the complete data can be queried using all the obtained IDs.
[0107] If pre-cached (step G), the complete data can be retrieved using the start_id and end_id calculated for the first page.
[0108] The data query and assembly module can assemble the complete data retrieved into a response format and return the cache_key along with it to the downstream system (step H).
[0109] 3. The path for non-first page request processing flow (cache lookup and fast location) can be: B [No], judgment I, step J, step K, step H; or B [No], I [No], step L, step M.
[0110] To determine if I can be a cache primary key, for requests that are not on the first page, you can check whether the request parameters carry a valid cache_key.
[0111] Determining whether I [is], step J, and step K can provide a fast data location method based on caching: To query paginated records, you can execute an efficient SQL query based on the received `cache_key` and the requested `page_no`: `SELECT start_id, end_id FROM page_cache WHERE cache_key=? AND page_no=?`. Due to the presence of a composite index, this query is fast, taking only milliseconds.
[0112] Data Retrieval: After obtaining `start_id` and `end_id`, a range query can be constructed to retrieve the complete data: `SELECT * FROM voucher_items WHERE voucher_item_id BETWEEN ? AND ?`. This query can be performed using the primary key index. The original query conditions (such as `accounting_period='202312'`) can be added as additional validation conditions to prevent data inconsistencies in extreme cases.
[0113] Return result: The retrieved data is assembled and returned.
[0114] The judgment I [No], step L, and step M can be exception handling procedures: If the request does not carry a cache_key, it is determined to be an illegal request (such as when the downstream system attempts to directly jump to the deep page). At this time, the error message module can assemble clear exception information, such as "Missing pagination context, please start the query from the first page", and return it to the downstream system.
[0115] According to the technical solution provided in this disclosure, the full pagination location information is proactively pre-calculated and persisted during the first request for direct use in subsequent requests; a composite key structure of {interface identifier}{RequestId}{downstream system identifier} and its generation method are designed to ensure the global uniqueness, caller isolation, and request session independence of each query session cache; a method is defined to directly query the pagination record table and obtain the data ID range through (cache primary key, page number) key-value pairs, thereby enhancing the response speed and stability of deep pagination queries; the accuracy of cache isolation and session management in multi-user high-concurrency scenarios is improved; the computational overhead caused by repeated execution of complex queries in the database is reduced; stable and predictable low-latency response is achieved, and pagination records in the pre-stored cache are quickly located through cache identifier and page number to be queried, avoiding repeated execution of complex query conditions, improving the reuse rate of computing resources, improving the query response speed in deep pagination scenarios, enhancing the stability of the database in high-concurrency environments, and improving resource utilization efficiency.
[0116] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.
[0117] Figure 4 This is a schematic diagram of a business data query device provided in an embodiment of this disclosure. Figure 4 As shown, the business data query device includes: The first processing module 401 is used to extract parameters from the data query request when the data query request is not the first pagination request, and obtain the cache identifier and the page number to be queried. The second processing module 402 is used to perform pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried, so as to obtain the pagination record; The third processing module 403 is used to obtain data range information from the paginated records to get the target data corresponding to the data query request.
[0118] According to the technical solution provided in this disclosure, when the data query request is not the first pagination request, parameter extraction processing is performed on the request. By parsing the query string or request body of the HTTP request, parameter values are extracted according to predefined parameter mapping rules to obtain the cache identifier and the page number to be queried. Based on the cache identifier and the page number to be queried, pagination record query processing is performed on the pre-stored cache. Using the cache identifier and the page number to be queried as composite query conditions, the start data identifier and end data identifier corresponding to the target page number are retrieved from the pre-stored cache to obtain the pagination record. Data range information acquisition processing is performed on the pagination record, and the page number corresponding to the current request is extracted from the pagination record. The corresponding data identifier start and end values are used to construct a range query statement based on this data range information. This yields a complete set of business data records that meet the original query conditions and are located within the specified page number as the target data. This enhances the parameter identification and extraction capabilities for non-first pagination requests; improves the accuracy and efficiency of obtaining cache identifiers and the page number to be queried; enhances the data location capabilities for subsequent pagination requests; improves the query response speed and stability for pagination at any depth; avoids repeatedly executing complex query conditions; improves the reuse rate of computing resources; enhances the query response speed in deep pagination scenarios; enhances the stability of the database in high-concurrency environments; and improves resource utilization efficiency.
[0119] In some embodiments, the above-described business data query apparatus is further configured to: when the data query request is an initial pagination request, perform query condition parsing processing on the data query request to obtain initial pagination query conditions; perform identifier set acquisition processing on a preset business database based on the initial pagination query conditions to obtain a target data entry identifier set; perform pagination pre-calculation processing on the target data entry identifier set and a preset single-page data volume to obtain a pagination structure; perform cache identifier generation processing on the data query request to obtain a session cache identifier; and perform associated storage processing on the session cache identifier and the pagination structure to obtain a pre-stored cache.
[0120] In some embodiments, the process of generating a cache identifier for a data query request to obtain a session cache identifier is specifically used to: extract an interface identifier from the data query request to obtain an interface identifier; extract a request identifier from the data query request to obtain a request identifier; extract a caller identifier from the data query request to obtain a caller identifier; and combine the interface identifier, request identifier, and caller identifier to obtain a session cache identifier.
[0121] In some embodiments, associating the session cache identifier and the pagination structure to obtain a pre-stored cache is specifically used for: extracting the pagination page number from the pagination structure to obtain the pagination record page number; constructing a composite index from the session cache identifier and the pagination record page number to obtain the target index key; and persistently writing the session cache identifier and the pagination structure based on the target index key to obtain the pre-stored cache.
[0122] In some embodiments, the third processing module is specifically used to: extract the start identifier from the paginated records to obtain the start identifier; extract the end identifier from the paginated records to obtain the end identifier; and perform a range query on a preset business database based on the start identifier and the end identifier to obtain the target data corresponding to the data query request.
[0123] In some embodiments, the above-mentioned business data query device is further configured to perform pagination parameter extraction processing on the data query request to obtain a single-page data volume parameter; and if the single-page data volume parameter is greater than a preset single-page data volume threshold, perform parameter over-limit response processing on the data query request to obtain parameter error prompt information.
[0124] In some embodiments, the above-mentioned business data query device is further configured to perform cache identifier validity verification processing on the data query request to obtain cache identifier validity verification result; and if the cache identifier validity verification result is invalid, perform abnormal response processing on the data query request to obtain cache error prompt information.
[0125] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure.
[0126] Figure 5 This is a schematic diagram of the electronic device 5 provided in an embodiment of this disclosure. Figure 5 As shown, the electronic device 5 of this embodiment includes: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the computer program 503, it implements the steps in the various method embodiments described above. Alternatively, when the processor 501 executes the computer program 503, it implements the functions of each module / unit in the various device embodiments described above.
[0127] Electronic device 5 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 5 may include, but is not limited to, processor 501 and memory 502. Those skilled in the art will understand that... Figure 5This is merely an example of electronic device 5 and does not constitute a limitation on electronic device 5. It may include more or fewer components than shown, or different components.
[0128] The processor 501 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0129] The memory 502 can be an internal storage unit of the electronic device 5, such as a hard disk or RAM of the electronic device 5. The memory 502 can also be an external storage device of the electronic device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc., equipped on the electronic device 5. The memory 502 can also include both internal and external storage units of the electronic device 5. The memory 502 is used to store computer programs and other programs and data required by the electronic device.
[0130] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0131] If integrated modules / units are implemented as software functional units and sold or used as independent products, they can be stored in a readable storage medium (e.g., a computer-readable storage medium). Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0132] The above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit it. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be included within the protection scope of this disclosure.
Claims
1. A service data query method, characterized by, include: If the data query request is not the first pagination request, the data query request is processed by parameter extraction to obtain the cache identifier and the page number to be queried; Based on the cache identifier and the page number to be queried, perform pagination record query processing on the pre-stored cache to obtain paginated records; The paginated records are processed to obtain data range information, thereby obtaining the target data corresponding to the data query request.
2. The service data query method of claim 1, wherein, Before performing pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried to obtain the paginated record, the method further includes: If the data query request is the first pagination request, the query conditions of the data query request are parsed to obtain the first pagination query conditions; Based on the initial pagination query conditions, the preset business database is processed to obtain the target data entry identifier set; The target data entry identifier set and the preset single-page data volume are subjected to pagination pre-calculation processing to obtain the pagination structure; The data query request is processed to generate a cache identifier, resulting in a session cache identifier; The session cache identifier and the pagination structure are associated and stored together to obtain the pre-stored cache.
3. The service data query method of claim 2, wherein, The process of generating a cache identifier for the data query request to obtain a session cache identifier includes: The data query request is processed to extract the interface identifier, thus obtaining the interface identifier; The data query request is processed to extract the request identifier, thus obtaining the request identifier; The caller identifier is extracted from the data query request to obtain the caller identifier; The interface identifier, the request identifier, and the caller identifier are combined to obtain the session cache identifier.
4. The business data query method according to claim 2, characterized in that, The step of associating the session cache identifier and the pagination structure for storage to obtain the pre-stored cache includes: The pagination structure is processed to extract pagination page numbers, thus obtaining the pagination record page numbers; The target index key is obtained by constructing a joint index using the session cache identifier and the page number of the pagination record. The session cache identifier and the pagination structure are persistently written based on the target index key to obtain the pre-stored cache.
5. The business data query method according to claim 1, characterized in that, The step of obtaining data range information from the paginated records to obtain the target data corresponding to the data query request includes: The starting identifier is extracted from the paginated record to obtain the starting identifier; The end identifier is extracted from the paginated records to obtain the end identifier; Based on the start identifier and the end identifier, a range query is performed on the preset business database to obtain the target data corresponding to the data query request.
6. The business data query method according to claim 1, characterized in that, Before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: The data query request is processed to extract pagination parameters to obtain the single-page data volume parameter; If the single-page data volume parameter exceeds the preset single-page data volume threshold, the data query request will be processed to handle parameter over-limit and a parameter error message will be obtained.
7. The business data query method according to claim 1, characterized in that, Before performing parameter extraction processing on the data query request to obtain the cache identifier and the page number to be queried when the data query request is not the first pagination request, the method further includes: The data query request is subjected to cache identifier validity verification processing to obtain cache identifier validity verification result; If the cache identifier validity check result is invalid, the data query request is processed to handle the exception and a cache error message is obtained.
8. A business data query device, characterized in that, include: The first processing module is used to perform parameter extraction processing on the data query request when the data query request is not the first pagination request, so as to obtain the cache identifier and the page number to be queried; The second processing module is used to perform pagination record query processing on the pre-stored cache based on the cache identifier and the page number to be queried, so as to obtain the pagination record; The third processing module is used to perform data range information acquisition processing on the paginated records to obtain the target data corresponding to the data query request.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
10. A readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.