Data query method and device, data processing method and device, electronic equipment and computer storage medium
By adopting a dual-caching mechanism in the order fulfillment system, first querying the first cache and then querying the database status, the problem of low data query efficiency in existing technologies is solved, and order delivery fulfillment data can still be efficiently queried even in abnormal states.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, when order fulfillment systems query order delivery fulfillment data, they mainly perform single data queries in the main database or the slave database, resulting in low data query efficiency.
A dual-caching mechanism is adopted. First, the target data is checked in the first cache. If it is not found, the database status is checked. If it is normal, the database is queried. If it is abnormal, the second cache is queried. The second cache pre-caches high-frequency data to ensure that the data can still be retrieved in abnormal states.
By prioritizing cache lookups and database status checks, data retrieval efficiency is significantly improved, ensuring that target data can still be retrieved even in abnormal situations, thus avoiding query failures.
Smart Images

Figure CN121786079A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, specifically to data query methods, data processing methods, data query devices, data processing devices, electronic devices, and computer storage media. Background Technology
[0002] With the increasing number of online orders, the delivery of online orders has become increasingly important. After an online order is placed, it is necessary to query the delivery fulfillment data corresponding to the order so as to determine the delivery capacity for the online order based on the delivery fulfillment data.
[0003] Specifically, when querying order delivery fulfillment data, it is actually based on the delivery method data determined between the merchant and the order fulfillment system. For example, for an online order from merchant A, the delivery riders pre-determined with the order fulfillment system are those with a delivery accuracy rate of over 90%. Therefore, the data of delivery riders with a delivery accuracy rate of over 90% is an example of delivery fulfillment data. In general, massive amounts of data related to orders can be stored in a database. Databases are mainly divided into master databases and slave databases. The master-slave configuration is a classic database architecture design. In this architecture, one server acts as the master database, handling the write operations of data (order-related data), while one or more other servers act as slave databases, handling the read operations of data. Compared to slave databases, the master database stores more comprehensive and timely data. Current data query methods mainly employ a single data query approach, such as querying data only in the master database or only in the slave database, leading to excessively high query volumes and low query efficiency. Therefore, improving data query efficiency in order data querying is a pressing technical problem that needs to be solved. Summary of the Invention
[0004] This application provides a data query method to improve data query efficiency. This application also provides a data processing method, a data query device, a data processing device, an electronic device, and a computer storage medium.
[0005] In a first aspect, this application provides a data query method applied to a rich client of an order fulfillment system. The method includes: in response to detecting a target query request message for target data, calling a first cache to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, querying the target data in the first cache to obtain the target data; the first cache is used to cache historical data queried in the database corresponding to historical query request messages within a first preset time period; the target data is delivery fulfillment data related to the delivery of target merchant orders; if the target data is not cached in the first cache, calling the database to determine whether the database is in an abnormal state; if the database is not in an abnormal state, calling the database to query the target data in the database to obtain the target data; if the database is in an abnormal state, calling a second cache to determine whether the target data is cached in the second cache; if the target data is cached in the second cache, querying the target data in the second cache to obtain the target data; the second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for delivering the target merchant orders.
[0006] Secondly, this application provides a data processing method applied to a server. The method includes: sending a calculation request message to a distributed data processing platform to request the calculation of high-frequency data generated in a database within a second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period; the high-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders, and the high-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency; calling a second cache to cache the high-frequency data in a preset time window, so that the second cache responds to a call request message from a rich client of the order fulfillment system to query target data in the second cache to obtain the target data; the target data is delivery fulfillment data related to the delivery of target merchant orders; the target data is used to determine the delivery capacity for delivering the target merchant orders.
[0007] Thirdly, this application provides a data query device applied to a rich client of an order fulfillment system. The device includes: a first invocation and query unit, configured to, in response to detecting a target query request message for target data, invoke a first cache to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, query the target data in the first cache to obtain the target data; the first cache is used to cache historical data retrieved from the database corresponding to historical query request messages within a first preset time period; the target data is delivery fulfillment data related to the delivery of a target merchant's order; a second invocation and query unit, configured to, if the target data is not cached... If the target data exists in the first cache, the database is invoked to determine whether the database is in an abnormal state; if the database is not in an abnormal state, the database is invoked to query the target data in the database to obtain the target data; the third invocation and query unit is used to invoke the second cache to determine whether the target data is cached in the second cache if the database is in an abnormal state; if the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data; the second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for delivering the target merchant's orders.
[0008] Fourthly, this application provides a data processing apparatus applied to a server. The apparatus includes: a calculation request message sending unit, configured to send a calculation request message to a distributed data processing platform for requesting the calculation of high-frequency data generated in a database within a second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period; the high-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders, and the high-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency; a fourth invocation and caching unit, configured to invoke a second cache to cache the high-frequency data in the second cache within a preset time window, so that the second cache responds to an invocation request message from a rich client of the order fulfillment system to query target data in the second cache to obtain the target data; the target data is delivery fulfillment data related to the delivery of target merchant orders; the target data is used to determine the delivery capacity for delivering the target merchant orders.
[0009] Fifthly, this application provides an electronic device, including: a processor; and a memory for storing a computer program. After the electronic device is powered on and runs the computer program through the processor, it executes the above-mentioned data query method and data processing method.
[0010] Sixthly, this application provides a computer storage medium storing computer execution instructions, which are executed by a processor to perform the aforementioned data query method and data processing method.
[0011] Compared with the prior art, this application has the following advantages: The data query method provided in this application embodiment, in response to detecting a target query request message for target data, first calls a first cache to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, the target data is queried from the first cache to obtain the target data; if the target data is not cached in the first cache, the database is called to determine whether the database is in an abnormal state; if the database is not in an abnormal state, the database is called to query the target data from the database to obtain the target data; if the database is in an abnormal state, a second cache is called to determine whether the target data is cached in the second cache; if the target data is cached in the second cache, the target data is queried from the second cache to obtain the target data; since the first cache contains historical data queried from the database corresponding to historical query request messages within a first preset time period, the historical data may contain the target data, while in the first preset time period... The efficiency of querying data in the first cache is obviously higher than that of querying the database. Therefore, this method prioritizes querying the target data in the first cache, which obviously improves the data query efficiency. If the first cache does not contain the target data, the database is then called to determine if the database is in an abnormal state. If it is not in an abnormal state, the target data can be queried directly in the database, ensuring that the target data can be found. If the database is in an abnormal state, since the second cache pre-caches high-frequency data generated by the database within a second preset time period, the target data is queried in the second cache, which makes it easier to find the target data as much as possible even when the database is in an abnormal state, avoiding the situation where the target data cannot be found at all under database abnormal conditions. In summary, this method improves the data query efficiency by querying data in the dual cache and the database according to the query priority, while ensuring that the required data can be found as much as possible under database abnormal conditions. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0013] Figure 1 A flowchart of the data query method provided in the first embodiment of this application.
[0014] Figure 2 A schematic diagram illustrating the interactive process of the data processing method provided in this application.
[0015] Figure 3 A flowchart of the data processing method provided in the second embodiment of this application.
[0016] Figure 4 A schematic diagram of a data query device provided in the third embodiment of this application.
[0017] Figure 5 This is a schematic diagram of a data processing apparatus provided in the fourth embodiment of this application.
[0018] Figure 6 A schematic diagram of an electronic device provided in the fifth embodiment of this application. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solutions of this application, the application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. However, this application can be implemented in many other ways different from those described below. Therefore, based on the embodiments provided in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0020] It should be noted that the terms "first," "second," "third," etc., in the claims, specification, and drawings of this application are used to distinguish similar objects and are not used to describe a specific order or sequence. Such data are interchangeable where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown or described in this application. Furthermore, the terms "comprising," "having," and their variations are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0021] It should be understood that in the embodiments of this application, "at least one" means one or more, and "more than one" means two or more. "And / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the related objects before and after it are in an "or" relationship. "Contains A, B and / or C" means containing any one, two, or three of A, B, and C.
[0022] It should be understood that in the embodiments of this application, "B corresponding to A", "B corresponding to A", "A corresponds to B" or "B corresponds to A" means that B is associated with A, and B can be determined based on A. Determining B based on A does not mean that B is determined solely based on A; B can also be determined based on A and / or other information.
[0023] This application provides a data query method, a data processing method, a data query apparatus, a data processing apparatus, an electronic device, and a computer storage medium. The following specific embodiments describe the data query method, data processing method, data query apparatus, data processing apparatus, electronic device, and computer storage medium.
[0024] First Embodiment This embodiment provides a data query method, and the execution subject of this embodiment is a rich client of an order fulfillment system. Please refer to the following for details. Figure 1 This is a flowchart of the data query method provided in the first embodiment of this application.
[0025] The data query method of this application includes the following steps.
[0026] Step S101: In response to detecting a target query request message for the target data, the first cache is invoked to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, the target data is queried in the first cache to obtain the target data.
[0027] In the data query method of this embodiment, the target data is delivery fulfillment data related to the delivery of orders from target merchants. This method primarily aims to query delivery fulfillment data related to merchant order delivery, and then determine delivery capacity based on the queried delivery fulfillment data. To facilitate understanding of delivery fulfillment data, let's take an online order from a merchant as an example. After an order is generated, it needs to be delivered based on the delivery requirements agreed upon in advance between the merchant and the order fulfillment system (i.e., the order delivery fulfillment system). For example, if merchant 1 pre-determines a delivery rider with the order fulfillment system who has a delivery accuracy rate of 99% (i.e., for this merchant's orders, late delivery is not allowed), then the data of delivery riders with a delivery accuracy rate of 99% is an example of delivery fulfillment data. Of course, delivery fulfillment data can also include other forms of data, such as merchant address, merchant type, etc.
[0028] Therefore, after a target order is generated with the target merchant, it is necessary to query the delivery fulfillment data related to the delivery of the target merchant's order, i.e., the target data, in order to determine the delivery capacity of the target merchant's order.
[0029] Generally, delivery fulfillment data related to merchant order delivery is stored in a database. Therefore, when querying target data, the existing query method is to query directly in the database. Since the database mainly refers to a distributed database, that is, a database divided into a master database and slave databases, the master database stores more comprehensive and timely data. Therefore, in order to ensure that the retrieved data is timely, the existing data query method mainly queries the master database for the required data. However, for some data query request messages, which are themselves requests to query slave databases, the existing data query method requires querying the master database, resulting in a large query volume in the master database and low query efficiency.
[0030] In practice, historical data related to query requests that have already been queried in the database may be stored in a cache. In this application, this cached historical data is referred to as the first cache. It's understood that, due to limited storage space, the first cache only caches historical data retrieved from the database corresponding to query requests within a first preset time period. The first preset time period can refer to the time interval from a first time to the current time, where the time difference between the current time and the first time is the first preset duration. The first time may be earlier than the current time. In practice, the first preset duration can refer to the effective duration for storing historical data in the first cache, such as setting it to 300 seconds. However, it should be noted that when the amount of historical data within the first preset duration exceeds the storage capacity of the first cache, some historical data needs to be deleted from the first cache, such as deleting historical data with earlier query times.
[0031] To alleviate the situation where the query volume of the main database is large and thus the query efficiency is low, in this application, in response to the detection of a target query request message for the target data, the first cache is invoked to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, the target data is queried in the first cache to obtain the target data.
[0032] Querying in the first cache can, on the one hand, reduce the query load on the main database and thus improve the overall query efficiency; on the other hand, querying data in the cache is more efficient than querying in a database that stores massive amounts of data. In short, if the target data can be found in the first cache, prioritizing the first cache can significantly improve data query efficiency.
[0033] In this application, in order to further improve the efficiency of data query, the data query method of this application is actually executed on the rich client of the order fulfillment system. A rich client is a computer program based on rich Internet applications that uses local computing resources to process data and reduces frequent interactions with the server. By executing this method through the rich client, all data query and data processing processes are avoided from being handled on the server side, thereby improving the data processing capabilities of the server.
[0034] In this application, the target data is used by the order fulfillment system after it is retrieved. Therefore, the rich client can be integrated into the order fulfillment system, so that after the rich client obtains the target data, the order fulfillment system can determine the delivery capacity of the target merchant's order, such as matching the target order with a suitable delivery rider.
[0035] Step S102: If the target data is not cached in the first cache, the database is called to determine if the database is in an abnormal state; if the database is not in an abnormal state, the database is called to query the target data in the database to obtain the target data.
[0036] Step S101 is the case where the target data is found in the first cache, that is, the target data exists in the first cache; there is also the case where the target data cannot be found in the first cache. In the case where the target data cannot be found in the first cache, the database is called to query the target data.
[0037] A database consists of a master database and slave databases; a slave database is a backup database that stores data in the master database. Because a database includes both master and slave databases, when querying target data, it's necessary to determine whether to call the master or slave database. Of course, this can only be done if the database is functioning correctly. It's important to note that if either the master or slave database is experiencing an error, the database that is functioning correctly should be called.
[0038] In this embodiment, "the database is not in an abnormal state" means that both the master database and the slave database are in normal operating condition. In fact, the target query request message includes two types: the first type is a request message for querying the slave database; the second type is a request message for querying the master database.
[0039] The type of the target query request message can be determined based on the region to which the target query request message belongs, the region of the primary database, or the region of the secondary database. If the target query request message accesses the secondary database closer than it accesses the primary database, that is, the region to which the target query request message belongs belongs to the secondary database region, then it belongs to the first case; otherwise, it belongs to the second case.
[0040] For a target query request message that requests a query from a secondary database, the process of determining whether to call the primary or secondary database includes: determining whether the target data requires strong consistency. As one way to call the database to query the target data: if the target data requires strong consistency, the primary database is called and the target data is queried from the primary database; if the target data does not require strong consistency, the synchronization delay between the primary and secondary databases is obtained; based on the target data synchronization delay and a preset delay condition, the primary or secondary database is called to obtain the target data.
[0041] Strong consistency requirements actually refer to strict requirements on the timeliness of data. If the target data is strongly consistent, this method directly calls the master database and queries the master database to obtain the target data, thereby ensuring that the queried target data meets the timeliness requirements. This is mainly because there is a certain delay in synchronizing data from the master database to the slave database, which makes the timeliness of the data in the slave database less than that in the master database. Therefore, if the target data has strict timeliness requirements, it can be queried directly in the master database.
[0042] In the above judgment process, if the target data does not require strong consistency, the target data synchronization delay time is obtained to represent the synchronization delay between the master database and the slave database. Based on the target data synchronization delay time and the preset time condition, the master database or the slave database is invoked to obtain the target data. Specifically, if the target data does not require strong consistency, it is necessary to check the data synchronization status between the master database and the slave database, and then determine whether to invoke the master database or the slave database to obtain the target data based on the data synchronization status.
[0043] The target data synchronization delay is used to characterize the data synchronization status between the master and slave databases. Therefore, before determining whether to call the master or slave database to obtain the target data, it can be judged whether the target data synchronization delay meets a preset delay condition. Calling the master or slave database to obtain the target data based on the target data synchronization delay and the preset delay condition can mean: if the target data synchronization delay meets the preset delay condition, then the slave database is called and the target data is queried from the slave database; if the target data synchronization delay does not meet the preset delay condition, then the master database is called and the target data is queried from the master database. Meeting the preset delay condition can mean that it is less than or equal to a certain preset delay.
[0044] In this embodiment, obtaining the target data synchronization delay duration representing the synchronization of data between the master database and the slave database can refer to: calling the third cache to obtain the target data synchronization delay duration stored in the third cache; the third cache is used to store and update the target data synchronization delay duration. The third cache differs from the first and second caches; the third cache is mainly used to store and update the target data synchronization delay duration, while the first and second caches are used to cache some data in the database.
[0045] In practice, a target data synchronization delay between the master and slave databases meeting the preset time limit means that synchronizing data from the master database to the slave database is relatively fast. In this case, the data in the slave database meets a certain timeliness requirement, allowing the slave database to be accessed and the target data queried there. This avoids the cross-regional network overhead involved in calling the master database and also reduces the query volume on the master database, thus improving query efficiency. Conversely, a target data synchronization delay not meeting the preset time limit means that synchronizing data from the master database to the slave database is slow. In this case, the data in the slave database does not meet a certain timeliness requirement, meaning the data in the slave database is less timely. Therefore, the master database needs to be accessed and the target data queried there to obtain the target data, ensuring that the queried target data meets a certain timeliness requirement.
[0046] The above scenario corresponds to a request message for querying a slave database. For a request message for querying the master database, one way to obtain the target data is to call the master database and query it. When the target query message is for querying the master database, there is no need to determine whether the target data requires strong consistency or whether the target data synchronization delay meets the preset time limit.
[0047] In this embodiment, after retrieving the target data from the database, a first cache request message is sent to the server to cache the target data in the first cache. This causes the server to respond to the first cache request message by caching the target data in the first cache. Cacheing the target data in the first cache allows subsequent query requests for the target data to be retrieved directly from the first cache.
[0048] Step S103: If the database is in an abnormal state, the second cache is called to determine whether the target data is cached in the second cache; if the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data.
[0049] The second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for orders from the target merchants. The storage space of the second cache is limited, and in practice, earlier high-frequency data can be deleted when storing subsequent high-frequency data to ensure that the second cache has enough space to store subsequent high-frequency data.
[0050] Step S102 corresponds to the case where the database is in normal use. When the database is unusable, that is, when neither the master database nor the slave database can be used to perform queries, the second cache is called to determine whether the target data is cached in the second cache. If the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data.
[0051] The second cache pre-caches high-frequency data generated by the database within a second preset time period. In fact, the server calls the second cache to pre-cachate this high-frequency data. The specific process of the server calling the second cache to pre-cachate this high-frequency data is described as follows.
[0052] First, the server sends a computation request message to the distributed data processing platform, requesting the computation of high-frequency data generated in the database within a second preset time period. The distributed data processing platform then responds to this request message and computes the high-frequency data generated in the database within the second preset time period. The distributed data processing platform is equipped with an offline computing engine to facilitate the computation of this high-frequency data.
[0053] A distributed data processing platform is a data processing platform that manages a distributed database. After an order is generated by the online order processing platform, the distributed data processing platform receives the order data provided by the online order processing platform, and then determines the merchant corresponding to the order data as a candidate merchant based on the order data. The delivery fulfillment data related to the delivery of the candidate merchant's order placed with the candidate merchant is stored in the database (i.e., the master database and the slave database).
[0054] Because the second cache needs to pre-cache high-frequency data generated by the database within a second preset time period, the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated by the database within the second preset time period. The calculated high-frequency data is stored in the high-frequency database, which is a database that stores high-frequency data. High-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders. High-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency (e.g., orders from merchants who place more than ten orders in a day). The high-frequency database differs from the previous distributed database. In this embodiment, unless otherwise specified, "database" mainly refers to the distributed database. In fact, the database format of the high-frequency database is not limited.
[0055] The second preset time period can be set based on requirements. The second preset time period can refer to the time interval from a second time to the current time, with the time difference between the current time and the second time being the second preset duration. For example, the last seven days can be used as the second preset time period. It should be noted that the duration of the second preset time period is much longer than the duration of the first preset time period, thus maximizing the retrieval of target data from the second cache in the event of database anomalies. In this application, the first time, the second time, and the current time are actually the first time point, the second time point, and the current time point; however, the current time in the two instances may not be the same time point.
[0056] After the distributed data processing platform obtains high-frequency data, the server can call the second cache to cache the high-frequency data in a preset time window. The preset time window can be a low-peak period for daily data processing (such as 1:00 AM to 5:00 AM), thus making the caching of high-frequency data in the second cache more efficient and not affecting other data processing tasks on the server. A timed scheduling module can be used to cache high-frequency data in the second cache at regular intervals (i.e., within the preset time window).
[0057] To better understand the data interactions between the server, distributed data processing platform, rich client, secondary cache, and high-frequency database, please refer to [reference needed]. Figure 2 This is a schematic diagram of the interaction process of the data processing method provided in this application.
[0058] First, the server executes step S201: sending a calculation request message to the distributed data processing platform to request the calculation of high-frequency data generated in the database within a second preset time period.
[0059] Next, the distributed data processing platform executes step S202: in response to the computation request message, it computes the high-frequency data generated in the database within the second preset time period. Then, it executes step S203: it calls the high-frequency database to store the high-frequency data.
[0060] Server-side execution step S204: Call the second cache to cache the high-frequency data of the high-frequency data in the second cache within a preset time window.
[0061] The rich client executes step S205: it calls the second cache to query the target data in the second cache to obtain the target data.
[0062] In this embodiment, the server also needs to obtain in advance the target data synchronization delay time used to represent the synchronization delay time between the master database and the slave database, and call the third cache to cache the target data synchronization delay time in the third cache.
[0063] The server obtains the target data synchronization delay duration, representing the synchronization delay between the master database and the slave database, in the following way: First, determine the data to be detected that needs to be inserted or updated in the master database; then, call the master database to insert or update the data to be detected, and determine the initial time for inserting or updating the data to be detected in the master database; next, determine whether the data to be detected can be found in the slave database at the current time; if the data to be detected can be found in the slave database at the current time, then obtain the first data synchronization delay duration as the target data synchronization delay duration based on the time difference between the current time and the initial time.
[0064] If the data to be detected can be found in the database at the current time (meaning it is detected in the first check), then the third cache is invoked to cache the target data synchronization delay time. This can be interpreted as: invoking the third cache and replacing the original data synchronization delay time in the third cache with the target data synchronization delay time. The original data synchronization delay time can refer to the originally calculated delay time required to synchronize data from the primary database to the secondary database.
[0065] It should be noted that if the data to be detected is not found in the database at the current time, this could refer to the first instance where the data was not found in the database. In this case, a timed polling method (e.g., checking every few seconds) is used for judgment. Specifically, based on the time difference between the first polling time (the current time of the first polling) and the initial time, the second data synchronization delay duration is obtained. The third cache is called to determine whether the second data synchronization delay duration is greater than the original data synchronization delay duration. If the second data synchronization delay duration is greater than the original data synchronization delay duration, the second data synchronization delay duration replaces the original data synchronization delay duration in the third cache. After that, the second polling time ( The process involves several steps: First, determining if the data to be detected can be found in the database at the current time of the second poll. If not, a third data synchronization delay is obtained based on the time difference between the second poll time and the initial time. The third cache is then used to replace the second data synchronization delay in the third cache. This process continues until the data to be detected is found in the database. The time difference between the target time of finding the data (the current time of the Nth poll) and the initial time is then used as the target data synchronization delay. This target data synchronization delay is then used to update the data synchronization delay in the third cache. Updating the data synchronization delay in the third cache with the target data synchronization delay can mean updating the previously updated data synchronization delay in the third cache with the target data synchronization delay. In practice, this corresponds to a continuous process of updating the data synchronization delay.
[0066] Additionally, a switch can be configured to control the enabling of a second cache for data querying. This allows queries to be performed directly in the second cache in response to the enabling control operation after the distributed database is in an abnormal state. This eliminates the need to check the database for abnormality again when subsequent data request messages occur before the database returns to normal, thereby improving query efficiency.
[0067] In the data query method of this embodiment, since the first cache contains historical data retrieved from the database corresponding to historical query request messages within the first preset time period, and this historical data may contain the target data, the efficiency of querying data in the first cache is obviously higher than that of querying the database. Therefore, this method prioritizes querying the target data in the first cache, which obviously improves the data query efficiency. When the first cache does not contain the target data, the database is then called to determine whether the database is in an abnormal state. When it is not in an abnormal state, the target data can be directly queried from the database, ensuring that the target data can be retrieved. When the database is in an abnormal state, since the second cache pre-caches high-frequency data generated by the database within the second preset time period, the target data is queried from the second cache, which makes it possible to retrieve the target data as much as possible when the database is in an abnormal state, avoiding the situation where the target data cannot be retrieved at all when the database is in an abnormal state. In summary, in this method, by querying data in the dual cache and the database according to the query priority, the data query efficiency is improved, while ensuring that the required data can be retrieved as much as possible when the database is in an abnormal state.
[0068] Second Embodiment Corresponding to the first embodiment, the second embodiment of this application provides a data processing method. The server-side execution entity of this embodiment will not be described again for parts identical to those in the first embodiment; please refer to the relevant parts of the first embodiment for details.
[0069] Please refer to Figure 3 This is a flowchart of the data processing method provided in the second embodiment of this application.
[0070] The data processing method of this application includes the following steps.
[0071] Step S301: Send a calculation request message to the distributed data processing platform to request the calculation of high-frequency data generated in the database within the second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period.
[0072] High-frequency data refers to delivery fulfillment data related to the delivery of high-frequency merchant orders. High-frequency merchant orders are orders placed by merchants whose order frequency exceeds a preset frequency.
[0073] Step S302: Call the second cache to cache high-frequency data in the second cache within a preset time window.
[0074] The second cache is invoked to cache high-frequency data in a preset time window, so that the second cache can query the target data in the second cache in response to the call request message of the rich client of the order fulfillment system. The target data is the delivery fulfillment data related to the delivery of the target merchant's order. The target data is used to determine the delivery capacity for the delivery of the target merchant's order.
[0075] In this embodiment, the method further includes: obtaining a first cache request message sent by the rich client to cache the target data in the first cache; responding to the first cache request message, calling the first cache to cache the target data in the first cache; the first cache request message is sent by the rich client after querying the database to find the target data.
[0076] In this embodiment, the database includes a master database and a slave database; the slave database is a database that backs up the data stored in the master database; the method further includes: obtaining a target data synchronization delay duration for synchronizing data between the master database and the slave database; calling a third cache to cache the target data synchronization delay duration in the third cache, so that the third cache queries the target data synchronization delay duration in the third cache in response to the call request message of the rich client.
[0077] Specifically, obtaining the target data synchronization delay duration to represent the synchronization of data between the master database and the slave database can refer to the following steps: First, determine the data to be detected that needs to be inserted or updated in the master database; then, call the master database to insert or update the data to be detected, and determine the initial time for inserting or updating the data to be detected in the master database; then, determine whether the data to be detected can be found in the slave database at the current time; if the data to be detected can be found in the slave database at the current time, then obtain the first data synchronization delay duration as the target data synchronization delay duration based on the time difference between the current time and the initial time.
[0078] If the data to be detected can be retrieved from the database at the current time, the target data synchronization delay time can be cached in the third cache by calling the third cache. This can mean calling the third cache and replacing the original data synchronization delay time in the third cache with the target data synchronization delay time.
[0079] In this embodiment, if the data to be detected cannot be found in the database at the current time, a timed polling method is used, and a second data synchronization delay duration is obtained based on the time difference between the first polling time and the initial time. The third cache is then called to determine if the second data synchronization delay duration is greater than the original data synchronization delay duration. If the second data synchronization delay duration is greater than the original data synchronization delay duration, the second data synchronization delay duration replaces the original data synchronization delay duration in the third cache. It is then determined whether the data to be detected can be found in the database at the second polling time. If the data to be detected cannot be found in the database at the second polling time, a third data synchronization delay duration is obtained based on the time difference between the second polling time and the initial time. The third cache is then called to replace the second data synchronization delay duration in the third cache with the third data synchronization delay duration. This process continues until the data to be detected is found in the database. The time difference between the target time when the data to be detected is found in the database and the initial time is used as the target data synchronization delay duration, and the data synchronization delay duration in the third cache is updated using the target data synchronization delay duration.
[0080] If the data to be detected can be retrieved from the database during the second round of querying, then the third data synchronization delay is obtained as the target data synchronization delay based on the time difference between the second round of querying and the initial time; the second data synchronization delay in the third cache is replaced with the target data synchronization delay. At this point, there is no need to update the data synchronization delay in the third cache.
[0081] In the data processing method of this embodiment, a calculation request message for requesting the calculation of high-frequency data generated in the database within a second preset time period is sent to the distributed data processing platform in advance. This causes the distributed data processing platform to respond to the calculation request message and calculate the high-frequency data generated in the database within the second preset time period. Then, the second cache is invoked to cache the high-frequency data in a preset time window. In effect, the high-frequency data generated in the database within the second preset time period is pre-cached in the second cache. Simultaneously, the first cache contains historical data, which may include target data. This facilitates the rich client's ability to invoke the first cache in response to a detected target query request message for the target data. The client checks whether the first cache contains the target data; if so, it queries the first cache to obtain the target data. Retrieving data from the cache is clearly more efficient than querying from the database. Therefore, prioritizing the query for target data in the first cache significantly improves query efficiency. If the first cache does not contain the target data, the database is then accessed to determine if it is in an abnormal state. If it is not in an abnormal state, the target data can be queried directly from the database, ensuring that the target data can be found. If the database is in an abnormal state, the target data is queried from the second cache, which pre-caches high-frequency data generated by the database within a second preset time period. This ensures that the target data can be retrieved as much as possible even when the database is in an abnormal state, avoiding the situation where the target data cannot be found at all under database abnormal conditions. By setting up a dual-caching and database query method, data query efficiency is improved, while ensuring that the required data can be retrieved as much as possible even under database abnormal conditions.
[0082] Third Embodiment Corresponding to the data query method provided in the first embodiment of this application, the third embodiment of this application also provides a data query device. Since the device embodiment is basically similar to the first embodiment, the description is relatively simple; relevant details can be found in the description of the first embodiment. The device embodiments described below are merely illustrative.
[0083] Please refer to Figure 4 This is a schematic diagram of the data query device provided in the third embodiment of this application.
[0084] The data query device 400 is applied to a rich client of an order fulfillment system. The device includes: a first invocation and query unit 401, configured to, in response to detecting a target query request message for target data, invoke a first cache to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, query the target data in the first cache to obtain the target data; the first cache is used to cache historical data retrieved from the database corresponding to historical query request messages within a first preset time period; the target data is delivery fulfillment data related to the delivery of a target merchant's order; and a second invocation and query unit 402, configured to, if the target data is not cached in the first cache... In the first cache, the database is invoked to determine whether the database is in an abnormal state; if the database is not in an abnormal state, the database is invoked to query the target data in the database to obtain the target data; the third invocation and query unit 403 is used to, if the database is in an abnormal state, invoke the second cache to determine whether the target data is cached in the second cache; if the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data; the second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for delivering the target merchant's order.
[0085] Fourth embodiment Corresponding to the data processing method provided in the second embodiment of this application, the fourth embodiment of this application also provides a data processing apparatus. Since the apparatus embodiment is basically similar to the second embodiment, the description is relatively simple; relevant details can be found in the description of the second embodiment. The apparatus embodiments described below are merely illustrative.
[0086] Please refer to Figure 5 This is a schematic diagram of the data processing apparatus provided in the fourth embodiment of this application.
[0087] The data processing device 500, applied to a server, includes: a calculation request message sending unit 501, used to send a calculation request message to a distributed data processing platform to request calculation of high-frequency data generated in a database within a second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period; the high-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders, and the high-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency; a fourth invocation and caching unit 502, used to invoke a second cache to cache the high-frequency data in the second cache within a preset time window, so that the second cache responds to an invocation request message from a rich client of the order fulfillment system to query target data in the second cache to obtain the target data; the target data is delivery fulfillment data related to the delivery of target merchant orders; the target data is used to determine the delivery capacity for delivering the target merchant orders.
[0088] Fifth embodiment Corresponding to the methods of the first to second embodiments of this application, the fifth embodiment of this application also provides an electronic device.
[0089] The electronic device includes: a processor; and a memory for storing a computer program. After the electronic device is powered on and runs the computer program through the processor, it executes the methods of the first to second embodiments. Figure 6 As shown, Figure 6 This is a schematic diagram of an electronic device provided according to the fifth embodiment of this application. The electronic device specifically includes: at least one processor 601, at least one communication interface 602, at least one memory 603, and at least one communication bus 604. Optionally, the communication interface 602 can be an interface for a communication module, such as the interface for a GSM module. The processor 601 may be a CPU, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The memory 603 may include high-speed RAM and may also include non-volatile memory, such as at least one disk storage device. The memory 603 stores a program, and the processor 601 calls the program stored in the memory 603 to execute the methods of the first to second embodiments.
[0090] Sixth Embodiment Corresponding to the methods of the first to second embodiments of this application, the sixth embodiment of this application also provides a computer storage medium storing computer execution instructions, which are executed by a processor to perform the methods of the first to second embodiments of this application.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0093] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media, which can store information by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined in this application, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.
[0094] 2. Those skilled in the art will understand that embodiments of this application can provide methods, systems, or computer program products. Therefore, embodiments of this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0095] 3. This application embodiment may involve the use of user data. In practical applications, user-specific personal data may be used within the scope permitted by applicable laws and regulations of the country in which the application is located (e.g., with the user's explicit consent and effective notification to the user, etc.). Furthermore, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0096] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.
Claims
1. A data query method, characterized in that, A rich client application for an order fulfillment system, the method comprising: In response to detecting a target query request message for target data, the first cache is invoked to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, the target data is queried in the first cache to obtain the target data; the first cache is used to cache historical data retrieved from the database corresponding to historical query request messages within a first preset time period; the target data is delivery fulfillment data related to the delivery of target merchant orders; If the target data is not cached in the first cache, the database is invoked to determine whether the database is in an abnormal state; if the database is not in an abnormal state, the database is invoked to query the target data in the database to obtain the target data. If the database is in an abnormal state, the second cache is invoked to determine whether the target data is cached in the second cache; if the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data; the second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for delivering the target merchant's orders.
2. The method according to claim 1, characterized in that, The database includes a master database and a slave database; the slave database is a database that backs up the data stored in the master database. The target query request message is a request message used to request a query from the database; The method further includes: Determine whether the target data belongs to data requiring strong consistency; The step of calling the database to query the target data in the database to obtain the target data includes: If the target data is data that requires strong consistency, then the main database is invoked and the target data is queried in the main database to obtain the target data; If the target data is data that does not require strong consistency, then the target data synchronization delay time used to represent the synchronization of data between the master database and the slave database is obtained; Based on the target data synchronization delay time and the preset time condition, the target data is obtained by calling the master database or the slave database.
3. The method according to claim 1, characterized in that, The database includes a master database and a slave database; the slave database is a database that backs up the data stored in the master database; the target query request message is a request message used to request a query from the master database. The step of calling the database to query the target data in the database to obtain the target data includes: The main database is invoked, and the target data is queried in the main database to obtain the target data.
4. The method according to claim 2, characterized in that, The step of obtaining the target data synchronization delay duration for representing the synchronization of data between the master database and the slave database includes: calling a third cache to obtain the target data synchronization delay duration stored in the third cache; the third cache is used to store and update the target data synchronization delay duration.
5. The method according to claim 2, characterized in that, Also includes: Determine whether the target data synchronization delay time meets the preset time condition; The step of obtaining the target data by calling the master database or the slave database based on the target data synchronization delay time and the preset time condition includes: If the target data synchronization delay time meets the preset time condition, then the slave database is invoked and the target data is queried in the slave database to obtain the target data.
6. A data processing method, characterized in that, Applied to the server side, the method includes: A calculation request message is sent to the distributed data processing platform to request the calculation of high-frequency data generated in the database within a second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period; the high-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders, and the high-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency. The second cache is invoked to cache the high-frequency data in the second cache within a preset time window, so that the second cache can query the target data in the second cache in response to the call request message of the rich client of the order fulfillment system to obtain the target data; the target data is delivery fulfillment data related to the delivery of the target merchant's order; the target data is used to determine the delivery capacity for delivering the target merchant's order.
7. A data query device, characterized in that, A rich client application for an order fulfillment system, the device comprising: The first invocation and query unit is used to respond to the detection of a target query request message for target data, and to invoke the first cache to determine whether the target data is cached in the first cache; if the target data is cached in the first cache, the target data is queried in the first cache to obtain the target data; the first cache is used to cache historical data queried in the database corresponding to historical query request messages within a first preset time period; the target data is delivery fulfillment data related to the delivery of target merchant orders; The second invocation and query unit is used to, if the target data is not cached in the first cache, invoke the database to determine whether the database is in an abnormal state; if the database is not in an abnormal state, invoke the database to query the target data in the database to obtain the target data. The third call and query unit is used to call the second cache to determine whether the target data is cached in the second cache if the database is in an abnormal state; if the target data is cached in the second cache, the target data is queried in the second cache to obtain the target data; the second cache is used to pre-cache high-frequency data generated by the database within a second preset time period; the target data is used to determine the delivery capacity for delivering the target merchant's order.
8. A data processing apparatus, characterized in that, Applied to the server side, the device includes: The calculation request message sending unit is used to send a calculation request message to the distributed data processing platform to request the calculation of high-frequency data generated in the database within a second preset time period, so that the distributed data processing platform responds to the calculation request message and calculates the high-frequency data generated in the database within the second preset time period; the high-frequency data is delivery fulfillment data related to the delivery of high-frequency merchant orders, and the high-frequency merchant orders are orders from merchants whose order frequency exceeds a preset frequency. The fourth invocation and caching unit is used to invoke the second cache to cache the high-frequency data in the second cache within a preset time window, so that the second cache responds to the invocation request message of the rich client of the order fulfillment system to query the target data in the second cache to obtain the target data; the target data is delivery fulfillment data related to the delivery of the target merchant's order; the target data is used to determine the delivery capacity for delivering the target merchant's order.
9. An electronic device, characterized in that, include: processor; And a memory for storing a computer program, wherein after the electronic device is powered on and the computer program is run by the processor, it performs the method according to any one of claims 1-6.
10. A computer storage medium, characterized in that, The computer storage medium stores computer execution instructions, which are executed by a processor to perform the method described in any one of claims 1-6.