Interface call processing method, electronic device and storage medium
By calculating the time stamp difference and preset frequency of the interface call request, and releasing or rejecting the interface call request, the problem of waste of network resources caused by the high interface call frequency is solved, and reasonable interface call frequency management is achieved.
Patent Information
- Application Number
- CN202411420669.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-10-12
AI Technical Summary
When the interface calls frequency is high or the interface calls data is not cached, the prior art cannot effectively avoid the invalid call frequency of the interface, resulting in waste of network resources.
By obtaining the unique identification string of the interface call request, calculate the time stamp difference between it and the target identification string in the preset request identification pool, compare the frequency with the preset interface call, and release the interface call request if it is greater than the frequency to avoid invalid calls .
It effectively avoids the waste of network resources caused by high interface call frequency, ensures that interface calls are carried out within the appropriate frequency, and avoids invalid calls.
Smart Images

Figure CN118939455B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for processing an interface call, an electronic device, and a storage medium. Background Art
[0002] In software development, interface calls are a common way of front-end and back-end interaction. When there is a page initialization request or user interaction occurs in the back-end data exchange, the interface call is often implemented through ajax or fetch.
[0003] However, in the current interface call related processing operations, when the interface call frequency is relatively frequent or the interface call data corresponding to the current interface call request is not cached, the current interface call request will not be stopped. Instead, the interface corresponding to the interface call request will be called frequently, resulting in a waste of network resources due to the high frequency of invalid interface calls.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present application is to provide an interface call processing method, an electronic device and a storage medium, aiming to solve the technical problem that the current interface call-related processing operations have a high frequency of invalid interface calls, which causes a waste of network resources.
[0006] To achieve the above purpose, the present application proposes a method for processing an interface call, which includes:
[0007] When an interface call request is detected, a unique identification string of the interface call request is obtained;
[0008] When a target identification string is extracted from a preset request identification pool based on the unique identification string, a timestamp difference between a unique timestamp corresponding to the unique identification string and a target timestamp corresponding to the target identification string is calculated;
[0009] The timestamp difference is compared with the preset interface call frequency. When the timestamp difference is greater than the preset interface call frequency, the interface call request is released.
[0010] In one embodiment, the step of obtaining the unique identification string of the interface call request includes:
[0011] Parse the unique identification string to obtain the interface call data, and determine whether the immediate execution identification bit can be detected in the interface call data;
[0012] If the immediate execution flag can be detected in the interface call data, the interface call request is released.
[0013] In one embodiment, after the step of determining whether an immediate execution flag can be detected in the interface call data, the following steps are included:
[0014] If the immediate execution flag cannot be detected in the interface call data, it is determined whether preset interface call data matching the interface call data is inserted into the preset request flag pool;
[0015] If no preset interface call data matching the interface call data is inserted, when it is detected that the remaining volume of the preset request identification pool is greater than the preset volume, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string into the preset request identification pool is recorded.
[0016] In one embodiment, if no preset interface call data matching the interface call data is inserted, the step includes:
[0017] When it is detected that the remaining volume of the preset request identifier pool is less than the preset volume, the insertion timestamps corresponding to the preset identifier strings in the preset request identifier pool are obtained;
[0018] After deleting the preset identification strings whose insertion timestamps are earlier than those of other preset identification strings, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string into the preset request identification pool is recorded.
[0019] In one embodiment, after the step of determining whether preset interface call data matching the interface call data is inserted into the preset request identifier pool, the following steps are included:
[0020] If preset interface call data matching the interface call data is inserted, determining the preset identification string corresponding to the preset interface call data matching the interface call data as the target identification string;
[0021] The target identification string is extracted from the preset request identification pool, and the steps of extracting the target identification string from the preset request identification pool based on the unique identification string are performed.
[0022] In one embodiment, the step of calculating the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string includes:
[0023] Compare the timestamp difference with the preset interface call frequency. When the timestamp difference is less than the preset interface call frequency, return information indicating request failure based on the interface call request; and insert the target identification string into the preset request identification pool, and record the current insertion timestamp of the target identification string into the preset request identification pool.
[0024] In one embodiment, the step of releasing the interface call request includes:
[0025] The target identification string is inserted into the preset request identification pool, and the current insertion timestamp of the target identification string being inserted into the preset request identification pool is recorded.
[0026] In one embodiment, before the step of detecting the interface call request, the method includes:
[0027] A cache pool is established, and a number of interface addresses to be initiated and request header information corresponding to each interface address to be initiated are obtained, and the interface addresses to be initiated and the request header information corresponding to the interface addresses to be initiated are combined into a preset identification string and cached into the cache pool to generate a preset request identification pool.
[0028] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the interface call processing method as described above.
[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the interface call processing method described above are implemented.
[0030] One or more technical solutions proposed in this application have at least the following technical effects:
[0031] It is proposed that when an interface call request is detected, a unique identification string of the interface call request is obtained, and when a target identification string is extracted from a preset request identification pool based on the unique identification string, the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string is calculated, the timestamp difference is compared with the preset interface call frequency, and when the timestamp difference is greater than the preset interface call frequency, the interface call request is released.
[0032] The present application obtains the unique identification string corresponding to the detected interface call request, and when it is determined through the unique identification string that it can extract the corresponding target identification string from the preset request identification pool, it is determined that the interface to be called by the interface call request has been cached, thereby avoiding the situation where the interface to be called is not cached but the interface call request is still released, resulting in frequent invalid calls to the interface. Because the target timestamp corresponding to the extracted target identification string is the last call operation time of the interface to be called, the time interval between the last call operation time and the current call operation time can be obtained by calculating the timestamp difference between the unique identification string and the target timestamp, and the timestamp difference is compared with the preset By comparing the interface call frequency, it can be obtained whether the distance between the last call operation time and the current call operation time is close, so as to determine whether the interface call frequency is relatively frequent. When the timestamp difference is greater than the preset interface call frequency, it means that the distance between the last call operation time and the current call operation time is relatively far, and the interface call frequency is not relatively frequent. The interface can be called normally. At this time, the interface call request is released to realize the interface call. That is, the present application adds a verification step before the interface call step to determine whether the interface has been cached and whether the interface call is frequent, and the interface call request is rejected or released, so as to avoid the waste of network resources caused by the high frequency of invalid calls of the interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0035] Figure 1 A flowchart of an embodiment of a method for processing an interface call of the present application is provided;
[0036] Figure 2 This is a schematic diagram of the structure of the interface call processing device of this application;
[0037] Figure 3 A brief flowchart of the processing method for calling the application interface;
[0038] Figure 4 A schematic diagram of the device structure of the hardware operating environment involved in the interface call processing method in the embodiment of the present application.
[0039] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0040] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0041] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0042] The main solution of the embodiment of the present application is: when an interface call request is detected, a unique identification string of the interface call request is obtained; when a target identification string is extracted from a preset request identification pool based on the unique identification string, the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string is calculated; the timestamp difference is compared with the preset interface call frequency, and when the timestamp difference is greater than the preset interface call frequency, the interface call request is released.
[0043] Due to the current interface call related processing operations, when the interface call frequency is relatively frequent or the interface call data corresponding to the current interface call request is not cached, the current interface call request will not be stopped. Instead, the interface corresponding to the interface call request will be called frequently, resulting in a waste of network resources due to the high frequency of invalid interface calls.
[0044] The present application provides a solution, which obtains the unique identification string corresponding to the detected interface call request, and determines through the unique identification string that it can extract the corresponding target identification string from the preset request identification pool, and determines that the interface to be called by the interface call request has been cached, thereby avoiding the situation where the interface to be called is not cached but the interface call request is still released, resulting in frequent invalid calls to the interface, and because the target timestamp corresponding to the extracted target identification string is the last call operation time of the interface to be called, by calculating the timestamp difference between the unique identification string and the target timestamp, the time interval between the last call operation time and the current call operation time can be obtained, and the time By comparing the timestamp difference value with the preset interface call frequency, it can be obtained whether the previous call operation time is close to the current call operation time, so as to determine whether the interface call frequency is relatively frequent. When the timestamp difference value is greater than the preset interface call frequency, it means that the previous call operation time is far from the current call operation time, and the interface call frequency is not relatively frequent. The interface can be called normally. At this time, the interface call request is released to realize the interface call. That is, the present application adds a verification step before the interface call step to determine whether the interface has been cached and whether the interface call is frequent, and the interface call request is rejected or released, so as to avoid the waste of network resources caused by the high frequency of invalid calls of the interface.
[0045] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a terminal device, etc. that can realize the above functions. The following takes an electronic device as an example to illustrate this embodiment and the following embodiments.
[0046] Based on this, the embodiment of the present application provides a method for processing an interface call, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the method for processing interface calls of the present application.
[0047] In this embodiment, the method for processing the interface call includes steps S10 to S30:
[0048] Step S10: when an interface call request is detected, a unique identification string of the interface call request is obtained.
[0049] This embodiment is based on Figure 2 The interface shown is implemented by a call processing device.
[0050] When the interface call processing device detects an interface call request initiated by an application or service, it receives the interface call request and obtains the unique identification string in the interface call request, so as to determine the interface call data corresponding to the interface to be called by the interface call request through the unique identification string, so as to perform subsequent verification steps of whether the interface has been cached and the frequency of the interface call according to the interface call data, and judge whether the interface to be called can be called normally, so as to avoid the abnormal phenomenon of high invalid call frequency of the interface caused by releasing the interface call request when the interface to be called cannot be called normally.
[0051] Among them, when an application or service initiates an interface call request, the application or service will generate a unique identification string corresponding to the interface path and request header parameters of the interface to be called and include it in the interface call request. When the application or service needs to respond quickly to external requests or events, an immediate execution flag will be added to the corresponding unique identification string for the quick call of the required interface.
[0052] In a feasible implementation manner, step S11 may be included before step S10:
[0053] Step S11, establish a cache pool, and obtain a number of interface addresses to be initiated and request header information corresponding to each interface address to be initiated, and combine the interface addresses to be initiated and the request header information corresponding to the interface addresses to be initiated into a preset identification string and cache it in the cache pool to generate a preset request identification pool.
[0054] It should be noted that the preset request identifier pool in the interface call processing device needs to be preset.
[0055] First, a cache pool is established in the interface call processing device, and the interface address to be initiated and the request header information corresponding to the interface address to be initiated of the interface that may be called by the application and / or service that has established a connection relationship with the interface call processing device are obtained. After each interface address to be initiated and its corresponding request header information are combined into a preset identification string, multiple preset identification strings will be obtained. The multiple preset identification strings are inserted into the cache pool in sequence, and the timestamps of their insertion into the cache pool are recorded to generate a preset request identification pool, thereby achieving a strong association between the interface call processing device and the application and / or service that has established a connection relationship with it, and avoiding the situation where the preset identification string stored in the generated preset request identification pool and the unique identification string corresponding to the interface call request that is connected cannot match multiple times.
[0056] It should be further explained that before the interface call processing device is put into normal use, it is necessary to initialize the interface call processing device, that is, to reset the preset interface call frequency used by the interface call processing device to determine whether the interface call is frequent, and to reset the total volume of the preset request identification pool. This setting is customized based on the actual interface call needs.
[0057] Step S20, when a target identification string is extracted from a preset request identification pool based on the unique identification string, a timestamp difference between a unique timestamp corresponding to the unique identification string and a target timestamp corresponding to the target identification string is calculated.
[0058] If, during the verification step of whether the execution interface has been cached, it is verified that the interface to be called has been cached, then a target identification string matching the unique identification string can be extracted from the preset request identification pool. At this time, it is necessary to calculate the timestamp difference between the unique timestamp of the unique identification string and the target timestamp corresponding to the extracted target identification string, so as to perform a verification step of whether the interface calls are frequent.
[0059] The interface address and request header information in the target identification string are the same as the interface address and request header information to be initiated in the unique identification string, and the interface to be called by the unique identification string is the same as the interface called by the target identification string.
[0060] The unique timestamp indicates the call time point when the interface call request corresponds to the interface call, and the target timestamp indicates the call time point when the interface was called last time. Therefore, by calculating the timestamp difference between the unique timestamp and the target timestamp, the time interval between the time point of the previous interface call operation and the time point of the current interface call operation can be obtained, and then the calling frequency of the interface can be obtained, and it can be judged whether the two interface call operations will cause the adverse situation of frequent interface calls to the interface.
[0061] Step S30, comparing the timestamp difference with the preset interface call frequency, and when it is found that the timestamp difference is greater than the preset interface call frequency, releasing the interface call request.
[0062] It should be noted that the preset interface call frequency refers to the time point when any interface can be called based on the current interface call operation, and the time interval between the time point corresponding to the previous interface call operation of the current interface call operation. Therefore, when the timestamp difference is compared with the preset interface call frequency and the timestamp difference is greater than the preset interface call frequency, it means that the call time points between the current interface call operation and the previous interface call operation of the interface are far apart, that is, the interface call based on the current interface call operation is not within the previous call frequency of the interface, and there is no situation where the interface call frequency is too high. Therefore, at this time, the interface call processing device will release the incoming interface call request to realize the effective calling of the interface.
[0063] In a feasible implementation manner, step S31 is included after step S30:
[0064] Step S31, inserting the target identification string into the preset request identification pool, and recording the current insertion timestamp of the target identification string into the preset request identification pool.
[0065] After it is determined through the target identification string that the call time points between the previous interface call operation and the previous interface call operation are far apart, and there is no abnormal phenomenon of frequent interface calls when calling the interface corresponding to the target identification string, it is necessary to update the target timestamp of the target identification string to the timestamp corresponding to the current interface call operation, that is, the target identification string needs to be reinserted into the preset request identification pool so that the corresponding call operation can be performed when the next interface call request is accessed. At the same time, the current insertion timestamp when the target identification string is inserted into the preset request identification pool is recorded, and the current insertion timestamp is used as the target timestamp of the target identification string to avoid the situation where when the target identification string is extracted again, its corresponding target timestamp is not the time point corresponding to the previous interface call operation, and the interface call frequency judgment is wrong.
[0066] In this embodiment, when an interface call request is detected, a unique identification string of the interface call request is obtained; when a target identification string is extracted from a preset request identification pool based on the unique identification string, the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string is calculated; the timestamp difference is compared with the preset interface call frequency, and when the timestamp difference is greater than the preset interface call frequency, the interface call request is released, that is, a verification step is added before the interface call step to verify whether the interface has been cached and the frequency of the interface call, and the interface call request is rejected or released, so as to avoid waste of network resources caused by the high frequency of invalid calls of the interface.
[0067] In another feasible implementation manner, after step S10, steps S11 to S12 may also be included:
[0068] Step S11, parsing the unique identification string to obtain interface call data, and determining whether an immediate execution identification bit can be detected in the interface call data.
[0069] Step S12: If the immediate execution flag can be detected in the interface call data, the interface call request is released.
[0070] In step S10, it is pointed out that when an application or service needs to quickly respond to an external request or event, an immediate execution flag will be added to the corresponding unique identification string for the quick call of the required interface. Therefore, after parsing the unique identification string corresponding to the interface call request and obtaining the interface call data in the unique identification string, a test will be performed to see if there is an immediate execution flag in the interface call data, so as to avoid network anomalies, waste of system resources, and reduced service stability caused by untimely response.
[0071] After the immediate execution identification bit is detected in the interface call data of the unique identification string, the incoming interface call request is immediately released to implement the call operation of the interface to be called by the interface call request.
[0072] In another feasible implementation manner, after step S11, steps S13 to S16 may be further included:
[0073] Step S13: If the immediate execution flag cannot be detected in the interface call data, it is determined whether preset interface call data matching the interface call data is inserted into the preset request identifier pool.
[0074] If the immediate execution flag is not detected in the interface call data of the unique identification string, it means that the program application or service that inputs the interface call request does not need to respond quickly to external requests or events. At this time, the verification steps of whether the interface has been cached and the frequency of the interface call can be executed.
[0075] First, a verification step is performed to determine whether the interface has been cached. The address of the interface to be initiated and its corresponding request header parameters in the parsed interface call data are compared with the address of the interface to be initiated and its corresponding request header parameters corresponding to each preset identifier string in the preset request identification pool, to determine whether preset interface call data matching the interface call data is cached in the preset request identification pool, so as to determine whether the interface corresponding to the interface call data has received a request, and further determine whether the interface corresponding to the interface call data is accessible and whether it can process the request normally.
[0076] Step S14, if the preset interface call data matching the interface call data is not inserted, then when it is detected that the remaining volume of the preset request identification pool is greater than the preset volume, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string into the preset request identification pool is recorded.
[0077] If it is detected that there is no preset interface call data cached in the preset request identification pool that matches the interface call data, it means that the interface corresponding to the interface call data has not received a request, that is, the interface corresponding to the interface call data cannot be accessed normally, and there is a risk of request processing failure based on this interface.
[0078] Therefore, at this time, the unique identification string corresponding to the interface call data needs to be inserted into the preset request identification pool, and the interface corresponding to the unique identification string needs to be cached so that it can be accessed normally. When inserting a new identification string into the preset request identification pool, it is necessary to confirm the current remaining capacity of the preset request identification pool to confirm whether its remaining capacity is sufficient for inserting the unique identification string.
[0079] If the detection confirms that the current remaining volume of the preset request identifier pool is greater than the preset volume, it means that the unique identifier string can be inserted into the preset request identifier pool without affecting the preset request identifier pool and causing no insertion error of the unique identifier string. The preset volume refers to the volume required to insert a new identifier string (unique identifier string) into the preset request identifier pool.
[0080] At the same time, the current insertion timestamp when the unique identification string is inserted into the preset request identification pool is recorded, so that when the unique identification string is subsequently extracted as the target identification string, the interface call frequency can be determined and the interface call request can be rejected.
[0081] Step S15: when it is detected that the remaining volume of the preset request identifier pool is less than the preset volume, the insertion timestamps corresponding to the preset identifier strings in the preset request identifier pool are obtained.
[0082] Step S16, after deleting the preset identification strings whose insertion timestamps are earlier than those of other preset identification strings, insert the unique identification string into the preset request identification pool, and record the current insertion timestamp of the unique identification string into the preset request identification pool.
[0083] When it is detected that the current remaining volume of the preset request identification pool is less than the preset volume, it means that the unique identification string cannot be effectively inserted into the preset request identification pool at this time. However, in order to ensure that the interface required to be called by the unique identification string can be normally identified when the next interface call request is incoming, a preset identification string cached in the preset request identification pool can be deleted at this time, and the deletion standard is the preset identification string that has not been extracted for a long time.
[0084] Get the insertion timestamps corresponding to each preset identification string cached in the preset request identification pool, and compare each insertion timestamp to obtain the preset identification string whose insertion timestamp is earlier than other insertion timestamps, indicating that the preset identification string has not been extracted for a long time. Deleting it can expand the remaining capacity of the preset request identification pool and enable the unique identification string to be effectively inserted.
[0085] When the unique identification string is inserted into the preset request identification pool, the current insertion timestamp when the unique identification string is inserted into the preset request identification pool is recorded, and then the interface call request is rejected.
[0086] Furthermore, after step S13, steps S17 to S18 may be included:
[0087] Step S17: If preset interface calling data matching the interface calling data is inserted, then the preset identification character string corresponding to the preset interface calling data matching the interface calling data is determined as the target identification character string.
[0088] Step S18, extracting the target identification string from the preset request identification pool, and executing the steps when the target identification string is extracted from the preset request identification pool based on the unique identification string.
[0089] If it is detected that preset interface call data matching the interface call data is cached in the preset request identification pool, it means that the interface corresponding to the interface call data has received a request, that is, the interface corresponding to the interface call data can be accessed normally. Therefore, at this time, the preset identification string corresponding to the preset interface call data matching the interface call data is directly extracted. After it is extracted and determined as the target identification string, a verification step is performed to determine whether the interface call is frequent, that is, step S20 is executed to ensure that after the interface call request is released, the interface to be called by the interface call request can be effectively called, thereby avoiding the waste of network resources caused by frequent invalid interface call operations.
[0090] In another feasible implementation manner, step S32 may be further included after step S30:
[0091] Step S32, compare the timestamp difference with the preset interface call frequency, and when the timestamp difference is less than the preset interface call frequency, return information indicating request failure based on the interface call request, and insert the target identification string into the preset request identification pool, and record the current insertion timestamp of the target identification string into the preset request identification pool.
[0092] When comparing the timestamp difference with the preset interface call frequency and obtaining that the timestamp difference is less than the preset interface call frequency, it indicates that the call time points between the current interface call operation of the interface and the previous interface call operation are relatively close, that is, the interface call based on the current interface call operation is within the previous call frequency of the interface, and there is a situation where the interface call frequency is too high. Therefore, at this time, the interface call processing device will reject the interface call request that is received to avoid invalid calls of the interface.
[0093] At the same time, the target identification string needs to be reinserted into the preset request identification pool so that the corresponding call operation can be performed when the next interface call request is accessed. At the same time, the current insertion timestamp when the target identification string is inserted into the preset request identification pool is recorded, and the current insertion timestamp is used as the target timestamp of the target identification string to avoid the situation where when the target identification string is extracted again, its corresponding target timestamp is not the time point corresponding to the last interface call operation, resulting in incorrect interface call frequency judgment.
[0094] For example, to help understand the implementation process of the interface call processing method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of an interface call processing method is provided, specifically:
[0095] Get the unique identification string corresponding to the interface call request, and parse it to get the interface call data (i.e. Figure 3 After step S1 in step S2), it is determined whether an immediate execution flag (i.e. Figure 3 In step S2 of the above example, if the interface call request can be detected, the interface call request is released (i.e. Figure 3 If it cannot be detected, it is determined whether a preset identification string (ie, Figure 3 In step S4 of the above, if the request cannot be extracted, then check whether the current remaining volume of the preset request identifier pool is greater than the preset volume (i.e. Figure 3In step S9 of the preset request identifier pool, if the current remaining capacity is greater than the preset capacity, the unique identification string is inserted into the preset request identifier pool, and the current insertion timestamp of the unique identification string insertion is recorded, and the interface call request is rejected (i.e. Figure 3 Step S10 in the preset request identification pool); if the current remaining capacity of the preset request identification pool is less than the preset capacity, then after deleting a preset identification string in the preset request identification pool, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string when it is inserted is recorded, and the interface call request is rejected at the same time (i.e. Figure 3 Step S11 in the process); if a preset identification string matching the unique identification string can be extracted from the preset request identification pool, the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the preset identification string is calculated (i.e. Figure 3 In step S5, it is determined whether the timestamp difference is greater than the preset interface call frequency (i.e. Figure 3 In step S6 of the above process, if the timestamp difference is greater than the preset interface call frequency, the interface call request is released, and the preset identification string is reinserted into the preset request identification pool, and the current insertion timestamp (i.e., Figure 3 Step S8 in the above); if the timestamp difference is less than the preset interface call frequency, the interface call request is rejected, and the preset identification string is reinserted into the preset request identification pool, and the current insertion timestamp (i.e., the current insertion timestamp) of the preset identification string when it is inserted is recorded. Figure 3 , step S7 in the above process).
[0096] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the processing method of the interface call of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0097] The present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the processing method of the interface call in the above-mentioned embodiment 1.
[0098] Reference below Figure 4, which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic device in the embodiments of the present application may include but is not limited to mobile terminals such as laptop computers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0099] like Figure 4 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0100] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a 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 device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0101] The electronic device provided by the present application adopts the method for processing interface calls in the above embodiment, which can solve the technical problem that the related processing operations of the current interface calls have a high frequency of invalid interface calls, resulting in a waste of network resources. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the method for processing interface calls provided in the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0102] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0103] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0104] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the processing method of the interface call in the above-mentioned embodiment.
[0105] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, 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: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0106] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0107] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device: when an interface call request is detected, obtains a unique identification string of the interface call request; when a target identification string is extracted from a preset request identification pool based on the unique identification string, calculates the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string; compares the timestamp difference with the preset interface call frequency, and when the timestamp difference is greater than the preset interface call frequency, releases the interface call request.
[0108] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the 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 square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / 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.
[0110] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0111] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned interface call processing method, and can solve the technical problem that the current interface call-related processing operations have a high frequency of invalid interface calls that causes waste of network resources. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the interface call processing method provided by the above-mentioned embodiment, and will not be repeated here.
[0112] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for processing an interface call, characterized in that: The processing method of the interface call includes: When an interface call request is detected, obtaining a unique identification string of the interface call request; When a target identification string is extracted from a preset request identification pool based on the unique identification string, a timestamp difference between a unique timestamp corresponding to the unique identification string and a target timestamp corresponding to the target identification string is calculated; Compare the timestamp difference with the preset interface call frequency, and when it is found that the timestamp difference is greater than the preset interface call frequency, release the interface call request; The step of obtaining the unique identification string of the interface call request includes: Parsing the unique identification string to obtain interface call data, and determining whether an immediate execution identification bit can be detected in the interface call data; If the immediate execution flag can be detected in the interface call data, then the interface call request is released; If the immediate execution flag cannot be detected in the interface call data, determining whether preset interface call data matching the interface call data is inserted into the preset request identifier pool; If no preset interface call data matching the interface call data has been inserted, then when it is detected that the remaining volume of the preset request identification pool is greater than the preset volume, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string inserted into the preset request identification pool is recorded.
2. The method for processing an interface call according to claim 1, characterized in that: After the step of inserting the preset interface call data matching the interface call data, the following steps are included: When it is detected that the remaining volume of the preset request identifier pool is less than the preset volume, obtaining the insertion timestamps corresponding to the preset identifier strings in the preset request identifier pool; After deleting the preset identification strings whose insertion timestamps are earlier than those of other preset identification strings, the unique identification string is inserted into the preset request identification pool, and the current insertion timestamp of the unique identification string inserted into the preset request identification pool is recorded.
3. The method for processing an interface call according to claim 2, characterized in that: After the step of determining whether preset interface call data matching the interface call data is inserted into the preset request identifier pool, the following steps are included: If preset interface call data matching the interface call data is inserted, determining the preset identification string corresponding to the preset interface call data matching the interface call data as the target identification string; The target identification string is extracted from the preset request identification pool, and the steps of extracting the target identification string from the preset request identification pool based on the unique identification string are performed.
4. The method for processing an interface call according to claim 1, characterized in that: The step of calculating the timestamp difference between the unique timestamp corresponding to the unique identification string and the target timestamp corresponding to the target identification string includes: Comparing the timestamp difference with a preset interface call frequency, and returning information indicating request failure based on the interface call request when the timestamp difference is less than the preset interface call frequency; and The target identification string is inserted into the preset request identification pool, and a current insertion timestamp of the target identification string being inserted into the preset request identification pool is recorded.
5. The method for processing an interface call according to claim 1, characterized in that: The step of releasing the interface call request includes: The target identification string is inserted into the preset request identification pool, and a current insertion timestamp of the target identification string being inserted into the preset request identification pool is recorded.
6. The method for processing an interface call according to claim 1, characterized in that: The step of detecting the interface call request includes: A cache pool is established, and a number of interface addresses to be initiated and request header information corresponding to the interface addresses to be initiated are obtained, and the interface addresses to be initiated and the request header information corresponding to the interface addresses to be initiated are combined into a preset identification string and cached in the cache pool to generate a preset request identification pool.
7. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the method for processing an interface call as claimed in any one of claims 1 to 6.
8. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the method for processing an interface call according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Communication terminal, communication relay apparatus, communication processing system and method, and computer program
JP2004048335A