Request processing method, electronic equipment, storage medium and program product
By inserting a new node at the end of the task list to isolate different types of data operation requests, the logical conflicts and data inconsistency problems of multi-service modules when operating global data simultaneously are solved, and higher data consistency and processing efficiency are achieved.
Patent Information
- Application Number
- CN202510134750.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-06
- Publication Date
- 2025-06-20
AI Technical Summary
When multiple business modules or components operate global data at the same time, logical conflicts and data inconsistencies may occur, mainly due to uncertainty in the order of operations, race conditions and logical conflict complexity.
By receiving data operation requests for global data, another request type associated with the request type and the tail node of the task list is obtained. If the request types are different, a new node is inserted at the end of the task list and associated with the original request to ensure that different types of data operation requests are isolated.
It effectively reduces conflicts between requests for different types of data operation, avoids logical conflicts and data inconsistencies, and improves the system's data consistency and processing efficiency.
Smart Images

Figure CN120179351A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of computers, etc., and particularly relates to a request processing method, an electronic device, a storage medium, and a program product. Background Art
[0002] It is a common requirement in software development for multiple business modules or components to share and operate on the same global data, as it can improve the system's collaborative efficiency, data consistency, and user experience.
[0003] In the prior art, a centralized database can be used to store global data, and all business modules perform data operations through the database access interface of the centralized database.
[0004] However, when multiple business modules or components perform different types of operations on global data simultaneously, due to the combined effects of various factors such as the uncertainty of the operation order, race conditions, and the complexity of logical conflicts, logical conflicts and data inconsistencies may occur. Summary of the Invention
[0005] The present disclosure provides a request processing method, an electronic device, a storage medium, and a program product.
[0006] According to one aspect of the present disclosure, there is provided a request processing method, including: Receiving a first data operation request for global data; Obtaining a first request type of the first data operation request and a second request type of a second data operation request associated with a tail node of a task list of the global data, and nodes in the task list are processed one by one; When the first request type is different from the second request type, inserting a new node associated with the first data operation request at the tail of the task list.
[0007] According to the request processing method of at least one embodiment of the present disclosure, if the first request type is the same as the second request type, the request processing method includes: Associating the first data operation request with the tail node.
[0008] According to the request processing method of at least one embodiment of the present disclosure, the associating the first data operation request with the tail node includes: Obtaining a first identifier of a first list storing the second data operation request from the information of the tail node; Obtaining the first list of the first identifier; Adding the first data operation request to the first list.
[0009] The request processing method according to at least one embodiment of the present disclosure further includes: In response to a task processing instruction, obtain a to-be-processed node from the task list; Obtain at least one to-be-processed request associated with the to-be-processed node; Process the at least one to-be-processed request.
[0010] The request processing method according to at least one embodiment of the present disclosure, The obtaining a to-be-processed node from the task list includes: obtaining a to-be-processed node from the task list according to the priority; or, obtaining a to-be-processed node from the task list according to the index; or, obtaining a to-be-processed node from the head of the task list; or, obtaining a to-be-processed node from the tail of the task list; Optionally, the obtaining at least one to-be-processed request associated with the to-be-processed node includes: obtaining a second identifier of a second list storing requests associated with the to-be-processed node from the information of the to-be-processed node; obtaining the second list of the second identifier; obtaining the at least one to-be-processed request from the second list; Optionally, when the type of the at least one to-be-processed request is deletion, the processing the at least one to-be-processed request includes: deleting data from the current global data according to the at least one to-be-processed request to obtain post-deletion data; deleting blank rows and / or blank columns from the post-deletion data.
[0011] The request processing method according to at least one embodiment of the present disclosure, Before obtaining the first request type of the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data, it further includes: attempting to obtain the task list related to the global data; and If the attempt is successful, execute obtaining the first request type of the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data.
[0012] The request processing method according to at least one embodiment of the present disclosure, if the attempt fails, the request processing method further includes: Create the task list related to the global data; Insert a new node associated with the first data operation request at the tail of the task list.
[0013] According to another aspect of the present disclosure, there is provided an electronic device, including: a memory that stores execution instructions; and a processor that executes the execution instructions stored in the memory, such that the processor executes the request processing method according to any one of the embodiments of the present disclosure.
[0014] According to still another aspect of the present disclosure, there is provided a readable storage medium storing execution instructions, which are used to implement the request processing method according to any one of the embodiments of the present disclosure when executed by a processor.
[0015] According to yet another aspect of the present disclosure, there is provided a computer program product including a computer program, which implements the request processing method according to any one of the embodiments of the present disclosure when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.
[0017] Figure 1 It is a schematic diagram of an application scenario of the request processing method according to an embodiment of the present disclosure.
[0018] Figure 2 It is the flow of the request processing method according to an embodiment of the present disclosure Figure 1 .
[0019] Figure 3 It is the flow of the request processing method according to an embodiment of the present disclosure Figure 2 .
[0020] Figure 4 It is the flow of the request processing method according to an embodiment of the present disclosure Figure 3 .
[0021] Figure 5 It is Figure 4 the flowchart of the request joining method in the request processing method shown.
[0022] Figure 6 It is the flow of the request processing method according to an embodiment of the present disclosure Figure 4 .
[0023] Figure 7 It is Figure 6 the flowchart of the request obtaining method in the request processing method shown.
[0024] Figure 8 It is Figure 6 the flowchart of the deletion method in the request processing method shown.
[0025] Figure 9 is the flowchart of the request processing method according to an embodiment of the present disclosure Figure 5 .
[0026] Figure 10 is the flowchart of the request processing method according to an embodiment of the present disclosure Figure 6 .
[0027] Figure 11 is a schematic flowchart of the request processing method according to an embodiment of the present disclosure.
[0028] Figure 12 is a schematic block diagram of the structure of the request processing apparatus according to an embodiment of the present disclosure.
[0029] Figure 13 is a schematic block diagram of the structure of an electronic device configured with the request processing apparatus according to an embodiment of the present disclosure. Detailed Embodiments
[0030] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only used to explain the relevant content and do not limit the present disclosure. In addition, it should be noted that only the parts related to the present disclosure are shown in the drawings for the convenience of description.
[0031] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the accompanying drawings and embodiments.
[0032] Suppose there is an employee management system, which includes the following modules: the basic personnel information module (responsible for managing the basic information of employees, such as name, position, etc.), the attendance information module (responsible for updating the attendance information of employees, such as clock-in time, leave records, etc.) and the performance information module (responsible for updating the performance information of employees, such as sales volume, number of tasks completed, etc.). If the operation of deleting the basic information of a certain employee is executed during the modification of the attendance information and performance information of this employee, the modification operations of the attendance information and performance information will be invalid or may form orphan data (that is, the attendance information and performance information still exist in the system, but the corresponding basic personnel information cannot be found), resulting in data inconsistency; if the modification operations of the attendance information and performance information are about to start execution, and at this time the basic personnel information is deleted, this will lead to a business logic conflict because the basic data on which the modification operations depend no longer exists.
[0033] To this end, the present disclosure provides a request processing method, an electronic device, a storage medium, and a program product. A user can send a data operation request to an electronic device such as a server through a certain service module or component, and the electronic device such as the server performs corresponding request processing operations after receiving the data operation request.
[0034] Figure 1 FIG. 4 shows an application scenario of the request processing method according to an embodiment of the present disclosure. In this application scenario, multiple user terminals 100 and a request processing device 200 may be included. Each user terminal 100 communicates with the request processing device 200 through a network. The user terminal 100 is an entity responsible for sending a data operation request for a certain global data, and this entity carries a service module or component, and this entity may be a mobile phone, a tablet computer, a computer, etc.; the request processing device 200 is an entity that receives and processes data operation requests from multiple user terminals 100, such as a server, etc.
[0035] For the convenience of description and to make the technical solutions of the specific embodiments of the present disclosure easier to understand, before describing the request processing method implemented in the present disclosure, the technical terms involved in the specific embodiments of the present disclosure are explained as follows: Global data refers to data shared among multiple service modules or components.
[0036] The tail node refers to the last node in a linked list, a queue, or any linear data structure.
[0037] Figure 2 FIG. 16 shows an overall flowchart of a request processing method M100 according to an embodiment of the present disclosure. As Figure 2 shown, the method includes steps S110 to S130. Among them, this method can be executed by an electronic device such as a server.
[0038] Specifically, Figure 2 the method shown includes: Step S110, receiving a first data operation request for global data.
[0039] In some embodiments of the present disclosure, multiple service modules or components within a system can all operate on global data simultaneously, or some of them can operate on global data simultaneously, or they can operate on global data at different times. For multiple parallel data operation requests, the order of the data operation requests can be determined according to factors such as the operation request type, priority, business logic, etc., and then executed sequentially in order. Figure 2The request processing steps shown. In particular, in order to prevent the request processing software from being overloaded, rate limiting strategies such as the token bucket algorithm or the leaky bucket algorithm can also be used to control the rate at which the request processing software receives data operation requests, thereby improving the stability and response ability of the request processing software and ensuring that good services can still be provided in high-concurrency scenarios.
[0040] The sender of the first data operation request in step S110 can be any business module or component in a certain system that shares global data. For example: one of the commodity management module, order processing module, payment module, and user account module in an online shopping system; one of the user information module, post management module, comment module, and notification module in a social media system; one of the personnel basic information module, attendance management module, performance evaluation module, and training management module in a human resource management system; one of the account management module, transfer module, loan application module, and transaction record query module in an online banking system, etc. The first data operation request can indicate modifying or adding to the global data, or deleting some data from the global data, etc.
[0041] Step S120, obtain the first request type of the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data.
[0042] In some embodiments of the present disclosure, the tail node of the task list in step S120 is usually located at the end of the task list; however, for some special cases, the tail node may also appear at other positions in the task list. For example, when the task list is specifically a priority list, the tail node is the last node to be processed in the current task list, that is, the node with the lowest priority; the tail node of this priority list may be located in the middle or at the front. The first request type of the first data operation request in step S120 can be delete, add, or modify; the second request type of the second data operation request associated with the tail node can also be delete, add, or modify; the first request type and the second request type can be the same or different. In particular, in order to improve the acquisition efficiency of the second request type of the second data operation request associated with the tail node, the second request type can be stored in the information of the nodes in the task list; when obtaining the second request type of the second data operation request associated with the tail node of the global data through step S120, it can be directly obtained from the information of the tail node of the global data. The nodes in the task list in step S120 are processed one by one.
[0043] Step S120 can obtain the first request type of the first data operation request by means of keyword matching, format parsing, request analysis, etc.
[0044] Step S130, when the first request type is different from the second request type, insert a new node associated with the first data operation request at the end of the task list.
[0045] In some embodiments of the present disclosure, the specific process of inserting a new node associated with the first data operation request at the end of the task list through step S130 may include: First, create a new node, and use the first data operation request itself or the identifier, digest, etc. of the first data operation request as the data attribute of the new node, so that the new node is associated with the first data operation request; Second, traverse the task list according to the insertion conditions (such as index, value, priority, etc.) to find the target position (i.e., the end) for inserting the new node; Finally, insert the new node at the end of the task list.
[0046] In some embodiments of the present disclosure, when the first request type of the received first data operation request is different from the second request type of the second data operation request associated with the tail node of the task list, create a new node associated with the first data operation request, and the nodes in the task list are processed one by one, so that different types of data operation requests do not interfere with each other, which can significantly reduce the conflicts between different types of data operation requests (for example, avoid situations such as modifying the data operation request being processed during the process of processing the delete type of data operation request), thereby avoiding logical conflicts and data inconsistencies caused by processing different types of data operation requests simultaneously.
[0047] In some embodiments of the present disclosure, between step S110 and step S120, an input verification step may also be included, that is, verify the format and content of the first data operation request to determine whether it meets the expectations; if it meets the requirements, execute step S120; otherwise, an error code or exception information may be returned to indicate the cause of the error; if a potential security threat is detected, corresponding security measures may be taken, such as IP address blacklist, restricted access frequency, etc. Through input verification, the stability and security of the request processing software can be improved, and problems caused by invalid or malicious first data operation requests can be avoided.
[0048] Between step S110 and step S120, an authentication step may also be included, that is, verify the identity of the requester through tokens, usernames, passwords, etc. to determine whether the requester has the permission to send the first data operation request. Through authentication, the security of the request processing software can be further improved.
[0049] Further, as Figure 3 shown, the request processing method provided by the present disclosure may further include step S140 before step S130.
[0050] Step S140: Determine whether the first request type is the same as the second request type.
[0051] In some embodiments of the present disclosure, step S140 may use an equality operator (such as == or is) to determine whether the first request type is the same as the second request type; the determination result may be in the form of a boolean value. For example, true indicates that the first request type is the same as the second request type, and false indicates that the first request type is different from the second request type.
[0052] In some embodiments of the present disclosure, when it is determined through step S140 that the first request type is different from the second request type, step S130 is executed.
[0053] Determining whether the first request type is the same as the second request type through step S140 helps ensure that the first request type meets the requirements before inserting a new node associated with the first data operation request, reducing the possibility of exceptions during the request processing, thereby improving the security, effectiveness, and stability of the request processing.
[0054] Further, when the first request type is the same as the second request type, as Figure 4 shown, the request processing method provided by the present disclosure may further include step S150.
[0055] Step S150: Associate the first data operation request with the tail node.
[0056] In some embodiments of the present disclosure, the number of requests pointed to by the tail node of the task list may be one or more. Taking the number of requests currently pointed to by the tail node as n (n is a positive integer) as an example, after associating the first data operation request with the tail node through step S150, the number of requests pointed to by the tail node becomes n + 1.
[0057] A container (such as a data structure like a queue, list, set, etc.) may be set for each node in the task list to store all requests associated with each node. At this time, associating the first data operation request with the tail node through step S150 may specifically be adding the first data operation request to the container of the tail node through step S150. A head pointer of a linked list may also be maintained for each node in the task list, and the requests are concatenated through the linked list. At this time, associating the first data operation request with the tail node through step S150 may specifically be adding the first data operation request to the linked list of the tail node through step S150. A key-value pair structure or the like may also be used, taking the unique identifier of each node in the task list as the key and the associated request set as the value. At this time, associating the first data operation request with the tail node through step S150 may specifically be adding the first data operation request to the value corresponding to the key of the tail node through step S150.
[0058] In the request processing method provided by the present disclosure, when the first request type of the first data operation request is the same as the second request type of the second data operation request associated with the tail node of the task list, the first data operation request is associated with the tail node, so that consecutive data operation requests of the same type are associated with the same node, realizing the reentrant ability of the data operation request. Based on the reentrant ability of the data operation request, this method can also solve the problem that when managing data operation requests based on a distributed lock mechanism, locking and unlocking operations need to be performed for each data operation request, increasing the system overhead, and improving the request processing efficiency.
[0059] Regarding step S150, in some embodiments of the present disclosure, it may include steps S151 to S153 as Figure 5 shown.
[0060] Step S151, obtain the first identifier of the first list storing the second data operation request from the information of the tail node.
[0061] In some embodiments of the present disclosure, in order to improve the efficiency, accuracy, and flexibility of request processing, the information of the nodes in the task list may include the corresponding request type and unique identifier. The unique identifier is the identifier of the list associated with the node, and this list is used to store data operation requests; the unique identifier can be generated based on the timestamp of the node, or can be generated using algorithms such as the Universally Unique Identifier (UUID) algorithm, snowflake algorithm, hash algorithm, etc. At this time, the first identifier can be directly obtained from the information of the tail node through step S151.
[0062] Step S152, obtain the first list of the first identifier.
[0063] In some embodiments of the present disclosure, the request processing software can set a data structure capable of storing lists and their corresponding identifiers. When the data structure is a dictionary, step S152 can directly use the first identifier as the key to find the corresponding first list through hash; when the data structure is an array, step S152 can traverse the entire array, compare the first identifier with the identifier of each element in the array one by one, and obtain the first list when matching; when the data structure is a database, step S152 can query through SQL to retrieve the first list according to the first identifier.
[0064] Step S153, add the first data operation request to the first list.
[0065] In some embodiments of the present disclosure, the first data operation request may be inserted into the end of the first list through step S153; alternatively, according to the priority or specific conditions of the first data operation request, the first data operation request may be inserted into a specific position in the first list through step S153.
[0066] Specifically, to avoid duplication, before adding the first data operation request to the first list through step S153, it may also be checked whether the first data operation request already exists in the first list. To ensure the validity of the first list, before adding the first data operation request to the first list through step S153, the first list may also be checked and the expired or no longer needed requests therein may be cleared.
[0067] Steps S151 to S153 manage the first data operation request through a list, which can prevent direct coupling between the node and the data operation request, facilitating expansion and maintenance; and when each node is called, all relevant data operation requests in the list can be processed at one time, which is suitable for batch execution or parallel processing and can improve the processing efficiency.
[0068] Furthermore, as Figure 6 shown, the request processing method provided by the present disclosure may further include steps S160 to S180.
[0069] Step S160, in response to a task processing instruction, obtain a to-be-processed node from the task list.
[0070] In some embodiments of the present disclosure, step S160 may obtain a to-be-processed node from the task list according to the priority; alternatively, obtain a to-be-processed node from the task list according to the index; alternatively, obtain a to-be-processed node from the head of the task list; or obtain a to-be-processed node from the tail of the task list. Step S160 may arbitrarily select one of the above methods as the node obtaining method, or may also select one method to obtain according to requirements, the characteristics of the data structure, performance requirements, and the objectives of system design, etc.
[0071] Step S170, obtain at least one to-be-processed request associated with the to-be-processed node.
[0072] In some embodiments of the present disclosure, for a certain node, when the data operation request associated with the node is different in type from both its previous data operation request and its next data operation request, the number of data operation requests associated with the node is 1; when the data operation request associated with the node is the same in type as one or more of its previous data operation request(s) and / or one or more of its next data operation request(s), the number of data operation requests associated with the node is greater than or equal to 2. The number of pending requests associated with the pending node obtained through step S170 depends on how many consecutive data operation requests of the same type there are.
[0073] In some embodiments of the present disclosure, step S170 may obtain at least one pending request pointed to by the pending node according to the association relationship between the node and the data operation request in the task list, such as obtaining at least one pending request from the container corresponding to the pending node, obtaining at least one pending request from the linked list corresponding to the pending node, or obtaining at least one pending request from the key-value pair corresponding to the pending node, etc.
[0074] Step S180: Process at least one pending request.
[0075] In some embodiments of the present disclosure, the process of processing at least one pending request through step S180 is related to the operation request type of the at least one pending request; for example, when the operation request type of the at least one pending request is deletion, step S180 specifically deletes some data in the current global data according to the at least one pending request; when the operation request type of the at least one pending request is addition, step S180 specifically inserts the newly added data into the current global data according to the at least one pending request; when the operation request type of the at least one pending request is modification, step S180 specifically updates some data in the current global data according to the at least one pending request.
[0076] In some embodiments of the present disclosure, when the number of pending requests is greater than 1, in order to reduce the complexity brought by concurrency and facilitate tracking the request processing process, step S180 may specifically serially process at least one pending request. In particular, in order to improve the processing speed and more effectively utilize the resources of the request processing software, step S180 may also specifically process at least one pending request in parallel.
[0077] When parallel processing multiple requests to be processed, to improve consistency, it is possible to analyze the data ranges involved in each request and possible overlapping situations; for processing of requests with the same fields, serialize the corresponding requests for execution, or merge the corresponding requests into one request to ensure ultimate consistency; group requests that will not affect each other into the same operation group; for operation groups that may have conflicts, a concurrency control mechanism (such as optimistic lock, pessimistic lock) can be set up to prevent data conflicts; to ensure data consistency, transactions can be used to manage the request processing process. For example: start a new transaction for each operation group by starting a transaction, execute the processing operations within each operation group in the transaction by executing the processing transaction, commit the transaction when all requests in all operation groups are successfully processed, and roll back the transaction when a certain request fails; after designing the concurrency control mechanism and transactions, multi-threading or multi-processing can be used to parallelly execute the requests to be processed within each group; in particular, during the parallel processing through multi-threading or multi-processing, the status of each thread or process can also be monitored, and possible exceptions can be handled (for example: for exceptions such as global data connection failure, unavailability, or network error, appropriate recovery measures can be taken; for temporary failures, a retry logic can be set up to attempt to process the data operation request again), ensuring that all data operation requests can be executed smoothly. The above processing process is applicable to requests to be processed of the modification, addition, and deletion types.
[0078] In some embodiments of the present disclosure, after obtaining a processing result by processing at least one request to be processed through step S180, it can be directly output, or the processing result can be converted into a required format and then output. In particular, to improve the request processing speed, it is also possible to store frequently used data in the global data through a cache and / or store the calculation results through a cache, etc.
[0079] In some embodiments of the present disclosure, after processing at least one request to be processed through step S180 to obtain a processing result, the processing result can be notified to relevant personnel via email, instant message, text message, etc., thereby improving the transparency of information.
[0080] In some embodiments of the present disclosure, steps S160 to S180 can be executed after step S130, as Figure 6 shown; steps S160 to S180 can also be executed before step S130 or simultaneously with step S130, and the execution process is similar to that Figure 6 shown, and will not be elaborated here one by one.
[0081] By only obtaining one node to be processed each time a task is processed through steps S160 to S180, different types of data operation requests are isolated, thereby reducing logical errors in the request processing process and improving consistency.
[0082] Regarding step S170, in some embodiments of the present disclosure, it may include steps S171 to S173 as Figure 7 shown.
[0083] Step S171: Obtain a second identifier of a second list storing requests associated with the node to be processed from the information of the node to be processed.
[0084] In some embodiments of the present disclosure, Figure 7 the process of obtaining the second identifier in step S171 shown is similar to the process of obtaining the first identifier in Figure 5 step S151 shown, and will not be elaborated here one by one.
[0085] Step S172: Obtain a second list of the second identifier.
[0086] In some embodiments of the present disclosure, Figure 7 the process of obtaining the second list in step S172 shown is similar to the process of obtaining the first list in Figure 5 step S152 shown, and will not be elaborated here one by one.
[0087] Step S173: Obtain at least one pending request from the second list.
[0088] In some embodiments of the present disclosure, the second list may be stored in a memory, a database, a file, etc. When the second list is stored in the memory, step S173 may obtain at least one pending request from the second list through a simple reference; when the second list is stored in the database, step S173 may execute an SQL query to obtain at least one pending request from the second list; when the second list is stored in the file, step S173 may read the file content and parse it to obtain at least one pending request.
[0089] Steps S171 to S173 manage data operation requests through a list, which can prevent direct coupling between the node and the data operation requests, and thus more efficiently and reliably manage the complex relationship between the nodes and the data operation requests in the task list, facilitating expansion and maintenance.
[0090] Regarding step S180, when the type of at least one pending request is deletion, in some embodiments of the present disclosure, it may include steps S181 to S182 as Figure 8 shown.
[0091] Step S181: Delete data from the current global data according to at least one pending request to obtain the data after deletion.
[0092] In some embodiments of the present disclosure, data corresponding to at least one pending request can be deleted from the current global data through step S181 to obtain the data after deletion. The deletion process of step S181 can be executed in parallel or serially, etc., and is not limited herein.
[0093] Step S182: Delete blank rows and / or blank columns from the data after deletion.
[0094] In some embodiments of the present disclosure, when all cells in a row have no valid data, that is, all elements in the entire row are empty or 0, this row is a blank row; when all cells in a column have no valid data, that is, all elements in the entire column are empty or 0, this column is a blank column.
[0095] Step S182 can count the number of non-empty (non-missing) values in each row. If the number of non-empty values in a row is zero, it indicates that this row is a blank row; count the number of non-empty values in each column. If the number of non-empty values in a column is zero, it indicates that this column is a blank column; then all blank rows and / or blank columns can be removed from the data after deletion through a filtering operation.
[0096] After deleting some data in the global data through steps S181 and S182 and deleting blank rows and / or blank columns, it can improve data quality, save storage space, improve calculation efficiency, and improve data consistency and maintainability.
[0097] Furthermore, as Figure 9 shown, the request processing method provided by the present disclosure may further include step S190 before step S120.
[0098] Step S190: Try to obtain the task list related to the global data.
[0099] In some embodiments of the present disclosure, if the attempt in step S190 is successful, step S120 is executed. Step S190 can first determine the storage structure of the task list; if the storage structure is that the task list is directly stored as a variable in memory, step S190 can directly try to obtain the task list related to the global data through the variable name; if the storage structure is that the task list is an attribute or member variable of a certain object, step S190 can try to obtain the task list related to the global data through this object.
[0100] Through step S190, it can be ensured that the task list exists and is available, thereby avoiding errors caused by the non-existence or emptiness of the task list in subsequent steps, and improving the robustness of the request processing process.
[0101] At this time, as Figure 10As shown, when the attempt in step S190 fails, the request processing method provided by the present disclosure may further include step S200.
[0102] Step S200, create a task list related to global data.
[0103] In some embodiments of the present disclosure, after creating the task list through step S200, the process of inserting a new node associated with the first data operation request at the end of the task list in step S130 can be directly executed.
[0104] The process of creating a task list related to global data through step S200 may include: creating a global variable to store the task list, and this global variable can be defined at the module level so that it can be accessed anywhere in the request processing software, and the global variable should be an empty list initially, so that data operation requests can be added safely; in order to describe the detailed information of each data operation request such as operation type, operation object, operation parameters, etc., a task model can be defined, and this task model should contain sufficient information to describe the details of the data operation request. In order to enable all data operation requests to be added to the task list and ensure that the data operation requests are uniformly managed and scheduled before execution, a function can be designed to add the data operation requests to the task list.
[0105] Among them, the specific steps of adding a data operation request to the task list through the function may include: the function receives the detailed information of the data operation request such as operation type, operation object, operation parameters, etc.; the function creates an object of the task type according to the detailed information of the data operation request; the function adds the object to the task list. In particular, in order to prevent problems such as data inconsistency and data competition in a concurrent environment, after creating an object of the task type, a global lock can also be used to protect the concurrent access to the task list, and under the protection of the lock, the step of adding the object to the task list is executed; after the addition is completed, the lock is released to allow other threads or processes to continue to access the task list. In particular, in order to let developers or users immediately know whether the data operation request has been successfully added to the task list, a confirmation message can be printed after the function adds the data operation request to the task list, that is, a message is output to the console, log file or other output media to confirm that a certain data operation request has been successfully added to the task list.
[0106] Creating a task list when the attempt fails through step S200 can ensure the normal execution of the request processing process without interruption, and can improve the robustness of the request processing process, data consistency and system maintainability.
[0107] The request processing method provided by the present disclosure can be applied in multiple fields such as e-commerce, finance, Internet of Things, social media, etc.
[0108] Figure 11 An exemplary flowchart implemented based on the request processing method of the present disclosure is shown.
[0109] Figure 11 In the shown flowchart, taking the employee management system as an example, the request processing process may include: I. Receive a first data operation request for global data in the employee management system.
[0110] In some embodiments of the present disclosure, the global data in this step usually includes various information related to employees and their management, which may cover multiple aspects such as basic information of employees, attendance, performance, contract policies, equipment allocation, department structure, and user permissions.
[0111] II. Try to obtain a task list related to the global data.
[0112] In some embodiments of the present disclosure, the task list in this step can centrally manage all operations on the global data, and may include one or more of the information such as task description, type, priority, status, person in charge, deadline, related data, remarks, and attachments.
[0113] When the attempt to obtain the task list related to the global data in this step is successful, step III is executed; otherwise, step VI is executed.
[0114] III. Obtain the first request type of the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data.
[0115] IV. Associate the first data operation request with the tail node.
[0116] In some embodiments of the present disclosure, this step can be implemented by adding a data operation request to the list corresponding to the tail node for association.
[0117] V. Insert a new node associated with the first data operation request at the tail of the task list.
[0118] VI. Create a task list related to the global data.
[0119] In some embodiments of the present disclosure, after creating the task list related to the global data through this step, step V is executed to insert a new node into the task list.
[0120] In some embodiments of the present disclosure, the process of maintaining the task list of global data through the above steps and the process of processing the requests pointed to by the nodes in the task list can be executed by different threads. Each thread independently completes its own tasks. One thread is responsible for creating a task list and inserting a new node when receiving a data operation request for the first time, and this thread is also responsible for associating the data operation request with the tail node or inserting a new node when receiving a data operation request subsequently; another thread is responsible for monitoring the task list and executing the specific processing process when it is idle and there are unprocessed nodes in the task list.
[0121] The request processing method provided by the present disclosure organizes data operation requests through a task list, points adjacent data operation requests of the same type to the same node in the task list to achieve the reentrant ability of tasks; points adjacent data operation requests of different types to different nodes in the task list to isolate different types of data operation requests and achieve the mutual exclusion ability of different types of data operation requests, thereby reducing logical conflicts in the request processing process and improving data consistency.
[0122] Based on any of the above embodiments, the present disclosure also provides a request processing apparatus.
[0123] Figure 12 It is a structural schematic block diagram of a request processing apparatus according to an embodiment of the present disclosure.
[0124] As Figure 12 shown, the request processing apparatus includes: A request receiving module 110, configured to receive a first data operation request for global data.
[0125] A type obtaining module 120, configured to obtain a first request type of the first data operation request and a second request type of a second data operation request associated with the tail node of the task list of the global data, and the nodes in the task list are processed one by one.
[0126] A node inserting module 130, configured to insert a new node associated with the first data operation request at the tail of the task list when the first request type is different from the second request type.
[0127] Each of the above modules can be implemented by a computer program module. Figure 12 The shown request processing apparatus can be implemented based on a computer program module architecture.
[0128] For the specific implementation process of the functions and roles of each module in the above apparatus, refer to the implementation process of the corresponding steps in the above method in detail, which will not be elaborated here.
[0129] The execution subject of the request processing method in the specific embodiments of the present disclosure can be an electronic device such as a server.
[0130] Therefore, based on any of the above embodiments, the present disclosure also provides an electronic device, which can execute the request processing method of any of the above embodiments described in the present disclosure, and a request processing device of any of the above embodiments described above can be configured on the electronic device.
[0131] Figure 13 FIG. 6 is a structural schematic diagram of an electronic device 1000 configured with a request processing device 100 according to an embodiment of the present disclosure.
[0132] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application of the hardware and overall design constraints. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.
[0133] The bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Component (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only one connection line is shown in this figure, but it does not mean that there is only one bus or one type of bus.
[0134] The present disclosure also provides a readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, it is used to implement the above method. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read only memory (ROM), an erasable programmable read only memory (EPROM or flash memory), an optical fiber device, and a portable read only memory (CDROM), etc.
[0135] The present disclosure also provides a computer program product. The methods of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present disclosure are executed in whole or in part.
[0136] The computer program or instructions can be stored in a readable storage medium, or transmitted from one readable storage medium to another. For example, the computer program or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc; or it can be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.
[0137] Those skilled in the art should understand that the embodiments of the present disclosure can be provided as methods, systems, or computer program products. Therefore, the present disclosure can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.
[0138] The present disclosure is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate means for implementing the functions specified in one Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0139] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one process Figure 1 one process or a plurality of processes and / or blocks Figure 1 specified in one block or a plurality of blocks.
[0140] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or a plurality of processes and / or blocks Figure 1 specified in one block or a plurality of blocks.
[0141] In the description of this specification, the descriptions with reference to the terms "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples", etc. mean that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.
[0142] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0143] Those skilled in the art should understand that the above embodiments are only for clearly explaining the present disclosure and not for limiting the scope of the present disclosure. For those skilled in the art, other changes or modifications can be made on the basis of the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A request processing method, characterized in that: include: receiving a first data operation request for global data; Obtaining a first request type of the first data operation request and a second request type of the second data operation request associated with the tail node of the task list of the global data, wherein the nodes in the task list are processed one by one; as well as When the first request type is different from the second request type, a new node associated with the first data operation request is inserted at the end of the task list.
2. The request processing method according to claim 1, characterized in that: If the first request type is the same as the second request type, the request processing method includes: The first data operation request is associated with the tail node.
3. The request processing method according to claim 2, characterized in that: The associating the first data operation request with the tail node includes: Acquire a first identifier of a first list storing the second data operation request from the information of the tail node; obtaining a first list of said first identifiers; and The first data operation request is added to the first list.
4. The request processing method according to any one of claims 1 to 3, characterized in that: Also includes: In response to a task processing instruction, obtaining a to-be-processed node from the task list; Obtain at least one pending request associated with the pending node; as well as The at least one pending request is processed.
5. The request processing method according to claim 4, characterized in that: The obtaining a to-be-processed node from the task list includes: Obtain a to-be-processed node from the task list according to the priority; or, Obtain a to-be-processed node from the task list according to the index; or, Obtain a to-be-processed node from the head of the task list; or, Obtain a to-be-processed node from the tail of the task list; Optionally, obtaining at least one pending request associated with the pending node includes: Acquire, from the information of the node to be processed, a second identifier of a second list storing requests associated with the node to be processed; obtaining a second list of said second identifiers; and Retrieve the at least one pending request from the second list; Optionally, when the type of the at least one pending request is deletion, the processing of the at least one pending request includes: Deleting data from current global data according to the at least one pending request to obtain deleted data; and Empty rows and / or empty columns are deleted from the deleted data.
6. The request processing method according to any one of claims 1 to 3, characterized in that: Before obtaining the first request type of the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data, the method further includes: attempting to obtain the task list related to the global data; and If the attempt is successful, the first request type of the first data operation request for obtaining the first data operation request and the second request type of the second data operation request associated with the tail node of the task list of the global data are executed.
7. The request processing method according to claim 6, characterized in that: If the attempt fails, the request processing method further includes: Creating a task list related to the global data; and A new node associated with the first data operation request is inserted at the end of the task list.
8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the request processing method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the request processing method according to any one of claims 1 to 7 when executed by a processor.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the request processing method according to any one of claims 1 to 7 is implemented.