Request processing method and system, storage medium, and electronic device
By automatically identifying the relationship between API and storage database field and delay double deletion strategy, the problems of repeated calculations and data in API request processing are solved, and strong consistency synchronization of API request results and system performance improvement are achieved.
Patent Information
- Application Number
- CN202210820150.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2042-07-12
AI Technical Summary
In large-scale high concurrency scenarios, it is difficult for the existing technology to effectively solve the problems of repeated calculations and data inconsistency in API request processing. Especially when using cached calculation results, you need to be familiar with the business code for data synchronization and consistency modification, and there is intrusion. Sex and complexity.
By obtaining the API's data write request, the relationship between the API and the fields in the storage database is automatically identified. The delay double deletion strategy and cluster analysis are used to achieve synchronous modification of the code's zero-invasion request results, and the system status is based on the read request when reading the request. Decide whether to cache the API request results to reduce the server query and computing.
It realizes strong consistency synchronization of API request results, reduces server-side data query and computing, improves system performance, and avoids duplicate calculations, and is suitable for high-concurrency environments in large-scale scenarios.
Smart Images

Figure CN115374131B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a request processing method, a request processing system, a storage medium, and an electronic device. Background Art
[0002] With the development of Internet technology, the scale of software has become increasingly large in recent years, and it is necessary to divide complex systems into small components. In order to enable application developers to call a set of routine functions without having to consider the underlying source code or understand the details of its internal working mechanism, an application programming interface (API) was designed.
[0003] In large-scale high-concurrency scenarios, data caching is usually used to improve the processing speed and concurrency of APIs and reduce backend pressure. The first type is to cache commonly used fields in storage databases such as MySQL and ETCD into memory databases such as Redis and Memcached, and use the high concurrency of memory databases to calculate API request processing; the second type is to cache request results on the API request side. For example, browsers use strong caching, negotiated caching and other methods to reduce interaction requests with the server and reduce server load. However, both of the above methods have certain limitations. Each request still requires a large amount of queries and calculations to assemble the initial data, which will cause repeated calculation problems. It is difficult to maintain data synchronization and consistency by caching calculation results.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field.
[0005] Public Content
[0006] The purpose of the present disclosure is to provide a request processing method, a request processing system, a storage medium and an electronic device, thereby overcoming one or more problems caused by limitations and defects of related technologies at least to a certain extent.
[0007] According to one aspect of the present disclosure, a request processing method is provided, including:
[0008] Get data writing request of application programming interface API;
[0009] According to the data write request, the fields corresponding to the API in the memory database are deleted, and the fields corresponding to the API in the storage database are updated;
[0010] According to the updated fields, determine the request result corresponding to the fields in the memory database;
[0011] Delete the request result corresponding to the field in the in-memory database.
[0012] In an exemplary embodiment of the present disclosure, determining a request result corresponding to a field in a memory database according to an updated field includes:
[0013] Perform cluster analysis on the field updates caused by data write requests of multiple APIs and the request results corresponding to the fields in advance to obtain the corresponding association relationships;
[0014] Determine the request result corresponding to the field in the memory database based on the association relationship.
[0015] In an exemplary embodiment of the present disclosure, the request processing method further includes:
[0016] Before caching the updated fields in the in-memory database, stop reading fields from the in-memory database within a preset time.
[0017] According to one aspect of the present disclosure, another request processing method is provided, including:
[0018] Get data read request of application programming interface API;
[0019] If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, then read the request result corresponding to the API;
[0020] If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, then the request result corresponding to the API is calculated;
[0021] Cache the request results corresponding to the API in the in-memory database.
[0022] In an exemplary embodiment of the present disclosure, calculating the request result corresponding to the API includes:
[0023] If the field corresponding to the API does not exist in the memory database, the field corresponding to the API in the storage database is cached in the memory database;
[0024] According to the API data read request, the fields corresponding to the API in the memory database are calculated to obtain the request result.
[0025] In an exemplary embodiment of the present disclosure, the request processing method further includes:
[0026] If the request result corresponding to the API is stopped from being cached in the memory database within the preset time of the limited-time cache cancellation rule, the limited-time cache cancellation rule includes stopping reading the field from the memory database within the preset time after the field in the storage database is updated;
[0027] If the preset time of the limited-time cancellation cache rule is exceeded, the request result corresponding to the API will be cached in the memory database.
[0028] According to one aspect of the present disclosure, there is provided a request processing system, comprising:
[0029] Business processing logic module: used to obtain data writing requests from the application programming interface API, delete the fields corresponding to the API in the memory database according to the data writing requests, update the fields corresponding to the API in the storage database, and delete the request results corresponding to the fields in the memory database.
[0030] In-memory database: used to store fields and field data corresponding to the API and the request results corresponding to the API;
[0031] Storage database: used to store fields and the data corresponding to the fields;
[0032] API change perception module: used to determine the request result corresponding to the field in the memory database based on the updated field.
[0033] According to one aspect of the present disclosure, another request processing system is provided, comprising:
[0034] Business processing logic module: used to obtain the data reading request of the application programming interface API. If the cache list includes the data reading request result corresponding to the API and the request result corresponding to the API exists in the memory database, then read the request result corresponding to the API. If the cache list includes the data reading request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, then calculate the request result corresponding to the API and cache the request result corresponding to the API in the memory database.
[0035] In-memory database: used to store fields and field data corresponding to the API and the request results corresponding to the API;
[0036] Storage database: used to store fields and the data corresponding to the fields;
[0037] API cache management: used to store cache lists.
[0038] According to one aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above methods by executing the executable instructions.
[0039] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above methods is implemented.
[0040] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0041] In a request processing method provided in an example embodiment of the present disclosure, the relationship between the API and the fields in the storage database is automatically identified according to the data request of the API, and the request result corresponding to the API is cached in the memory database. On the one hand, when the field changes, the synchronous modification of the request result can be completed in a zero-code intrusion manner to maintain a strong consistency relationship of the data; on the other hand, it can be decided whether to cache the API based on the request status of the system, which can effectively solve repeated calculations in large-scale scenarios, reduce the data query and calculation amount on the server side, and thus improve the overall performance of the system.
[0042] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0044] Figure 1 A flowchart of a request processing method to which the present disclosure embodiment can be applied is shown;
[0045] Figure 2 A flowchart of a request processing method according to an embodiment of the present disclosure is schematically shown;
[0046] Figure 3 A flowchart schematically shows a request processing method according to another embodiment of the present disclosure;
[0047] Figure 4 Schematically illustrates a log data diagram according to an embodiment of the present disclosure;
[0048] Figure 5 A flowchart showing another request processing method to which the present disclosure embodiment can be applied;
[0049] Figure 6 A flowchart of a request processing method in a specific scenario according to an embodiment of the present disclosure is schematically shown;
[0050] Figure 7 A flowchart of a request processing method in a specific scenario according to an embodiment of the present disclosure is schematically shown;
[0051] Figure 8 A flowchart of a request processing method in a specific scenario according to another embodiment of the present disclosure is schematically shown;
[0052] Fig. 9 A schematic diagram schematically shows a request processing system according to an embodiment of the present disclosure;
[0053] Fig.10 A schematic diagram schematically shows a request processing system according to another embodiment of the present disclosure;
[0054] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0055] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0056] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0057] In large-scale high-concurrency scenarios, data caching is usually used to improve the processing speed and concurrency of APIs and reduce backend pressure. Storage database refers to the system storing relatively initial data, including all information in the system. Memory database refers to the database that directly operates data in memory. For example, when caching data, storage database is equivalent to a warehouse, and memory database is equivalent to a transit station. The data reading and writing speed of memory is several orders of magnitude higher. Storing data in memory can greatly improve the performance of applications compared to accessing it from disk. The first type is to cache commonly used fields in storage databases such as MySQL and ETCD into memory databases such as Redis and Memcached, and use the high concurrency and fast query capabilities of memory databases to reduce the performance bottleneck of persistent storage databases; the second type is to cache request results on the API request side. For example, the browser reduces interactive requests with the server and reduces the server load through strong caching, negotiated caching and other methods. However, there will be such problems, repeated calculations and data inconsistency.
[0058] In-memory databases usually use key-value to cache relatively initial data. For aggregate queries and APIs that require a lot of calculations, each request still requires a lot of queries and calculations to assemble the initial data, which will cause repeated calculations. Related technologies will use the method of caching calculation results to solve the above problems, but at the same time will introduce new problems: you need to be familiar with the business code, and you can modify the aggregate data / calculation results at the same time after the initial data is updated to ensure data consistency; modifying the logic will cause intrusion into the existing business code; the cache value of aggregate data / intermediate results is related to the request frequency and concurrency, and you need to decide whether to cache based on the system status.
[0059] In order to maintain data consistency in related technical solutions, there are many variations according to actual business scenarios. In essence, they are all caching of fields. Here we take "delayed double deletion" as an example.
[0060] The delayed double deletion strategy is a common strategy for maintaining consistency in the storage and cache data in distributed systems. Let's observe the system layout from a macro perspective to understand data consistency. Due to asynchronous data operations between multiple nodes, multiple business program nodes read and write data; Redis read-write separation, master-slave synchronization; MySQL read-write separation, master-slave synchronization.
[0061] The data work process can be summarized in the following steps: delete the Redis master database data; the service node modifies the MySQL master database data; the service node makes the current business processing wait for a period of time until the Redis and MySQL master and slave node data are successfully synchronized; the service node deletes data from the Redis master database; the current or other service nodes read the Redis slave database data, find that the Redis slave database has no data, read the data from the MySQL slave database, and write it to the Redis master database.
[0062] The following describes in detail how to maintain data consistency in the API data write request.
[0063] Based on this, in this example embodiment, a request processing method is provided, referring to Figure 1 As shown, the request processing method includes the following steps:
[0064] Step S110, obtaining a data writing request of an application programming interface API;
[0065] Step S120, deleting the field corresponding to the API in the memory database according to the data write request, and updating the field corresponding to the API in the storage database;
[0066] Step S130, determining the request result corresponding to the field in the memory database according to the updated field;
[0067] Step S140, deleting the request result corresponding to the field in the memory database.
[0068] In a request processing method provided in an example embodiment of the present disclosure, the relationship between the API and the fields in the storage database is automatically identified according to the data request of the API, and the request result corresponding to the API is cached in the memory database. When the field changes, the synchronous modification of the request result can be completed in a zero-code intrusion manner, maintaining a strong consistency relationship of the data.
[0069] After receiving the data write request from the API, according to the delayed double deletion strategy, the data work process is as follows: Figure 2 As shown in the figure, when the API data write request enters the business processing module after passing the load balancing, after the business processing logic, the cached data in the memory database is deleted first, and then the value in the storage database is updated, and the data synchronization between the storage database and the memory database is waited for. The cached data is deleted again after a fixed time interval to ensure the data consistency between the memory database and the storage database.
[0070] In this example implementation, some functions are added on the basis of the delayed double deletion strategy to optimize the delayed double deletion strategy. The memory database not only contains cached data, but also request results of different APIs. The request result is the result encapsulated after calculating the data through logical processing according to the requirements in the API request information.
[0071] In step S110, a data writing request of an application programming interface API is obtained.
[0072] In this example implementation, the server obtains a data write request from the application programming interface API, and analyzes the data write request after obtaining the data write request. For example, the client needs to modify personal information, and after the operation is performed, the portal website receives a data write request from the API interface for modifying personal information.
[0073] In step S120, the field corresponding to the API in the memory database is deleted according to the data write request, and the field corresponding to the API in the storage database is updated.
[0074] In this example implementation, many servers cache the data of certain fields frequently used by the client in the memory database in advance. However, if the client initiates a data write request and needs to modify the data of certain fields in the storage database, then the cached data in the memory database is invalid data. Therefore, after obtaining the data write request, it is necessary to first delete the field corresponding to the API in the memory database to prevent other threads from calling it, resulting in an erroneous request result. Then, according to the data write request, the field corresponding to the API in the storage database is updated. For example, if the client needs to modify the age in personal information from 20 to 21, then first delete the cached age field in the memory database, and then modify the data in the age field in the storage database to 21. If there are other requests to call the age field during the modification process, it will be found that there is no cached data for this field in the memory database, and it can only be re-queried in the storage database, thus maintaining data consistency.
[0075] In addition, update rules can be set according to the business needs of the client. For example, each write request for the same API can only perform a single accumulation of the field data corresponding to the API (for example, adding one each time). The present disclosure does not limit the specific content of the update rules. After configuring the update rules, the update rules are used to update the field data corresponding to the API in the storage database.
[0076] Step S130: Determine the request result corresponding to the field in the memory database according to the updated field.
[0077] In this example implementation, since the request result corresponding to the field still exists in the memory database, for example, an API request result is to calculate a growth relationship between age and height. At this time, since the age field is changed, the API request result will change. Therefore, it is necessary to automatically find the corresponding request result based on the updated field, which can be done by Figure 3 Follow the steps in the command to enable the field to automatically find the corresponding request result.
[0078] Step S310 , cluster analysis is performed in advance on the field updates caused by data writing requests of multiple APIs and the request results corresponding to the fields to obtain corresponding association relationships.
[0079] In this example implementation, clustering is to divide a data set into different classes or clusters according to a specific standard (such as distance), so that the similarity of data objects in the same cluster is as large as possible, and the difference of data objects in different clusters is as large as possible. It is an unsupervised learning method. Data clustering methods can be mainly divided into partition-based clustering methods, density-based clustering methods, hierarchical clustering methods, etc.
[0080] In this example implementation, Figure 4 As shown, training can be performed in advance based on the API request return data and field modification records in the log. For example, according to the process of the K-means algorithm, the API request return data and fields are pre-divided into K groups, and K objects are randomly selected as the initial cluster centers, and then the distance between each object and each seed cluster center is calculated, and each object is assigned to the cluster center closest to it. The cluster centers and the objects assigned to them represent a cluster. Each time a sample is assigned, the cluster center of the cluster is recalculated based on the existing objects in the cluster. This process will be repeated until a certain termination condition is met. The termination condition can be that no (or a minimum number) of objects are reassigned to different clusters, no (or a minimum number) of cluster centers change again, and the sum of squared errors is locally minimized.
[0081] Step S320, determining the request result corresponding to the field in the memory database according to the association relationship.
[0082] In this example implementation, if the results of two requests to the same API are the same, the fields modified between them are not relevant to the API; if the results of the two requests are different, the fields modified between them may be relevant to the API (the higher the frequency, the greater the relevance). For example, the modified fields can be queried through the Watch mechanism, which is that an object or data node may be monitored by multiple clients, and when the corresponding event is triggered, these objects or clients will be notified.
[0083] In addition, association rule algorithms can be used to find the associations between API request return data and field modification records. For example, the apriori algorithm and FP-Growth algorithm can mine frequent item sets from different API request return data and field modification records, calculate confidence and support, and then find the connections between API request return data and field modification records.
[0084] Step S140, deleting the request result corresponding to the field in the memory database.
[0085] In this example implementation, the corresponding request results in the memory database for the changed field data will also change. In order to ensure data consistency, the request results corresponding to the fields also need to be deleted, because the data reading request of another API may have errors when reading the cache.
[0086] In this example implementation, after deleting the request result corresponding to the field in the memory database, the updated field is cached in the memory database to calculate the new request result. The server caches the updated field in the memory database so that the subsequent API data read request can read the cached data, and then quickly calculate the request result to return to the client.
[0087] In addition, before caching the updated fields in the memory database, stop reading the fields from the memory database within a preset time. The data of the MySQL and Redis master and slave nodes are not synchronized in real time. Synchronizing data takes time. During this period, other service nodes directly read the latest data from the storage database to ensure data consistency.
[0088] The above embodiment describes the data writing request of the API, and the following describes the data reading request of the API.
[0089] Based on this, in this example embodiment, a request processing method is provided, referring to Figure 5 As shown, the request processing method includes the following steps:
[0090] Step S510, obtaining a data reading request of an application programming interface API;
[0091] Step S520: If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, then read the request result corresponding to the API;
[0092] Step S530, if the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, then calculate the request result corresponding to the API;
[0093] Step S540: cache the request result corresponding to the API into the memory database.
[0094] In the request processing method provided in an example implementation of the present disclosure, it is possible to decide whether to cache the API based on the system's request status, which can effectively solve repeated calculations in large-scale scenarios, reduce data queries and calculations on the server side, and thus improve the overall performance of the system.
[0095] After receiving the data read request from the API, according to the delayed double deletion strategy, the data work process is as follows: Figure 6 As shown in the figure, when the API data reading request enters the business processing module after load balancing, after the business processing logic, the data is first searched in the memory database. If the required data is not found, the storage database is searched again and the result is cached in the memory database.
[0096] For example, in a K8S (Kubernetes) cluster, Pod is the basis of all business types and the smallest unit level managed by K8S. It is a combination of one or more containers. These containers share storage, network, and namespaces, as well as specifications for how to run. In a Pod, all containers are arranged and scheduled in the same way and run in a shared context. For specific applications, Pod is their logical host, and Pod contains multiple business-related application containers. To query the resource allocation of a medium-sized cluster POD, assuming there are 50 namespaces and 100 PODs in each namespace, 5,000 queries are required if the query is performed in the above manner, and resources are also consumed for data encapsulation and calculation.
[0097] In this example implementation, some functions are added on the basis of the delayed double deletion strategy to optimize the delayed double deletion strategy, and cache management is added. The API request results that need to be cached can be set by subscription or according to the request frequency and concurrency threshold, and cache query and time-limited cache query cancellation functions are provided.
[0098] Step S510: obtaining a data reading request of an application programming interface API.
[0099] In this example implementation, the server obtains a data read request from the application programming interface API, and analyzes the data read request after obtaining the data read request. For example, the client needs to query personal information, and after the query operation, the portal website receives a data write request from the personal information query API interface.
[0100] Step S520: If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, the request result corresponding to the API is read.
[0101] In this example implementation, the cache list is set based on the request frequency and concurrency threshold to set the APIs that need to be cached. For example, based on the frequent data reading requests for querying the weather API on the portal website, the request frequency of this API is relatively high, and the server will automatically set it to the cache list based on the request frequency of this API. Then, the next time a request is obtained for the same API, it will first check whether the cache list includes the request for this API, and then query the in-memory database. If there is a request result corresponding to the API, the API request result will be sent directly back to the client. Of course, certain APIs can also be set in the cache list according to demand.
[0102] Step S530: If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, the request result corresponding to the API is calculated.
[0103] In this example implementation, if there is a request for the API in the cache list, but there is no request result corresponding to the API when querying the memory database, then the request result corresponding to the API needs to be calculated. For example, a request corresponding to an API needs to obtain the result of A+B, so the data corresponding to A and B needs to be obtained first.
[0104] If the field corresponding to the API does not exist in the memory database, the field corresponding to the API in the storage database is cached in the memory database. For example, to obtain the result of A+B, the data corresponding to the fields A and B are found in the storage database and then cached in the memory database.
[0105] According to the API data read request, the fields corresponding to the API in the memory database are calculated to obtain the request result. For example, if the API data read request is to obtain the result of A+B, the results of A and B are added in the memory database to obtain the result.
[0106] Step S540: cache the request result corresponding to the API into the memory database.
[0107] In this example implementation, the request results corresponding to the API are cached in the memory database. When the next request for the same API arrives, the cache list is queried first, and then the request results are directly obtained from the memory database and returned to the client. This effectively solves the problem of repeated calculations and can reduce data queries and calculations on the server side, thereby improving the overall performance of the system.
[0108] For example, in a K8S cluster, to query the resource allocation of a medium-sized cluster POD, if there are 50 namespaces and each namespace has 100 PODs, only one query is required if the query is performed in the above way.
[0109] In addition, a time-limited cache cancellation rule is set. The rule can be to stop reading the field from the memory database within a preset time after updating the field in the storage database. At this time, it is to prevent the request result obtained from being an old calculation result. If it is within the preset time of the time-limited cache cancellation rule, the request result corresponding to the API will stop being cached in the memory database. If it is outside the preset time of the time-limited cache cancellation rule, the request result corresponding to the API will be cached in the memory database. The essential difference between the cache of the request results corresponding to the field and the API is that the data query and calculation in the intermediate process are omitted. Therefore, the query, calculation, network transmission and other resource consumption of the server are not consumed.
[0110] The above request processing method in this example implementation is applied to the request processing process in combination with a specific application scenario.
[0111] refer to Figure 7 As shown, after obtaining an API data write request, it enters the business logic processing module after load balancing, and then deletes the field cache involved in the API in the memory database, and updates the fields in the storage database. Then the API change perception module is notified. The API change perception module obtains the cache request result that will be affected by the change of the field based on the mapping relationship between the API and the field. The mapping relationship between the API and the field is obtained by the API and field analysis module by pre-training the data in the storage database. The cache request result has changed, so it is unavailable and needs to be deleted. In order to maintain strong data consistency, data is not read from the memory database within a set interval. After the updated field is cached in the memory database, the field cache is deleted.
[0112] refer to Figure 8As shown, after obtaining an API data read request, enter the API cache management module for query after load balancing. If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, the request result corresponding to the API is returned. If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, first go to the memory database to get the cache field. If it does not exist in the memory database, go to the storage database to cache the field data to the internal training database, then calculate the request result corresponding to the API, and then cache the request result corresponding to the API in the memory database, and finally return the request result corresponding to the API.
[0113] In a request processing method provided in an example embodiment of the present disclosure, the relationship between the API and the fields in the storage database is automatically identified according to the data request of the API, and the request result corresponding to the API is cached in the memory database. On the one hand, when the field changes, the synchronous modification of the request result can be completed in a zero-code intrusion manner to maintain a strong consistency relationship of the data; on the other hand, it can be decided whether to cache the API based on the request status of the system, which can effectively solve repeated calculations in large-scale scenarios, reduce the data query and calculation amount on the server side, and thus improve the overall performance of the system.
[0114] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0115] Furthermore, this example implementation also provides a request processing system.
[0116] refer to Fig. 9 The request processing system includes a business processing logic module 901, a memory database 902, a storage database 903, and an API change perception module 904, wherein:
[0117] Business processing logic module: used to obtain data writing requests from the application programming interface API, delete the fields corresponding to the API in the memory database according to the data writing requests, update the fields corresponding to the API in the storage database, and delete the request results corresponding to the fields in the memory database;
[0118] In-memory database: used to store fields and field data corresponding to the API and the request results corresponding to the API;
[0119] Storage database: used to store fields and the data corresponding to the fields;
[0120] API change perception module: used to determine the request result corresponding to the field in the memory database based on the updated field.
[0121] refer to Fig.10 ,The request processing system includes a business processing logic module ,1001, a memory database 1002, a storage database 1003, and an API cache management 1004, where:
[0122] Business processing logic module: used to obtain the data reading request of the application programming interface API. If the cache list includes the data reading request result corresponding to the API and the request result corresponding to the API exists in the memory database, then read the request result corresponding to the API. If the cache list includes the data reading request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, then calculate the request result corresponding to the API and cache the request result corresponding to the API in the memory database.
[0123] In-memory database: used to store fields and field data corresponding to the API and the request results corresponding to the API;
[0124] Storage database: used to store fields and the data corresponding to the fields;
[0125] API cache management: used to store cache lists.
[0126] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.
[0127] It should be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0128] like Fig.11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage part 1108 into a random access memory (RAM) 1103. Various programs and data required for system operation are also stored in the RAM 1103. The CPU 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0129] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed, so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0130] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1109, and / or installed from a removable medium 1111. When the computer program is executed by a central processing unit (CPU) 1101, various functions defined in the method and apparatus of the present application are executed.
[0131] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiment. For example, the electronic device can implement the various steps shown in the method disclosed in the present invention.
[0132] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0133] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A request processing method, characterized in that: include: Get data writing request of application programming interface API; Deleting the field corresponding to the API in the memory database according to the data write request, and updating the field corresponding to the API in the storage database; Determine, according to the updated field, a request result corresponding to the field in the memory database; The request result is the result of encapsulating the calculated logical processing data according to the requirements in the API request information; Deleting the request result corresponding to the field in the memory database; The updated fields are cached in the memory database to calculate new request results.
2. The method according to claim 1, characterized in that The determining, according to the updated field, the request result corresponding to the field in the memory database includes: Perform cluster analysis on the field updates caused by data writing requests of multiple APIs and the request results corresponding to the fields in advance to obtain corresponding association relationships; Determine the request result corresponding to the field in the memory database according to the association relationship.
3. The method according to claim 1, further comprising: Before caching the updated field in the memory database, stop reading the field from the memory database within a preset time.
4. A request processing method, characterized in that: include: Get data read request of application programming interface API; If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, read the request result corresponding to the API; The request result is the result of encapsulating the calculated logical processing data according to the requirements in the API request information; If the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, cache the field corresponding to the API in the storage database into the memory database, and calculate the field corresponding to the API in the memory database according to the data read request of the API to obtain the request result corresponding to the API; The request results corresponding to the API are cached in the in-memory database.
5. The method according to claim 4, characterized in that The method further comprises: If within the preset time of the time-limited cache cancellation rule, the request result corresponding to the API is stopped from being cached in the memory database, the time-limited cache cancellation rule includes stopping reading the field from the memory database within the preset time after updating the field in the storage database; If the preset time of the limited-time cancellation cache rule is exceeded, the request result corresponding to the API is cached in the memory database.
6. A request processing system, characterized in that: include: A business processing logic module is used to obtain a data writing request of an application programming interface API, delete a field corresponding to the API in a memory database according to the data writing request, update a field corresponding to the API in a storage database, and delete a request result corresponding to the field in the memory database; Cache the updated fields in the memory database to calculate new request results; The request result is the result of encapsulating the calculated logical processing data according to the requirements in the API request information; An in-memory database, used to store fields and field data corresponding to the API and request results corresponding to the API; Storage database, used to store fields and data corresponding to the fields; The API change perception module is used to determine the request result corresponding to the field in the memory database according to the updated field.
7. A request processing system, characterized in that: include: A business processing logic module is used to obtain a data read request of an application programming interface API, and if the cache list includes a data read request result corresponding to the API and the request result corresponding to the API exists in the memory database, then read the request result corresponding to the API; if the cache list includes the data read request result corresponding to the API and the request result corresponding to the API does not exist in the memory database, then cache the field corresponding to the API in the storage database to the memory database, and calculate the field corresponding to the API in the memory database according to the data read request of the API to obtain the request result corresponding to the API; Cache the request result corresponding to the API in the memory database; The request result is the result of encapsulating the logical processing data after calculation according to the requirements in the API request information; An in-memory database, used to store fields and field data corresponding to the API and request results corresponding to the API; Storage database, used to store fields and data corresponding to the fields; API cache management, used to store cache lists.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 5 by executing the executable instructions.
