Request processing method and device, computer equipment and storage medium

The request processing method in financial systems addresses duplicate request issues by intercepting and identifying unique identifiers, eliminating duplicates, and using response interceptors to enhance efficiency and speed in handling multiple requests.

CN119226638APending Publication Date: 2024-12-31PING AN BANK CO LTD

Patent Information

Application Number
CN202411204851.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Financial business systems face inefficiencies in processing duplicate requests due to the direct use of axios for batch request handling, leading to low processing efficiency when handling large numbers of requests.

Method used

Implement a request processing method that includes intercepting requests using a preset interceptor, calculating unique identifiers, checking for duplicates in a cache and active request records, and utilizing response interceptors to monitor and forward the response of original requests, thereby eliminating duplicate processing.

Benefits of technology

This approach intelligently identifies and eliminates duplicate requests, improving processing efficiency by avoiding multiple processing of the same requests and ensuring rapid response completion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226638A_ABST
    Figure CN119226638A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of artificial intelligence and the field of financial science and technology, and relates to a request processing method which comprises the steps of receiving a to-be-processed service request; intercepting the service request based on the request interceptor; calculating a unique identifier of the service request, and judging whether a first identifier which is the same as the unique identifier and is not expired exists in a cache or not; if the first identifier does not exist, judging whether an original request with a second identifier which is the same as the unique identifier exists in the active request record or not; if the original request exists, eliminating the service request; after the response interceptor monitors that the processing of the original request is completed, obtaining a target response result corresponding to the original request; and forwarding the target response result to a caller corresponding to the service request. The invention further provides a request processing device, computer equipment and a storage medium. In addition, the target response result may be stored in the block chain. According to the application, the processing efficiency of the service request is effectively improved based on the use of the interceptor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence development technology and financial technology, and in particular to request processing methods, devices, computer equipment and storage media. Background Art

[0002] With the widespread use of financial business systems developed by financial technology companies (such as insurance companies, banks, etc.), during the use of financial business systems, users have increasingly higher requirements for the service response speed and reliability of financial business systems.

[0003] However, the current financial business system often encounters the problem of duplicate requests when processing business requests, resulting in the same multiple asynchronous requests triggered by the same user being sent and processed multiple times. The existing financial business system usually directly uses the method officially provided by axios to handle duplicate requests. When the number of requests to be processed is large, this processing method requires batch use of axios on the page, which will result in low request processing efficiency. Summary of the invention

[0004] The purpose of the embodiments of the present application is to propose a request processing method, device, computer equipment and storage medium to solve the existing financial business system's method of processing repeated requests, which is usually directly processed by the method officially provided by axios. When the number of requests to be processed is large, this processing method requires batch use of axios on the page, which will cause the technical problem of low request processing efficiency.

[0005] In order to solve the above technical problems, the embodiment of the present application provides a request processing method, which adopts the following technical solution:

[0006] Receive pending business requests;

[0007] Intercepting the business request based on a preset request interceptor;

[0008] Calculate the unique identifier of the service request, and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache;

[0009] If the first identifier does not exist in the cache, determining whether there is an original request having a second identifier identical to the unique identifier in a preset active request record;

[0010] If the original request exists in the active request record, deleting the service request;

[0011] Based on a preset response interceptor, the response of the original request is monitored, and after the response interceptor monitors that the processing of the original request is completed, a target response result corresponding to the original request is obtained;

[0012] The target response result is forwarded to the caller corresponding to the business request.

[0013] Furthermore, the step of calculating the unique identifier of the service request specifically includes:

[0014] Determine a target hash algorithm from among a plurality of preset hash algorithms;

[0015] Obtain the URL, request method, parameters and method name of the business request;

[0016] Perform hash calculation processing on the URL, the request method, the parameters and the method name based on the target hash algorithm to obtain a corresponding hash value;

[0017] The hash value is used as the unique identifier of the service request.

[0018] Furthermore, the step of eliminating the service request specifically includes:

[0019] Get the preset request elimination method;

[0020] The service request is eliminated based on the request elimination method.

[0021] Furthermore, the step of intercepting the service request based on a preset request interceptor specifically includes:

[0022] Obtaining the target IP address of the service request;

[0023] Get the preset IP address blacklist;

[0024] Determine whether the target IP address is included in the IP address blacklist;

[0025] If the target IP address is not included in the IP address blacklist, the step of intercepting the service request based on the preset request interceptor is executed.

[0026] Further, after the step of calculating the unique identifier of the service request and determining whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache, the method further includes:

[0027] If the first identifier exists in the cache, obtaining cache data corresponding to the first identifier from the cache;

[0028] Creating a corresponding target object based on the cached data;

[0029] Send the target object to the caller.

[0030] Further, after the step of determining whether there is an original request having a second identifier identical to the unique identifier in the preset active request record, the method further includes:

[0031] If the original request does not exist in the active request record, sending the service request to the corresponding server;

[0032] Receiving a response result corresponding to the service request returned by the server;

[0033] The response result is sent to the caller.

[0034] Furthermore, after the step of receiving a response result corresponding to the service request returned by the server, the method further includes:

[0035] Invoking the response interceptor;

[0036] Detecting, based on the response interceptor, whether a cache strategy is set in the request configuration of the business request;

[0037] If a cache policy is set in the request configuration of the business request, an expiration time corresponding to the response result is generated;

[0038] Based on the response interceptor, the response result and the expiration time are stored in the cache.

[0039] In order to solve the above technical problems, the embodiment of the present application also provides a request processing device, which adopts the following technical solution:

[0040] A first receiving module, used for receiving a service request to be processed;

[0041] An interception module, used to intercept the service request based on a preset request interceptor;

[0042] A processing module, used for calculating the unique identifier of the service request, and determining whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache;

[0043] a determination module, configured to determine whether there is an original request having a second identifier identical to the unique identifier in a preset active request record if the first identifier does not exist in the cache;

[0044] A deletion module, configured to delete the service request if the original request exists in the active request record;

[0045] A first acquisition module is used to monitor the response of the original request based on a preset response interceptor, and obtain a target response result corresponding to the original request after the response interceptor monitors that the original request has been processed;

[0046] The forwarding module is used to forward the target response result to the caller corresponding to the business request.

[0047] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0048] Receive pending business requests;

[0049] Intercepting the business request based on a preset request interceptor;

[0050] Calculate the unique identifier of the service request, and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache;

[0051] If the first identifier does not exist in the cache, determining whether there is an original request having a second identifier identical to the unique identifier in a preset active request record;

[0052] If the original request exists in the active request record, deleting the service request;

[0053] Based on a preset response interceptor, the response of the original request is monitored, and after the response interceptor monitors that the processing of the original request is completed, a target response result corresponding to the original request is obtained;

[0054] The target response result is forwarded to the caller corresponding to the business request.

[0055] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0056] Receive pending business requests;

[0057] Intercepting the business request based on a preset request interceptor;

[0058] Calculate the unique identifier of the service request, and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache;

[0059] If the first identifier does not exist in the cache, determining whether there is an original request having a second identifier identical to the unique identifier in a preset active request record;

[0060] If the original request exists in the active request record, deleting the service request;

[0061] Based on a preset response interceptor, the response of the original request is monitored, and after the response interceptor monitors that the processing of the original request is completed, a target response result corresponding to the original request is obtained;

[0062] The target response result is forwarded to the caller corresponding to the business request.

[0063] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0064] The present application first receives a business request to be processed; then intercepts the business request based on a preset request interceptor; then calculates the unique identifier of the business request, and determines whether there is a first identifier that is the same as the unique identifier and has not expired in the preset cache; if the first identifier does not exist in the cache, then determines whether there is an original request with a second identifier that is the same as the unique identifier in the preset active request record; if the original request exists in the active request record, then eliminates the business request; subsequently, based on a preset response interceptor, monitors the response of the original request, and after the response interceptor monitors that the original request is processed, obtains the target response result corresponding to the original request; finally, forwards the target response result to the caller corresponding to the business request. The present application, based on the use of request interceptors, caches, active request records and response interceptors, intelligently eliminates the business request when it is identified as a duplicate request, and then forwards the target response result corresponding to the obtained original request to the caller corresponding to the business request, thereby realizing the rapid and intelligent completion of the response processing for the business request, effectively avoiding the situation where duplicate requests are sent and processed multiple times, and improving the processing efficiency of business requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0066] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0067] Figure 2 A flowchart of an embodiment of a request processing method according to the present application;

[0068] Figure 3 is a structural diagram of an embodiment of a request processing device according to the present application;

[0069] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0070] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0071] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0072] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0073] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0074] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0075] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0076] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0077] It should be noted that the request processing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the request processing device is generally set in the server / terminal device.

[0078] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0079] Continue to refer Figure 2 , shows a flowchart of an embodiment of the request processing method according to the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. The request processing method provided in the embodiment of the present application can be applied to any scenario where request processing is required, and the request processing method can be applied to products in these scenarios, for example, business request processing in the financial insurance field. The request processing method comprises the following steps:

[0080] Step S201: receiving a service request to be processed.

[0081] In this embodiment, the electronic device (eg, Figure 1The server / terminal device shown in the figure) can obtain the service request through a wired connection or a wireless connection. It should be pointed out that the above-mentioned wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future. The executor of the present application is specifically a business system, and the present application can be applied to business scenarios in which the business system processes the received business requests. Exemplarily, in the field of finance and insurance, the above-mentioned business system may be a claims business system. The above-mentioned business request may be an inquiry request for claims information triggered by a customer in the process of using the claims business system.

[0082] Step S202: intercepting the service request based on a preset request interceptor.

[0083] In the present embodiment, the above-mentioned request processing method is implemented based on axios. Axios is an excellent promise-based http library for sending requests, which can be used in browsers and node.js. On the axios instance, a request interceptor is pre-added. The request interceptor will be called before the request is sent to the server. Specifically, the request interceptor is added by using the .interceptors.request.use() method of the axios instance. This request interceptor function receives the request configuration (config) as a parameter and returns a modified request configuration or Promise, which is resolved to the modified request configuration. Wherein, the specific implementation process of intercepting the business request based on the preset request interceptor, the application will be further described in detail in the subsequent specific embodiments, and will not be elaborated too much here.

[0084] Step S203: Calculate the unique identifier of the service request, and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache.

[0085] In the present embodiment, outside the axios instance, a cache system is pre-initialized in a global scope or a module, i.e., the above-mentioned cache, for storing the request result and the expiration time of the request result. The format of the cache can be a simple object or Map, the key is the unique identifier of the request, and the value is an object containing the request data and the expiration time. Wherein, the specific implementation process of the unique identifier of the business request calculated above, the application will be further described in detail in subsequent specific embodiments, and will not be elaborated too much here. In addition, if there is the first identifier identical with the unique identifier and not expired in the cache, it shows that the above-mentioned business request belongs to a repeated request.

[0086] Step S204: If the first identifier does not exist in the cache, determine whether there is an original request with a second identifier that is the same as the unique identifier in a preset active request record.

[0087] In the present embodiment, outside the axios instance, a data structure recording the current active request (i.e., a request that has been sent but has not yet received a response) is pre-initialized in a global scope or a module, i.e., the above-mentioned active request record. The structure of the active request record can be a Map or object, the key is the unique identifier of the request, and the value is a container containing the original request configuration and the response callback. Wherein, if there is an original request with the second identifier identical to the unique identifier in the active request record, it indicates that the above-mentioned business request belongs to a repeated request. And if there is no original request with the second identifier identical to the unique identifier in the active request record, it indicates that the above-mentioned business request does not belong to a repeated request.

[0088] Step S205: If the original request exists in the active request record, the service request is deleted.

[0089] In this embodiment, if the original request exists in the active request record, it indicates that the specific implementation process of eliminating the service request will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated here.

[0090] Step S206: monitor the response of the original request based on a preset response interceptor, and obtain a target response result corresponding to the original request after the response interceptor monitors that the original request has been processed.

[0091] In this embodiment, a response interceptor is added to the axios instance in advance. The response interceptor will be called before the server response is processed. The functions of the response interceptor include: Update cache: If the request is configured with cache and the response status code indicates that the request is successful, the response interceptor will store the response data and its expiration time in the cache. In this way, future identical requests can get data directly from the cache without accessing the server again. Notify duplicate requests: For duplicate requests that are canceled due to deduplication, the target interceptor needs to ensure that they can get the response data after the original request is completed. Specifically, this can be achieved by maintaining a listening mechanism in the response interceptor. Once the original request is processed, all waiting duplicate requests are notified and the corresponding response data is sent.

[0092] Step S207 forwards the target response result to the caller corresponding to the business request.

[0093] In this embodiment, the caller is a user who initiates the service request. By sending the response result to the caller, the response processing for the service request can be successfully completed based on the use of the response interceptor without sending the service request to the server.

[0094] The present application first receives a business request to be processed; then intercepts the business request based on a preset request interceptor; then calculates the unique identifier of the business request, and determines whether there is a first identifier that is the same as the unique identifier and has not expired in the preset cache; if the first identifier does not exist in the cache, then determines whether there is an original request with a second identifier that is the same as the unique identifier in the preset active request record; if the original request exists in the active request record, then eliminates the business request; subsequently, based on a preset response interceptor, monitors the response of the original request, and after the response interceptor monitors that the original request is processed, obtains the target response result corresponding to the original request; finally, forwards the target response result to the caller corresponding to the business request. The present application, based on the use of request interceptors, caches, active request records and response interceptors, intelligently eliminates the business request when it is identified as a duplicate request, and then forwards the target response result corresponding to the obtained original request to the caller corresponding to the business request, thereby realizing the rapid and intelligent completion of the response processing for the business request, effectively avoiding the situation where duplicate requests are sent and processed multiple times, and improving the processing efficiency of business requests.

[0095] In some optional implementations, the calculating of the unique identifier of the service request in step S203 includes the following steps:

[0096] Determine the target hash algorithm from multiple preset hash algorithms.

[0097] In this embodiment, the above-mentioned hash algorithms may at least include CRC32, FNV-1, MD5, SHA-256 and other algorithms. An algorithm may be randomly selected from all the above-mentioned hash algorithms as the above-mentioned target hash algorithm. Preferably, since the CRC32 algorithm has the advantages of fast calculation speed and low resource consumption, the CRC32 algorithm may be used as the target hash algorithm to improve the calculation speed of the subsequent hash calculation processing.

[0098] Get the URL, request method, parameters and method name of the service request.

[0099] In this embodiment, the above-mentioned business request can be parsed to extract the URL, request method, parameters and method name in the business request. Among them, the above-mentioned URL refers to the URL address of the business request. The above-mentioned request method refers to the get request method or the post request method. The above-mentioned parameters may refer to the request reason of the business request, and the request reason refers to the specific matters of the business request, such as passing business data, passing passwords, etc. In the business scenario of financial insurance product push, the business data may include transaction data, payment data, business data, and so on. The above-mentioned method name refers to the method name corresponding to the business request. In addition, the unique identifier corresponding to the business request may also include other categories of information in addition to the URL, request method, parameters and method name, which can be set according to actual needs.

[0100] The URL, the request method, the parameters and the method name are hashed based on the target hash algorithm to obtain a corresponding hash value.

[0101] In this embodiment, the collected URL, request method, parameters and method name hash values ​​are calculated by using a target hash algorithm, wherein a hash function can convert an input of any length into an output (i.e., a hash value) of a fixed length, and different inputs almost always produce different hash values.

[0102] The hash value is used as the unique identifier of the service request.

[0103] The present application determines the target hash algorithm from a plurality of preset hash algorithms; then obtains the URL, request method, parameters and method name of the business request; then performs hash calculation processing on the URL, request method, parameters and method name based on the target hash algorithm to obtain a corresponding hash value; and subsequently uses the hash value as the unique identifier of the business request. The present application determines the target hash algorithm from a plurality of preset hash algorithms, and then uses the target hash algorithm to perform hash calculation processing on the URL, request method, parameters and method name of the business request, so as to realize fast and accurate generation of the unique identifier of the business request, thereby improving the generation efficiency and generation intelligence of the unique identifier.

[0104] In some optional implementations of this embodiment, step S205 includes the following steps:

[0105] Gets the preset request cancellation method.

[0106] In this embodiment, the request elimination method can be specifically CancelToken in axios, which is essentially calling the xhr.abort method to make the caller who initiated the service request abandon the request. The request elimination method is stored in the local database in advance, and then the request elimination method can be called from the local database later.

[0107] The service request is eliminated based on the request elimination method.

[0108] In this embodiment, after the call of the request elimination method is completed, the service request can be deleted by using the request elimination method to complete the elimination process of the service request, that is, the service request is no longer sent to the server.

[0109] The present application obtains a preset request elimination method; and then eliminates the business request based on the request elimination method. When the present application detects that the original request exists in the active request record, it will determine that the business request is a repeated request that is sent repeatedly, and then it will intelligently use the request elimination method to quickly and accurately complete the elimination of the business request, so that the repeated processing of the repeated request will not occur in the future, reducing the invalid workload of request processing and improving the accuracy and intelligence of request processing.

[0110] In some optional implementations, step S202 includes the following steps:

[0111] Obtain the target IP address of the service request.

[0112] In this embodiment, the target IP address refers to the IP address that sends the service request.

[0113] Get the preset IP address blacklist.

[0114] In this embodiment, the above-mentioned IP address blacklist is a list set storing malicious IP addresses that is pre-constructed according to actual network security protection requirements.

[0115] Determine whether the target IP address is included in the IP address blacklist.

[0116] In this embodiment, the target IP address can be matched with all IP addresses included in the IP address blacklist, and if there is a specific IP address matching the target IP address among all IP addresses included in the IP address blacklist, it is determined that the target IP address is included in the IP address blacklist. If there is no specific IP address matching the target IP address among all IP addresses included in the IP address blacklist, it is determined that the target IP address is not included in the IP address blacklist.

[0117] If the target IP address is not included in the IP address blacklist, the step of intercepting the service request based on the preset request interceptor is executed.

[0118] In this embodiment, if the target IP address is not included in the IP address blacklist, it indicates that the target IP address that issues the service request is a legal IP address, and the response processing for the service request will continue to be executed later. If the target IP address is included in the IP address blacklist, it indicates that the target IP address that issues the service request is an illegal IP address, and the response to the service request will be restricted later to prevent the processing of illegal requests, thereby protecting the security and stability of the service system.

[0119] The present application obtains the target IP address of the service request; then obtains a preset IP address blacklist; subsequently determines whether the target IP address is included in the IP address blacklist; if the target IP address is not included in the IP address blacklist, then executes the step of intercepting the service request based on the preset request interceptor. After receiving the service request to be processed, the present application will also identify whether the service request is an illegal request based on the use of the IP address blacklist. Only when it is determined that the target IP address is not included in the IP address blacklist will the response processing for the service request be continued, effectively protecting the security and stability of the business system.

[0120] In some optional implementations, after step S203, the electronic device may further perform the following steps:

[0121] If the first identifier exists in the cache, cache data corresponding to the first identifier is obtained from the cache.

[0122] In this embodiment, if the first identifier exists in the cache, it indicates that the business request is a duplicate request. The cache can be implemented using a cache utility class (CacheUtil). The cache utility class is responsible for storing and managing cache data, including cache access, expiration checking, etc. Map or WeakMap can be used to store cache items, where the key is the unique identifier of the request and the value is the cache data and expiration time. Specifically, the corresponding cache data can be found from the cache by using the first identifier.

[0123] A corresponding target object is created based on the cached data.

[0124] In this embodiment, the target object is specifically a resolved Promise object that uses the cached data as a resolved value.

[0125] Send the target object to the caller.

[0126] In this embodiment, since axios does not provide a method for directly canceling unsent requests, a resolved Promise object is returned to simulate the effect of "cancelling" the request. This resolved Promise object will contain cached data as a response to the above-mentioned business request and return it to the caller of the business request. And when the caller receives a Promise object containing cached data, it can access this cached data through the .then() method. This request-response process is transparent to the caller, and they do not need to know whether the data comes from a network request or a cache. By adopting this request-response mode, it is possible to simulate the behavior of canceling the request and returning the cached data without actually sending a network request, thereby improving the performance and response speed of the business system.

[0127] If the present application detects that the first identifier exists in the cache, the cache data corresponding to the first identifier is obtained from the cache; then a corresponding target object is created based on the cache data; and the target object is subsequently sent to the caller. When the present application detects that the first identifier exists in the cache, the cache data corresponding to the first identifier is intelligently obtained from the cache, and a target object is created based on the cache data, and then the target object is sent to the caller. By adopting a request-response method based on a target object, it is possible to simulate the behavior of canceling a request and returning cached data without actually sending a network request, thereby improving the performance and response speed of the business system and improving the intelligence of processing business requests.

[0128] In some optional implementations of this embodiment, after step S204, the electronic device may further perform the following steps:

[0129] If the original request does not exist in the active request record, the service request is sent to the corresponding server.

[0130] In this embodiment, if it is detected that there is no first identifier that is identical to the unique identifier and has not expired in the cache, and there is no original request with the second identifier that is identical to the unique identifier in the active request record, it is determined that the business request is not a duplicate request but a new request that needs to be processed normally, and the business request will be sent to the corresponding server subsequently.

[0131] Receive a response result corresponding to the service request returned by the server.

[0132] In this embodiment, after receiving the service request, the server will process the service request, output a corresponding response result, and provide feedback.

[0133] The response result is sent to the caller.

[0134] In this embodiment, the caller is a user who initiates the service request. By sending the response result to the caller, the response processing for the service request is successfully completed.

[0135] If the present application detects that the original request does not exist in the active request record, the business request will be sent to the corresponding server; then the response result corresponding to the business request returned by the server will be received; and the response result will be subsequently sent to the caller. If the present application detects that the original request does not exist in the active request record, it will determine that the above business request is a new request that needs to be processed normally, and then the business request will be sent to the corresponding server, and then the response result corresponding to the business request returned by the server will be received and returned to the caller corresponding to the business request, thereby smoothly completing the response processing for the business request and ensuring the standardization and intelligence of the processing of the business request.

[0136] In some optional implementations of this embodiment, after the step of receiving a response result corresponding to the service request returned by the server, the electronic device may further perform the following steps:

[0137] Invoke the response interceptor.

[0138] In this embodiment, after the response interceptor is added, it will be stored for subsequent calls.

[0139] Based on the response interceptor, it is detected whether a cache strategy is set in the request configuration of the business request.

[0140] In this embodiment, the service request can be parsed using the above-mentioned response interceptor, and it can be determined whether cache type information is configured in the service request. If cache type information is configured in the service request, it is determined that a cache policy is set in the request configuration of the service request. If cache type information is not configured in the service request, it is determined that no cache policy is set in the request configuration of the service request.

[0141] If a cache policy is set in the request configuration of the business request, an expiration time corresponding to the response result is generated.

[0142] In this embodiment, there is no specific limitation on the selection of the value of the expiration time, and it can be set according to actual system performance requirements.

[0143] Based on the response interceptor, the response result and the expiration time are stored in the cache.

[0144] In this embodiment, the storage processing of the response result and the expiration time can be implemented by using a Map form. Specifically, the unique identifier of the service request is used as a key, and the response result and the expiration time are stored in the cache as values.

[0145] After receiving the response result corresponding to the business request returned by the server, the present application calls the response interceptor; then based on the response interceptor, detects whether a cache strategy is set in the request configuration of the business request; if a cache strategy is set in the request configuration of the business request, an expiration time corresponding to the response result is generated; and subsequently based on the response interceptor, the response result and the expiration time are stored in the cache. After receiving the response result corresponding to the business request returned by the server, the present application will also intelligently call the response interceptor to detect whether a cache strategy is set in the request configuration of the business request. If it is detected that a cache strategy is set in the request configuration of the business request, an expiration time corresponding to the response result will be further generated, and the response result and the expiration time will be stored in the cache. This allows the cache data to be directly obtained from the cache and responded to when processing the same request that matches the business request, without having to access the server again, thereby reducing the processing workload for the request, improving the processing efficiency for the request, and improving the intelligence of the processing of the request.

[0146] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0147] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target response results, the above-mentioned target response results can also be stored in a node of a blockchain.

[0148] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0149] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0150] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0151] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0152] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0153] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a request processing device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0154] like Figure 3 As shown, the request processing device 300 described in this embodiment includes: a first receiving module 301, an interception module 302, a processing module 303, a judgment module 304, an elimination module 305, a first acquisition module 306 and a forwarding module 307. Among them:

[0155] A first receiving module 301, configured to receive a service request to be processed;

[0156] An interception module 302, configured to intercept the service request based on a preset request interceptor;

[0157] The processing module 303 is used to calculate the unique identifier of the service request and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache;

[0158] A determination module 304 is configured to determine whether there is an original request having a second identifier identical to the unique identifier in a preset active request record if the first identifier does not exist in the cache;

[0159] The elimination module 305 is used to eliminate the service request if the original request exists in the active request record;

[0160] A first acquisition module 306 is used to monitor the response of the original request based on a preset response interceptor, and obtain a target response result corresponding to the original request after the response interceptor monitors that the original request has been processed;

[0161] The forwarding module 307 is used to forward the target response result to the caller corresponding to the business request.

[0162] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0163] In some optional implementations of this embodiment, the processing module 303 includes:

[0164] A first determination submodule is used to determine a target hash algorithm from a plurality of preset hash algorithms;

[0165] The first acquisition submodule is used to obtain the URL, request method, parameters and method name of the service request;

[0166] A calculation submodule, used to perform hash calculation processing on the URL, the request method, the parameters and the method name based on the target hash algorithm to obtain a corresponding hash value;

[0167] The second determining submodule is used to use the hash value as the unique identifier of the service request.

[0168] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0169] In some optional implementations of this embodiment, the elimination module 305 includes:

[0170] A second acquisition submodule is used to acquire a preset request elimination method;

[0171] The elimination submodule is used to eliminate the service request based on the request elimination method.

[0172] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the above-mentioned implementation mode, and will not be repeated here.

[0173] In some optional implementations of this embodiment, the interception module 302 includes:

[0174] A third acquisition submodule is used to obtain the target IP address of the service request;

[0175] The fourth acquisition submodule is used to obtain a preset IP address blacklist;

[0176] A judgment submodule, used to judge whether the target IP address is included in the IP address blacklist;

[0177] An execution submodule is used to execute the step of intercepting the service request based on a preset request interceptor if the target IP address is not included in the IP address blacklist.

[0178] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0179] In some optional implementations of this embodiment, the request processing device further includes:

[0180] a fourth acquisition module, configured to acquire cache data corresponding to the first identifier from the cache if the first identifier exists in the cache;

[0181] A creation module, used to create a corresponding target object based on the cached data;

[0182] The first sending module is used to send the target object to the caller.

[0183] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0184] In some optional implementations of this embodiment, the request processing device further includes:

[0185] A second sending module, configured to send the service request to a corresponding server if the original request does not exist in the active request record;

[0186] A second receiving module is used to receive a response result corresponding to the service request returned by the server;

[0187] The third sending module is used to send the response result to the caller.

[0188] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0189] In some optional implementations of this embodiment, the request processing device further includes:

[0190] A calling module, used for calling the response interceptor;

[0191] A detection module, used for detecting whether a cache strategy is set in the request configuration of the business request based on the response interceptor;

[0192] A generating module, configured to generate an expiration time corresponding to the response result if a cache policy is set in the request configuration of the service request;

[0193] A storage module is used to store the response result and the expiration time in the cache based on the response interceptor.

[0194] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the request processing method in the aforementioned implementation mode, and are not described in detail here.

[0195] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0196] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0197] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0198] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the request processing method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0199] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the request processing method.

[0200] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0201] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0202] In an embodiment of the present application, a business request to be processed is first received; then the business request is intercepted based on a preset request interceptor; thereafter, a unique identifier of the business request is calculated, and it is determined whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache; if the first identifier does not exist in the cache, it is determined whether there is an original request with a second identifier that is the same as the unique identifier in a preset active request record; if the original request exists in the active request record, the business request is eliminated; subsequently, a response to the original request is monitored based on a preset response interceptor, and after the response interceptor detects that the processing of the original request is completed, a target response result corresponding to the original request is obtained; finally, the target response result is forwarded to the caller corresponding to the business request. The present application uses request interceptors, caches, active request records, and response interceptors to intelligently eliminate a business request when it is identified as a duplicate request, and then forward the target response result corresponding to the original request to the caller corresponding to the business request, thereby quickly and intelligently completing the response processing for the business request, effectively avoiding the situation where duplicate requests are sent and processed multiple times, and improving the processing efficiency of business requests.

[0203] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the request processing method as described above.

[0204] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0205] In an embodiment of the present application, a business request to be processed is first received; then the business request is intercepted based on a preset request interceptor; thereafter, a unique identifier of the business request is calculated, and it is determined whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache; if the first identifier does not exist in the cache, it is determined whether there is an original request with a second identifier that is the same as the unique identifier in a preset active request record; if the original request exists in the active request record, the business request is eliminated; subsequently, a response to the original request is monitored based on a preset response interceptor, and after the response interceptor detects that the processing of the original request is completed, a target response result corresponding to the original request is obtained; finally, the target response result is forwarded to the caller corresponding to the business request. The present application uses request interceptors, caches, active request records, and response interceptors to intelligently eliminate a business request when it is identified as a duplicate request, and then forward the target response result corresponding to the original request to the caller corresponding to the business request, thereby quickly and intelligently completing the response processing for the business request, effectively avoiding the situation where duplicate requests are sent and processed multiple times, and improving the processing efficiency of business requests.

[0206] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0207] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A request processing method, characterized in that: The steps include: Receive pending business requests; Intercepting the business request based on a preset request interceptor; Calculate the unique identifier of the service request, and determine whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache; If the first identifier does not exist in the cache, determining whether there is an original request having a second identifier identical to the unique identifier in a preset active request record; If the original request exists in the active request record, deleting the service request; Based on a preset response interceptor, the response of the original request is monitored, and after the response interceptor monitors that the processing of the original request is completed, a target response result corresponding to the original request is obtained; The target response result is forwarded to the caller corresponding to the business request.

2. The request processing method according to claim 1, characterized in that: The step of calculating the unique identifier of the service request specifically includes: Determine a target hash algorithm from among a plurality of preset hash algorithms; Obtain the URL, request method, parameters and method name of the business request; Perform hash calculation processing on the URL, the request method, the parameters and the method name based on the target hash algorithm to obtain a corresponding hash value; The hash value is used as the unique identifier of the service request.

3. The request processing method according to claim 1, characterized in that: The step of eliminating the service request specifically includes: Get the preset request elimination method; The service request is eliminated based on the request elimination method.

4. The request processing method according to claim 1, characterized in that: The step of intercepting the service request based on a preset request interceptor specifically includes: Obtaining the target IP address of the service request; Get the preset IP address blacklist; Determine whether the target IP address is included in the IP address blacklist; If the target IP address is not included in the IP address blacklist, the step of intercepting the service request based on the preset request interceptor is executed.

5. The request processing method according to claim 1, characterized in that: After the step of calculating the unique identifier of the service request and determining whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache, the method further includes: If the first identifier exists in the cache, obtaining cache data corresponding to the first identifier from the cache; Creating a corresponding target object based on the cached data; Send the target object to the caller.

6. The request processing method according to claim 1, characterized in that: After the step of determining whether there is an original request having a second identifier identical to the unique identifier in the preset active request record, the method further includes: If the original request does not exist in the active request record, sending the service request to the corresponding server; Receiving a response result corresponding to the service request returned by the server; The response result is sent to the caller.

7. The request processing method according to claim 6, characterized in that: After the step of receiving a response result corresponding to the service request returned by the server, the method further includes: Invoking the response interceptor; Detecting, based on the response interceptor, whether a cache strategy is set in the request configuration of the business request; If a cache policy is set in the request configuration of the business request, an expiration time corresponding to the response result is generated; Based on the response interceptor, the response result and the expiration time are stored in the cache.

8. A request processing device, characterized in that: include: A first receiving module, used for receiving a service request to be processed; An interception module, used to intercept the service request based on a preset request interceptor; A processing module, used for calculating the unique identifier of the service request, and determining whether there is a first identifier that is the same as the unique identifier and has not expired in a preset cache; a determination module, configured to determine whether there is an original request having a second identifier identical to the unique identifier in a preset active request record if the first identifier does not exist in the cache; A deletion module, configured to delete the service request if the original request exists in the active request record; A first acquisition module is used to monitor the response of the original request based on a preset response interceptor, and obtain a target response result corresponding to the original request after the response interceptor monitors that the original request has been processed; The forwarding module is used to forward the target response result to the caller corresponding to the business request.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the request processing method according to any one of claims 1 to 7 when executing the computer-readable instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the request processing method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Interface repeated request processing method and system based on Axios

    CN114189559A

  • Axios-based repeated request processing method

    CN116938910A

  • Anti-repetition and automatic caching front-end request scheme

    CN117640757A

  • Apparatus and methods for managing outstanding transactions between one or more requesting units and a target unit

    US20240264969A1

Cited By

  • Method and system for processing API request, storage medium and electronic equipment

    CN121144064A