Query request processing method and device
By generating encrypted identifiers for chart query requests and detecting cache databases, the target thread is hibernated, solving the problem of waste of computing resources when multiple users are queried simultaneously, improving system responsiveness and reducing operational costs.
Patent Information
- Application Number
- CN202411945039.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-25
AI Technical Summary
When multiple users initiate the same chart query request at the same time, the system repeatedly executes the same calculation and rendering process, resulting in waste of computing resources, increased energy consumption and increased operational costs.
Encrypted query statement identification is generated for each query request and detects whether the same request identification exists in the cache database. If it exists, the target thread enters a dormant state, avoiding repeated calculation and rendering processes.
It significantly reduces resource and memory consumption, improves system responsiveness and thread utilization, and reduces operating costs.
Smart Images

Figure CN119884170A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for processing a query request. Background Art
[0002] With the development of technologies such as cloud computing and artificial intelligence, users' demands for data charts are becoming increasingly diversified and immediate, requiring the system to be able to quickly and accurately generate high-quality charts to meet data analysis needs in different scenarios.
[0003] Whenever a user submits a chart query request, the system immediately extracts data from the database, processes the data through the background computing engine, and then renders it using the graphics library, and finally returns the generated chart to the user. This method ensures the real-time and accuracy of the chart content.
[0004] However, for the same query initiated by multiple users almost at the same time, the system will repeatedly execute the same calculation and rendering process, which not only wastes computing resources but also increases energy consumption and operating costs. Summary of the invention
[0005] In view of this, the present invention provides a method and device for processing a query request.
[0006] In a first aspect, the present invention provides a method for processing a query request, the method comprising: obtaining a query statement corresponding to a target query request, and encrypting the query statement to obtain a first request identifier corresponding to the query statement; detecting whether there is a second request identifier identical to the first request identifier in a cache database; if there is a second request identifier identical to the first request identifier in the cache database, putting a target thread corresponding to the target query request to sleep; wherein the target thread is a thread that executes the target query request.
[0007] The query request processing method provided in this embodiment, when a query request is obtained, first generates an encrypted query statement identifier (first request identifier) for each request. Check whether there is a second request identifier that is the same as the first request identifier in the cache database. If a matching second request identifier is found, it means that a thread has previously processed the same query, and its result may have been cached. The target thread currently processing the request can be put into a dormant state instead of repeatedly executing the calculation and rendering process, reducing unnecessary calculation and rendering processes, and significantly reducing resource and memory consumption.
[0008] In one possible implementation, if there is a second request identifier identical to the first request identifier in the cache database, after the target thread corresponding to the target query request is put to sleep, the method also includes: after the target thread corresponding to the target query request is converted from a sleep state to a running state, detecting whether there is a second request identifier identical to the first request identifier in the cache database; if there is no second request identifier identical to the first request identifier in the cache database, querying the cache data corresponding to the target query request from the cache database according to the target query request.
[0009] The query request processing method provided in this embodiment can manage the life cycle of the thread more finely by setting the sleep duration of the target thread. If the sleep duration reaches the preset duration, it is necessary to re-check whether there is a second request identifier identical to the first request identifier in the cache database. When there is no second request identifier identical to the first request identifier in the cache database, it means that the previous query request has been processed. At this time, re-checking the cache database can ensure that the thread will not be in a dormant state indefinitely, thereby improving the utilization rate of the thread and the responsiveness of the system.
[0010] In a possible implementation, the method also includes: if there is a second request identifier that is identical to the first request identifier in the cache database, repeatedly executing the step of detecting whether there is a second request identifier that is identical to the first request identifier in the cache database after the target thread corresponding to the target query request is converted from a sleep state to a running state, until the number of repeated executions meets a preset number of times, and stopping executing the target query request.
[0011] The query request processing method provided in this embodiment, by setting a preset number of repeated executions, the system can ensure that the target thread will not be in a dormant state indefinitely due to a long cache miss, thereby avoiding the problem of query requests occupying threads due to invalidity.
[0012] Moreover, in the face of uncertain factors such as cache failure, data update or system abnormality, the repeated execution detection mechanism can enhance the fault tolerance of the system. Even if the initial cache misses, the system can try to obtain data through multiple attempts, thus improving the reliability and stability of the system.
[0013] In one possible implementation, if there is a second request identifier that is identical to the first request identifier in the cache database, before the target thread corresponding to the target query request is put to sleep, the method also includes: if there is a second request identifier that is identical to the first request identifier in the cache database, detecting whether there is cache data corresponding to the target query request in the cache database; if there is cache data corresponding to the target query request in the cache database, querying the cache data corresponding to the target query request from the cache database according to the target query request.
[0014] The query request processing method provided in this embodiment, when there is cache data matching the target query request in the cache, directly reading the data from the cache can greatly reduce the query processing time. Compared with querying from the original data source or database, cache reading is usually faster because the cache data is usually located in memory or faster storage media. In addition, by reducing direct access to the database or other storage system, the system can reduce its overall load. This not only helps protect the underlying storage system from the impact of high-concurrency queries, but also improves the stability and reliability of the system.
[0015] In a possible implementation, the method also includes: setting a merge identifier corresponding to the first request identifier in the cache database; if the cache data corresponding to the target query request does not exist in the cache database, querying the cache data corresponding to the target query request from the business database according to the target query request; after querying the cache data corresponding to the target query request from the business database, caching the cache data to the cache database and deleting the merge identifier.
[0016] The query request processing method provided in this embodiment can identify the same query request by setting a merge identifier in the cache database. If the cache data corresponding to the target query request does not exist in the cache database, the cache data corresponding to the target query request is queried from the business database according to the target query request, that is, when the cache data does not exist in the cache database, the cache data is queried from the business database, thereby avoiding the situation where the cache data cannot be queried.
[0017] At the same time, the cached data is cached in the cache database, and the merge identifier is deleted, so that the next time a query request corresponding to the cached data is obtained, the data can be directly queried from the cache database, saving a lot of time.
[0018] In a possible implementation, the method further includes: generating a query failure prompt corresponding to the target query request; and displaying the query failure prompt on a page.
[0019] In the query request processing method provided in this embodiment, when a user initiates a query request but fails to obtain data successfully, the system can promptly inform the user of the query result by displaying a query failure prompt. This avoids the situation where the user waits for a long time in vain or the system does not respond, and improves the friendliness and transparency of the user experience.
[0020] In a second aspect, the present invention provides a query request processing device, the device comprising: an acquisition module, used to acquire a query statement corresponding to a target query request, and encrypt the query statement to obtain a first request identifier corresponding to the query statement; a detection module, used to detect whether there is a second request identifier identical to the first request identifier in a cache database; a sleep module, used to put a target thread corresponding to the target query request to sleep if there is a second request identifier identical to the first request identifier in the cache database; wherein the target thread is a thread that executes the target query request.
[0021] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for processing query requests of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0022] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for processing a query request of the first aspect or any corresponding embodiment thereof.
[0023] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method for processing a query request of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 is a flowchart of a method for processing a query request according to an embodiment of the present invention;
[0026] Figure 2 is a structural block diagram of a query request processing device according to an embodiment of the present invention;
[0027] Figure 3 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0029] Based on relevant technologies, we can know that with the development of technologies such as cloud computing and artificial intelligence, users' demand for data charts is becoming increasingly diversified and immediate, requiring the system to be able to quickly and accurately generate high-quality charts to meet data analysis needs in different scenarios.
[0030] Whenever a user submits a chart query request, the system immediately extracts data from the database, processes the data through the background computing engine, and then renders it using the graphics library, and finally returns the generated chart to the user. This method ensures the real-time and accuracy of the chart content.
[0031] However, for the same query initiated by multiple users almost at the same time, the system will repeatedly execute the same calculation and rendering process, which not only wastes computing resources but also increases energy consumption and operating costs.
[0032] Based on this, the present invention provides a method for processing query requests. When a query request is obtained, an encrypted query statement identifier (first request identifier) is first generated for each request. Check whether there is a second request identifier that is the same as the first request identifier in the cache database. If a matching second request identifier is found, it means that a thread has processed the same query before, and its result may have been cached. The target thread currently processing the request can be put into a dormant state instead of repeatedly executing the calculation and rendering process, reducing unnecessary calculation and rendering processes, and significantly reducing resource and memory consumption.
[0033] According to an embodiment of the present invention, an embodiment of a method for processing a query request is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] In this embodiment, a method for processing a query request is provided, which can be used in computer devices, such as computers, servers, etc. Figure 1 FIG. 1 is a flow chart of a method for processing a query request according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0035] Step S101: obtain a query statement corresponding to a target query request, and encrypt the query statement to obtain a first request identifier corresponding to the query statement.
[0036] The target query request may indicate a specific query operation to be performed. For example, a query request to query certain data in a database to extract data. The query statement may be a SQL (Structured Query Language) statement or other database query language used to implement the target query request. The first request identifier may represent a unique identifier obtained by encrypting the query statement, which is used to distinguish different query requests.
[0037] Specifically, a query statement corresponding to a query request initiated by a user or a system is obtained, and then the query statement is encrypted using a certain encryption algorithm to generate a unique first request identifier.
[0038] As an example, a hash algorithm (such as MD5, SHA-256, etc.) may be used to encrypt the query statement to obtain a unique hash value of a fixed length as the first request identifier.
[0039] As an example, before encryption, the query statement can be normalized (eg, removing spaces, sorting parameters, etc.) to ensure that the same request identifier can be generated even if the format of the query statement is slightly different.
[0040] It should be noted that the number of query requests obtained can be multiple, and the target query request can be any one of the multiple query requests, that is, each query request needs to execute steps S101 to S103.
[0041] Step S102: Detect whether there is a second request identifier that is the same as the first request identifier in the cache database.
[0042] The second request identifier can indicate the query request that is currently being queried. When there is a query request, the request identifier can be pre-set in the cache database so that when a new query request (target query request) is obtained, it can be detected whether there is a second request identifier that is the same as the first request identifier in the cache database. For example: currently executing multiple query statements corresponding to query requests, the second request identifier corresponding to each query request can be request identifier A, request identifier B and request identifier C. After obtaining the target query request, the target query request and request identifier A, request identifier B and request identifier C can be compared in turn. If the first request identifier of the target query request is request identifier A, then there is a second request identifier that is the same as the first request identifier in the cache database.
[0043] Step S103: if there is a second request identifier identical to the first request identifier in the cache database, the target thread corresponding to the target query request is put to sleep; wherein the target thread is a thread that executes the target query request.
[0044] From the above content, it can be seen that if there is a second request identifier identical to the first request identifier in the cache database, it means that the same query request is already being processed. At this time, the target thread executing the target query request can be put to sleep to avoid repeated query operations.
[0045] As an example, the target thread can be put into sleep mode using the Thread.sleep() method in Java or the time.sleep() function in Python. The target thread can also be put into sleep mode using other methods, which are not specifically limited here. For example, in Java, if the same request identifier is detected in the cache, Thread.sleep(5000) can be executed to put the thread into sleep mode for 5 seconds, and then the status in the cache can be checked again.
[0046] The query request processing method provided in this embodiment, when a query request is obtained, first generates an encrypted query statement identifier (first request identifier) for each request. Check whether there is a second request identifier that is the same as the first request identifier in the cache database. If a matching second request identifier is found, it means that a thread has previously processed the same query, and its result may have been cached. The target thread currently processing the request can be put into a dormant state instead of repeatedly executing the calculation and rendering process, reducing unnecessary calculation and rendering processes, and significantly reducing resource and memory consumption.
[0047] In a possible implementation, the method further includes:
[0048] Step a1: after the target thread corresponding to the target query request is converted from a dormant state to a running state, it is detected whether there is a second request identifier identical to the first request identifier in the cache database.
[0049] After the target thread corresponding to the target query request is put into sleep mode, a corresponding sleep time may be set for the target thread, and when the sleep time ends, the target thread corresponding to the target query request is converted from the sleep state to the running state. Then, it may continue to detect whether there is a second request identifier identical to the first request identifier in the cache database.
[0050] Step a3: if the cache database does not contain the second request identifier identical to the first request identifier, query the cache database for cache data corresponding to the target query request according to the target query request.
[0051] If the result of the re-detection is that there is no second request identifier identical to the first request identifier in the cache database, it indicates that the target query request corresponding to the first request identifier can be executed, and the cache data corresponding to the target query request can be queried from the cache database through the target query request.
[0052] It should be noted that the prerequisite for re-detection is that there are other query requests that are the same as the target query request. After querying the data, other query requests can cache the data in the cache database. Then, when the target query request can be executed, the data can be queried directly from the cache database.
[0053] The query request processing method provided in this embodiment can manage the life cycle of the thread more finely by setting the sleep duration of the target thread. If the sleep duration reaches the preset duration, it is necessary to re-check whether there is a second request identifier identical to the first request identifier in the cache database. When there is no second request identifier identical to the first request identifier in the cache database, it means that the previous query request has been processed. At this time, re-checking the cache database can ensure that the thread will not be in a dormant state indefinitely, thereby improving the utilization rate of the thread and the responsiveness of the system.
[0054] In a possible implementation, the above method also includes: if there is a second request identifier that is identical to the first request identifier in the cache database, repeatedly executing the step of detecting whether there is a second request identifier that is identical to the first request identifier in the cache database after the target thread corresponding to the target query request is converted from a sleep state to a running state, until the number of repeated executions meets the preset number of times, and stopping executing the target query request.
[0055] From the above content, it can be seen that if the result of the re-detection is that there is no second request identifier that is identical to the first request identifier in the cache database, the target query request corresponding to the first request identifier can be executed; conversely, if the result of the re-detection is that there is a second request identifier that is identical to the first request identifier in the cache database, the target thread needs to continue to sleep, and then when the sleep time is reached, re-detect whether there is a second request identifier that is identical to the first request identifier in the cache database.
[0056] During this period, the number of repeated executions can be limited by the preset number of times pre-set by the user. The preset number of times can be 200, 300, etc., which are not specifically limited here. Specifically, when the number of repeated executions meets the preset number of times, the target query request is stopped, that is, a timeout exception occurs, and the query is exited.
[0057] The query request processing method provided in this embodiment, by setting a preset number of repeated executions, can ensure that the target thread will not be in a dormant state indefinitely due to a long-term cache miss, thereby avoiding the problem of query requests occupying threads due to invalidity. In addition, in the face of uncertain factors such as cache failure, data update or system abnormality, the repeated execution detection mechanism can enhance the fault tolerance of the system. Even if the cache misses the first time, the system can try to obtain data through multiple attempts, thereby improving the reliability and stability of the system.
[0058] In a possible implementation, the method further includes:
[0059] Step b1: If there is a second request identifier that is the same as the first request identifier in the cache database, it is detected whether there is cache data corresponding to the target query request in the cache database.
[0060] When the result of the first detection of whether there is a second request identifier identical to the first request identifier in the cache database is that there is a second request identifier identical to the first request identifier in the cache database, it indicates that the target query request has not been executed before, and then it is necessary to first detect whether there is cache data corresponding to the target query request in the cache database according to the target query request. That is, first determine whether there is data to be queried in the cache database.
[0061] Step b2: if the cache data corresponding to the target query request exists in the cache database, query the cache data corresponding to the target query request from the cache database according to the target query request.
[0062] If cache data corresponding to the target query request exists in the cache database, the cache data corresponding to the target query request may be directly queried from the cache database according to the target query request.
[0063] The query request processing method provided in this embodiment, when there is cache data matching the target query request in the cache, directly reading the data from the cache can greatly reduce the query processing time. Compared with querying from the original data source or database, cache reading is usually faster because the cache data is usually located in memory or faster storage media. In addition, by reducing direct access to the database or other storage system, the system can reduce its overall load. This not only helps protect the underlying storage system from the impact of high-concurrency queries, but also improves the stability and reliability of the system.
[0064] In a possible implementation, the method further includes:
[0065] Step c1, setting a merge identifier corresponding to the first request identifier in the cache database.
[0066] When the result of the first detection of whether there is a second request identifier identical to the first request identifier in the cache database is that there is a second request identifier identical to the first request identifier in the cache database, a merge identifier corresponding to the first request identifier may be set in the cache database. The merge identifier is used to indicate that the target query request is already in the process of being processed, and if a query request identical to the target query request is subsequently obtained, it is necessary to wait.
[0067] Step c2: if the cache data corresponding to the target query request does not exist in the cache database, query the cache data corresponding to the target query request from the business database according to the target query request.
[0068] If the cache database does not contain cache data corresponding to the target query request, it indicates that the data required by the target query request cannot be found in the cache database. Then, the target thread may continue to search for the corresponding cache data in the business database.
[0069] Step c3: after the cache data corresponding to the target query request is queried from the business database, the cache data is cached in the cache database, and the merge identifier is deleted.
[0070] After the cache data corresponding to the target query request is queried from the business database, that is, after the target query request is executed, the cache data needs to be cached to the cache database, and then the merge flag is deleted, that is, the waiting query request can be notified to continue execution.
[0071] The query request processing method provided in this embodiment can identify the same query request by setting a merge identifier in the cache database. If the cache data corresponding to the target query request does not exist in the cache database, the cache data corresponding to the target query request is queried from the business database according to the target query request, that is, when the cache data does not exist in the cache database, the cache data is queried from the business database, thereby avoiding the situation where the cache data cannot be queried.
[0072] At the same time, the cached data is cached in the cache database, and the merge identifier is deleted, so that the next time a query request corresponding to the cached data is obtained, the data can be directly queried from the cache database, saving a lot of time.
[0073] In a possible implementation, the method further includes:
[0074] Step d1, generating a query failure prompt corresponding to the target query request.
[0075] As can be seen from the above content, when the number of repeated executions meets the preset number, the target query request is stopped, that is, when the target query request is stopped because the number of repeated executions reaches the preset number, the system needs to generate a query failure prompt corresponding to the query request. Specifically, it may include the reason for the failure (such as "query repeated, execution has been stopped"), possible solutions (such as "please try again later" or "check query conditions"), and any related error codes or information.
[0076] Step d2: Display a query failure prompt on the page.
[0077] After generating the query failure prompt, the system needs to display this prompt to the user. This is usually achieved by embedding the prompt information into the HTML elements of the web page, such as displaying it in a modal box, warning box or error message area.
[0078] In the query request processing method provided in this embodiment, when a user initiates a query request but fails to obtain data successfully, the system can promptly inform the user of the query result by displaying a query failure prompt. This avoids the situation where the user waits for a long time in vain or the system does not respond, and improves the friendliness and transparency of the user experience.
[0079] In this embodiment, a query request processing device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0080] This embodiment provides a query request processing device, such as Figure 2 As shown, it includes: an acquisition module 201, which is used to acquire the query statement corresponding to the target query request, and encrypt the query statement to obtain a first request identifier corresponding to the query statement; a detection module 202, which is used to detect whether there is a second request identifier that is identical to the first request identifier in the cache database; a sleep module 203, which is used to put the target thread corresponding to the target query request to sleep if there is a second request identifier that is identical to the first request identifier in the cache database; wherein the target thread is a thread that executes the target query request.
[0081] In a possible implementation, the above-mentioned device also includes: a first detection module, which is used to detect whether there is a second request identifier identical to the first request identifier in the cache database after the target thread corresponding to the target query request is converted from a sleep state to a running state; and a first query module, which is used to query the cache data corresponding to the target query request from the cache database according to the target query request if there is no second request identifier identical to the first request identifier in the cache database.
[0082] In a possible implementation, the above-mentioned device also includes: a repeated execution module, which is used to repeatedly execute the step of detecting whether there is a second request identifier identical to the first request identifier in the cache database after the target thread corresponding to the target query request is converted from a sleep state to a running state, until the number of repeated executions meets the preset number of times, and stop executing the target query request.
[0083] In one possible implementation, the above-mentioned device also includes: a second detection module, which is used to detect whether there is cache data corresponding to the target query request in the cache database if a second request identifier identical to the first request identifier exists in the cache database; and a second query module, which is used to query the cache data corresponding to the target query request from the cache database according to the target query request if the cache data corresponding to the target query request exists in the cache database.
[0084] In one possible implementation, the above-mentioned device also includes: a setting module, which is used to set a merge identifier corresponding to the first request identifier in the cache database; a third query module, which is used to query the cache data corresponding to the target query request from the business database according to the target query request if the cache data corresponding to the target query request does not exist in the cache database; a cache deletion module, which is used to cache the cache data to the cache database and delete the merge identifier after querying the cache data corresponding to the target query request from the business database.
[0085] In a possible implementation, the apparatus further includes: a generation module, configured to generate a query failure prompt corresponding to the target query request; and a display module, configured to display the query failure prompt on a page.
[0086] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0087] The query request processing device in this embodiment is presented in the form of a functional unit, where the functional unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0088] The embodiment of the present invention also provides a computer device having the above Figure 2 The query request processing device is shown.
[0089] See also Figure 3 , Figure 3 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 3 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.
[0090] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0091] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0092] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0093] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0094] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0095] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0096] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0097] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for processing a query request, characterized in that: The method comprises: Obtaining a query statement corresponding to the target query request, and encrypting the query statement to obtain a first request identifier corresponding to the query statement; Detect whether there is a second request identifier identical to the first request identifier in the cache database; If there is a second request identifier that is the same as the first request identifier in the cache database, the target thread corresponding to the target query request is put to sleep; wherein the target thread is a thread that executes the target query request.
2. The method for processing a query request according to claim 1, characterized in that: If there is a second request identifier identical to the first request identifier in the cache database, after putting the target thread corresponding to the target query request to sleep, the method further includes: When the target thread corresponding to the target query request is converted from a dormant state to a running state, detecting whether there is a second request identifier identical to the first request identifier in the cache database; If the cache database does not have a second request identifier identical to the first request identifier, the cache database is queried for cache data corresponding to the target query request according to the target query request.
3. The method for processing a query request according to claim 2, characterized in that: The method further comprises: If there is a second request identifier that is identical to the first request identifier in the cache database, repeatedly execute the step of detecting whether there is a second request identifier that is identical to the first request identifier in the cache database after the target thread corresponding to the target query request is converted from a sleep state to a running state, until the number of repeated executions meets the preset number of times, and stop executing the target query request.
4. The method for processing a query request according to claim 1, characterized in that: If there is a second request identifier identical to the first request identifier in the cache database, before putting the target thread corresponding to the target query request to sleep, the method further includes: If there is a second request identifier identical to the first request identifier in the cache database, detecting whether there is cache data corresponding to the target query request in the cache database; If cache data corresponding to the target query request exists in the cache database, the cache data corresponding to the target query request is queried from the cache database according to the target query request.
5. The method for processing a query request according to claim 4, characterized in that: The method further comprises: Setting a merge identifier corresponding to the first request identifier in a cache database; If the cache data corresponding to the target query request does not exist in the cache database, query the cache data corresponding to the target query request from the business database according to the target query request; After the cache data corresponding to the target query request is queried from the business database, the cache data is cached in the cache database, and the merge identifier is deleted.
6. The method for processing a query request according to claim 3, characterized in that: The method further comprises: Generate a query failure prompt corresponding to the target query request; The query failure prompt is displayed on the page.
7. A query request processing device, characterized in that: The device comprises: An acquisition module, used to acquire a query statement corresponding to a target query request, and encrypt the query statement to obtain a first request identifier corresponding to the query statement; A detection module, used to detect whether there is a second request identifier that is the same as the first request identifier in the cache database; A sleep module is used to put the target thread corresponding to the target query request into sleep mode if there is a second request identifier identical to the first request identifier in the cache database; wherein the target thread is a thread that executes the target query request.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the query request processing method according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the query request processing method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the query request processing method according to any one of claims 1 to 6.
Citation Information
Cited By
Data query method and device, equipment and medium
CN120470028A