Querying sql statement method and device, computer device and storage medium

By receiving query requests, obtaining the URL of the middleware function, and detecting the Redis value, the system caches or matches the SQL statement, solving the problems of low efficiency and large modification volume in querying SQL statements. This achieves efficient SQL statement retrieval and improves user experience.

CN116795862BActive Publication Date: 2025-11-21SHENZHEN DONSON CLOUD TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310615533.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-26
Publication Date
2025-11-21
Estimated Expiration
2043-05-26

AI Technical Summary

Technical Problem

Existing technologies often result in low efficiency for querying SQL statements and require significant context changes throughout the entire process, negatively impacting user experience.

Method used

By receiving query requests, the system obtains the URL address in the context of the middleware function, checks whether the target key parameter exists in the Redis value, caches the SQL statement and reads it if it exists, and retrieves the SQL statement by matching the goroutine number if it does not exist, thus avoiding the passing of global variables.

Benefits of technology

This allows the target SQL statement to be retrieved with a single query request, improving query efficiency, enhancing user experience, and reducing the amount of modification required.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116795862B_ABST
    Figure CN116795862B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of SQL statement query, in particular to a method for querying a SQL statement. The method comprises the following steps: receiving a statement query request, obtaining a url address in the context of a middleware function according to the statement query request; detecting whether a target key parameter with a redis value as the url address exists in the middleware function; when the target key parameter with the redis value as the url address exists in the middleware function, obtaining a SQL statement through the url address, and caching the SQL statement in the redis in the middleware function; reading the redis cache in the middleware function to obtain a target SQL statement. In the application, the SQL statement in the redis cache in the middleware function is read, context transmission in the whole link is avoided, a target SQL statement is obtained through one query request, the efficiency of the SQL statement query is improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of SQL query technology, and in particular to a method, apparatus, computer device, and storage medium for querying SQL statements. Background Technology

[0002] With the advent of the big data era, Go, as an open-source programming language, has advantages such as simplicity, readability, and security, and is gradually being applied to Web development API development. In particular, its coroutine feature makes the system more concurrent.

[0003] In existing technologies, to facilitate debugging on system test environment pages, the functionality to view SQL is added to front-end page components, allowing testers and developers to quickly obtain the SQL statement corresponding to a specific component. This is typically done using PHP. However, PHP requires two requests to obtain the SQL statement, resulting in low efficiency and negatively impacting user experience. Go, on the other hand, lacks global variables, and context is generally only passed within the controller layer, not the model or other method layers. Adding context throughout the entire process would involve significant modifications. Therefore, finding a solution to obtain the SQL statement with minimal changes through a single request is a pressing issue for those skilled in the art. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for querying SQL statements to address the aforementioned technical problems, thereby solving the issues of low efficiency in querying SQL statements and excessive context changes in the entire process in the prior art.

[0005] A method for querying SQL statements, comprising:

[0006] Receive a query request and obtain the URL address in the context of the middleware function based on the query request;

[0007] Check if the target key parameter in the middleware function, whose value is a URL address, exists.

[0008] When the target key parameter of the URL address exists in the Redis value of the middleware function, the SQL statement is obtained through the URL address and cached in the Redis of the middleware function;

[0009] The Redis cache in the middleware function is read to obtain the target SQL statement.

[0010] An apparatus for querying SQL statements, comprising:

[0011] The address request module is used to receive statement query requests and obtain the URL address in the context of the middleware function based on the statement query request.

[0012] The target key parameter query module is used to detect whether the target key parameter, whose value in Redis is a URL address, exists in the middleware function;

[0013] The statement caching module is used to retrieve the SQL statement through the URL address when the value of Redis in the middleware function exists as the target key parameter of the URL address, and cache the SQL statement in the Redis address of the middleware function;

[0014] The statement reading module is used to read the Redis cache in the middleware function to obtain the target SQL statement.

[0015] A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor, when executing the computer-readable instructions, implements the above-described method for querying SQL statements.

[0016] One or more readable storage media storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the SQL query statement method described above.

[0017] The aforementioned method, apparatus, computer device, and storage medium for querying SQL statements include: receiving a statement query request; obtaining the URL address in the context of a middleware function based on the query request; detecting whether a target key parameter in the middleware function, whose value is the URL address, exists; when the target key parameter in the middleware function exists, obtaining the SQL statement through the URL address and caching the SQL statement in the middleware function's Redis cache; and reading the Redis cache in the middleware function to obtain the target SQL statement. In this invention, obtaining the URL address through the received statement query enables the retrieval of the URL address in the context of the middleware function. Detecting whether a target key parameter in the middleware function exists, based on its URL address, enables the determination of its existence. Obtaining the SQL statement through the URL address and caching it in the middleware function's Redis cache facilitates the retrieval and storage of the SQL statement, thus enabling subsequent SQL statement queries. Reading the Redis cache in the middleware function allows obtaining the target SQL statement with a single query request, improving the efficiency of SQL statement queries and enhancing the user experience. Furthermore, the problem of the lack of global variables was solved by assigning coroutine numbers, and the need to pass context in all methods was avoided. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of an application environment for a query SQL statement method according to an embodiment of the present invention;

[0020] Figure 2 This is a flowchart illustrating a method for querying SQL statements according to an embodiment of the present invention;

[0021] Figure 3 This is a schematic diagram of a device for querying SQL statements in one embodiment of the present invention;

[0022] Figure 4 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] The SQL query method provided in this embodiment can be applied to, for example... Figure 1 In this application environment, the client communicates with the server. Clients include, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0025] In one embodiment, such as Figure 2 As shown, a method for querying SQL statements is provided, which can be applied to... Figure 1 Taking the server-side as an example, the explanation includes the following steps:

[0026] S10. Receive a statement query request and obtain the URL address in the context of the middleware function according to the statement query request.

[0027] Understandably, to avoid excessive modifications, the context in this invention is only included in the middleware function and the control layer; there is no context in the model layer, other method layers, and the calling layer. Furthermore, in the front-end test environment, clicking the corresponding module sends an SQL query request. Upon receiving the query request, the URL address in the context of the middleware function is obtained based on the query request; that is, the corresponding URL address is found from the context of the middleware function through the query request.

[0028] S20. Check if the target key parameter in the middleware function, whose value in Redis is the URL address, exists.

[0029] Specifically, after obtaining the URL address, the system checks whether the target key parameter in the middleware function, whose value in Redis is the URL address, exists. In other words, when the value is the URL address, the system checks whether the key exists in Redis within the middleware function. This involves retrieving intermediate parameters from the middleware and determining whether they meet preset parameter conditions. If the intermediate parameters meet the preset conditions (i.e., the `debug` parameter equals 1), the system detects that the target key parameter in the middleware function, whose value in Redis is the URL address, exists. If the intermediate parameters do not meet the preset conditions (i.e., the `debug` parameter does not equal 1), the system detects that the target key parameter in the middleware function, whose value in Redis is the URL address, does not exist.

[0030] S30. When the target key parameter of the URL address exists in the Redis value of the middleware function, the SQL statement is obtained through the URL address and cached in the Redis of the middleware function.

[0031] S40. Read the Redis cache in the middleware function to obtain the target SQL statement.

[0032] Understandably, the target SQL statement is the SQL statement that was retrieved and corresponds to the request.

[0033] Specifically, when the target key parameter of the URL address exists in the Redis instance within the middleware function—that is, when the middleware parameter meets the preset parameter conditions, specifically when the `debug` parameter equals 1—the SQL statement is retrieved from the database based on the URL address. This SQL statement is then cached in the Redis instance within the middleware function, stored as a string as the value. During the call, the cached SQL statement in the middleware function's Redis instance can be read; that is, key-value pair matching is performed using the URL address obtained from the query request to obtain the corresponding value. The SQL statement is then extracted from the string value in the Redis instance, thus obtaining the target SQL statement.

[0034] In this embodiment of the invention, the method retrieves the URL address by querying the received statement, thus obtaining the URL address in the context of the middleware function. It checks whether the target key parameter in the middleware function, whose value is the URL address, exists, thus determining the existence of the target key parameter in the middleware function. The method retrieves the SQL statement through the URL address and caches it in the middleware function's Redis, thus achieving the retrieval and storage of the SQL statement, facilitating subsequent SQL statement queries. By reading from the Redis cache in the middleware function, the method achieves the retrieval of the target SQL statement in a single query request, improving the efficiency of SQL statement queries and enhancing the user experience. Furthermore, the method solves the problem of the lack of global variables and avoids passing context in all methods by allocating coroutine numbers.

[0035] In one embodiment, step S20, namely detecting whether the target key parameter in the middleware function, whose value in Redis is a URL address, exists, includes:

[0036] The intermediate parameters of the middleware function are obtained. When the intermediate parameters meet the preset parameter conditions, the URL address is determined as the target key parameter of Redis in the middleware function, and it is detected that the target key parameter of Redis with the value of the URL address exists in the middleware function.

[0037] Specifically, after obtaining the URL, the intermediate parameters in the middleware are retrieved, specifically the `debug` parameter, and it is determined whether the `debug` parameter meets the preset parameter conditions (these conditions can be set according to actual conditions). When the intermediate parameters meet the preset parameter conditions, i.e., when the `debug` parameter equals 1, the URL is determined as the target key parameter in the Redis function of the middleware function, i.e., the URL is determined as the key in the Redis function, and the existence of the target key parameter with the value of the URL in the Redis function is detected, and the SQL statement is directly obtained. When the intermediate parameters do not meet the preset parameter conditions, i.e., when the `debug` parameter does not equal 1, key-value pair matching is performed twice using the goroutine number to obtain the SQL statement. That is, in this embodiment, by determining whether the intermediate parameters in the middleware meet the preset parameter conditions, the existence of the target key parameter in the Redis function is detected. This achieves the determination that the target key parameter exists when the preset parameter conditions are met, and the determination that the target key parameter does not exist when the preset parameter conditions are not met.

[0038] In one embodiment, step S30, which involves caching the SQL statement in the middleware function's Redis, includes:

[0039] The intermediate parameters and the SQL statement are cached in the Redis context of the middleware function through the target storage function in the context.

[0040] Specifically, the intermediate parameters and the SQL statement are cached in the Redis context of the middleware function using the target storage function within the context. That is, the WithValue function from the context package stores the debug parameters and the value of the query statement (i.e., the SQL statement) in the middleware context. Thus, the SQL statement can be retrieved by accessing the context during subsequent query request processing. In other words, in this embodiment, by storing the middleware parameters and the SQL statement in the middleware context using the target storage function within the context, the called SQL statement is stored in the middleware, enabling the target SQL statement to be obtained with a single query request, thereby improving the efficiency of SQL statement queries.

[0041] In one embodiment, after step S20, the middleware function includes a coroutine number; that is, after detecting whether the target key parameter in the middleware function, whose value in Redis is a URL address, exists, it further includes:

[0042] S201, when the target key parameter of the URL address in the middleware function does not exist, obtain the coroutine number in the middleware function.

[0043] Understandably, in Go, which does not support shared state web servers, each HTTP request is processed as a separate goroutine and assigned an ID.

[0044] Furthermore, in the system testing environment, clicking on a module on the test page queries the corresponding SQL statement, thus receiving a statement query request from the front end. The coroutine number is obtained based on the statement query request, meaning an idle coroutine number is assigned to that query request. Subsequently, when multiple users send statement query requests simultaneously, an idle coroutine number is assigned to each query request in the order they are received. After a query request ends, this coroutine number is reassigned to other users' query requests, but throughout the request process, this coroutine number remains belonging to that specific query request and is not assigned to other query requests. That is, it remains unchanged throughout the entire request chain—the middleware layer, control layer, model layer, method layer, and invocation layer—and can be used as a simulated global variable.

[0045] Specifically, when the target key parameter in the middleware function, which is a URL address, does not exist, that is, when the middleware parameter does not meet the preset parameter conditions, i.e., when the debug parameter does not meet the condition that debug equals 1, the coroutine number assigned according to the request is obtained from the middleware function.

[0046] S202, Match the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number.

[0047] Specifically, the coroutine number is determined as the second key parameter of the middleware function in Redis, i.e., the coroutine number is designated as `key1`, and all URLs are determined as the second value parameters of the middleware function in Redis, i.e., the URLs are designated as `value1`. Then, the second key parameter and all second value parameters are matched, i.e., `key1` is matched with all `value1` values ​​to obtain the `value1` corresponding to `key1`, i.e., the URL. This URL is then determined as the coroutine URL address corresponding to the coroutine number. For example, the URL address is first matched using `redis.get` with the coroutine number.

[0048] S203, determine the goroutine URL address corresponding to the goroutine number as the first key parameter, obtain the SQL statement according to the first key parameter, and cache the SQL statement in the redis in the middleware function.

[0049] S204, Read the Redis cache in the middleware function to obtain the target SQL statement.

[0050] Specifically, the URL address corresponding to the coroutine number is determined as the first key parameter, i.e., the coroutine URL address is determined as key2. The SQL statement is then retrieved based on the first key parameter, that is, the SQL statement is matched using `redis.set` with the coroutine URL address, and cached in the Redis cache within the middleware function. Specifically, the SQL statement is stored as value2 in a string-type Redis cache. Then, during the call, the Redis cache in the middleware function can be read. That is, the URL address obtained from the query request is matched with key-value pairs to obtain the corresponding value2. The SQL statement is then extracted from the string-type Redis value2, thus obtaining the target SQL statement.

[0051] In this embodiment of the invention, when the target key parameter, whose Redis value is a URL address, does not exist in the middleware function, the coroutine number stored in the middleware is obtained, thereby determining the coroutine URL address. By caching the SQL statement in the Redis cache within the middleware function and reading from the Redis cache, the target SQL statement is extracted, thus enabling a single request to retrieve the SQL statement, improving the efficiency of SQL querying and enhancing the user experience.

[0052] In one embodiment, step S202, which involves matching the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number, further includes:

[0053] S2021, the coroutine number is recorded as a second key parameter, and all the URL addresses in the middleware are recorded as second value parameters.

[0054] S2022, perform key-value pair matching on the second key parameter and all the second value parameters to obtain the final value parameter corresponding to the second key parameter.

[0055] S2023, the URL address corresponding to the final value parameter is determined as the goroutine URL address corresponding to the goroutine number.

[0056] Understandably, the final value parameter is value1 corresponding to the coroutine number.

[0057] Specifically, after obtaining the coroutine number, it is matched against all URLs. This is done using `redis.set` to perform key-value pair matching between the coroutine number and all URLs. First, the coroutine number is recorded as the second key parameter, and all URLs in the middleware are recorded as second value parameters. Then, key-value pair matching is performed between the second key parameter and all second value parameters. Specifically, the coroutine number is determined as `key1` and all URLs as `value1`. This process is repeated until `key1` matches a corresponding `value1`, at which point the final value parameter corresponding to the second key parameter is obtained. For example, `redis.set` can be used to match a URL address using the coroutine number. Finally, the URL address corresponding to the final value parameter is retrieved from the context and identified as the coroutine URL address corresponding to the coroutine number. In other words, in this embodiment, by defining data as keys and values, the recording of the second key parameter and all second value parameters is achieved. By performing key-value pair matching on the second key parameter and all second value parameters, the final value parameter can be obtained through key-value pair matching, thereby determining the coroutine URL address.

[0058] In one embodiment, after step S204, that is, after obtaining the target SQL statement, the method further includes:

[0059] Delete the second key parameter and the second value parameter.

[0060] Specifically, after obtaining the target SQL statement, the second key parameter and the second value parameter are deleted, that is, key1 and value1 are deleted. Specifically, key1 of check:GOID and value1 of the URL address corresponding to check:GOID are deleted. In other words, in this embodiment, by deleting the second key parameter and the second value parameter, the storage space occupied is reduced, saving memory space.

[0061] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0062] In one embodiment, a device for querying SQL statements is provided, which corresponds one-to-one with the SQL query method described in the above embodiments. For example... Figure 3 As shown, the SQL query statement device includes a data acquisition module 10, a result recognition module 20, a data analysis module 30, and a result evaluation module 40. Detailed descriptions of each functional module are as follows:

[0063] Address request module 10 is used to receive statement query requests and obtain the URL address in the context of the middleware function according to the statement query request;

[0064] The target key parameter query module 20 is used to detect whether the target key parameter in the middleware function, whose value in Redis is a URL address, exists.

[0065] The statement caching module 30 is used to retrieve the SQL statement through the URL address and cache the SQL statement in the Redis of the middleware function when the value of Redis in the middleware function exists as the URL address target key parameter.

[0066] The statement reading module 40 is used to read the Redis cache in the middleware function to obtain the target SQL statement.

[0067] Optionally, the target key parameter query module 20 includes:

[0068] The intermediate parameter determination unit is used to obtain the intermediate parameters of the middleware function. When the intermediate parameters meet the preset parameter conditions, the URL address is determined as the target key parameter of Redis in the middleware function, and the existence of the target key parameter of Redis with the value of the URL address in the middleware function is detected.

[0069] Optionally, the target key parameter query module 20 further includes:

[0070] The coroutine number acquisition module 50 is used to acquire the coroutine number in the middleware function when the target key parameter with the Redis value of the URL address does not exist.

[0071] Address matching module 60 is used to match the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number;

[0072] The first key parameter module 70 is used to determine the coroutine URL address corresponding to the coroutine number as the first key parameter, obtain the SQL statement according to the first key parameter, and cache the SQL statement in the redis in the middleware function;

[0073] The cache reading module 80 is used to read the Redis cache in the middleware function to obtain the target SQL statement.

[0074] Optionally, the address matching module 60 includes:

[0075] A parameter recording unit is used to record the coroutine number as a second key parameter and to record all the URL addresses in the middleware as second value parameters;

[0076] A key-value matching unit is used to perform key-value pair matching on the second key parameter and all the second value parameters to obtain the final value parameter corresponding to the second key parameter;

[0077] The coroutine address unit is used to determine the URL address corresponding to the final value parameter as the coroutine URL address corresponding to the coroutine number.

[0078] Optionally, the coroutine address unit further includes:

[0079] The parameter deletion subunit is used to delete the first key parameter and the first value parameter.

[0080] Optionally, the statement caching module 30 includes:

[0081] The intermediate parameter unit is used to cache the intermediate parameters and the SQL statement in the Redis context of the middleware function through the target storage function in the context.

[0082] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor provides computing and control capabilities. The memory includes a readable storage medium and internal memory. The non-volatile storage medium stores the operating system and computer-readable instructions. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The network interface is used to communicate with an external server via a network connection. When the computer-readable instructions are executed by the processor, they implement a query SQL statement method. The readable storage medium provided in this embodiment includes both non-volatile and volatile readable storage media.

[0083] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor executes the computer-readable instructions to implement the above-described query SQL statement method.

[0084] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The computer-readable storage media provided in this embodiment include non-volatile readable storage media and volatile readable storage media. The computer-readable instructions stored on the readable storage media implement the above-described SQL query statement method when executed by one or more processors.

[0085] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When executed, these computer-readable instructions can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0086] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0087] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for querying SQL statements, characterized in that, include: Receive a query request and obtain the URL address in the context of the middleware function based on the query request; Check if the target key parameter in the middleware function, whose value is a URL address, exists. When the target key parameter of the URL address exists in the Redis value of the middleware function, the SQL statement is obtained through the URL address and cached in the Redis of the middleware function; The Redis cache in the middleware function is read to obtain the target SQL statement; If the target key parameter of the URL address in the middleware function does not exist, retrieve the coroutine number in the middleware function; Match the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number; The goroutine URL address corresponding to the goroutine number is determined as the first key parameter, and the SQL statement is obtained according to the first key parameter. The SQL statement is then cached in the Redis in the middleware function. The Redis cache in the middleware function is read to obtain the target SQL statement.

2. The SQL query method as described in claim 1, characterized in that, The step of matching the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number includes: Record the coroutine number as the second key parameter, and record all the URL addresses in the middleware as the second value parameter; Perform key-value pair matching on the second key parameter and all the second value parameters to obtain the final value parameter corresponding to the second key parameter; The URL address corresponding to the final value parameter is determined as the goroutine URL address corresponding to the goroutine number.

3. The query SQL statement method as described in claim 2, characterized in that, After obtaining the target SQL statement, the process includes: Delete the second key parameter and the second value parameter.

4. The SQL query method as described in claim 1, characterized in that, The step of detecting whether the target key parameter in the middleware function, whose value in Redis is a URL address, exists includes: The intermediate parameters of the middleware function are obtained. When the intermediate parameters meet the preset parameter conditions, the URL address is determined as the target key parameter of Redis in the middleware function, and it is detected that the target key parameter of Redis with the value of the URL address exists in the middleware function.

5. The SQL query method as described in claim 1, characterized in that, The step of caching SQL statements in Redis within the middleware function includes: The intermediate parameters and the SQL statement are cached in the Redis context of the middleware function through the target storage function in the context.

6. A device for querying SQL statements, characterized in that, include: The address request module is used to receive statement query requests and obtain the URL address in the context of the middleware function based on the statement query request. The target key parameter query module is used to detect whether the target key parameter, whose value in Redis is a URL address, exists in the middleware function; The statement caching module is used to retrieve the SQL statement through the URL address when the value of Redis in the middleware function exists as the target key parameter of the URL address, and cache the SQL statement in the Redis address of the middleware function; The statement reading module is used to read the Redis cache in the middleware function to obtain the target SQL statement; The target key parameter query module includes: The coroutine number acquisition module is used to acquire the coroutine number in the middleware function when the target key parameter of the Redis value is a URL address does not exist. The address matching module is used to match the coroutine number with all the URL addresses to obtain the coroutine URL address corresponding to the coroutine number; The first key parameter module is used to determine the goroutine URL address corresponding to the goroutine number as the first key parameter, obtain the SQL statement according to the first key parameter, and cache the SQL statement in the redis in the middleware function; The cache reading module is used to read the Redis cache in the middleware function to obtain the target SQL statement.

7. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the computer-readable instructions, it implements the query SQL statement method as described in any one of claims 1 to 5.

8. One or more readable storage media storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors cause the one or more processors to perform the query SQL statement method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Cache processing method and device, computer equipment and storage medium

    CN111190928A

  • Front-end and back-end asynchronous request data interaction method and system based on Redis

    CN115145946A