Data query method and device, storage medium and electronic equipment

By storing and querying data in Redis server and MongoDB server, the inefficiency of query caused by massive data in the database server is solved, and faster data query is achieved.

CN119474139APending Publication Date: 2025-02-18ZUNYI BRANCH OF CHINA MOBILE GRP GUIZHOU COMPANY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411507926.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, massive data is stored in the database server, which causes the data query to take a long time and affects the query efficiency.

Method used

Data query is performed through the Redis server or MongoDB server. The Redis server stores conditions and results that are queried within the preset time period or frequently, while the MongoDB server stores queryed conditions and results that are exceeded for the time period range.

Benefits of technology

It greatly reduces the time-consuming of data query and improves the efficiency of data query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474139A_ABST
    Figure CN119474139A_ABST
Patent Text Reader

Abstract

The invention discloses a data query method and device, a storage medium and electronic equipment, and relates to the technical field of databases, and the method comprises the following steps: in response to a data query request sent by a client, firstly obtaining a target query condition carried in the data query request; then, under the condition that it is determined that the query is not the first query according to the target query condition, data query is carried out through the Redis server or the MongoDB server on the basis of the target query condition; sending a query result corresponding to the target query condition to the client; wherein the Redis server stores query conditions which have been queried in a preset time period and corresponding query results, and / or query conditions which meet a preset query frequency and corresponding query results; the MongoDB server stores a queried query condition exceeding a preset time period range and a corresponding query result. By applying the technical scheme of the invention, the data query efficiency can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a data query method, device, storage medium and electronic device. Background Art

[0002] In recent years, with the rapid development of information technology, the amount of information data has continued to increase, and the demand for data management and analysis has spread to various application scenarios. In the process of data management and analysis, statistical queries on data objects are required.

[0003] At present, in the related art, data query is directly performed in the database server according to the query conditions input by the user. However, since the database server stores a huge amount of data, it will cause the data query to take a long time, affecting the efficiency of the data query. Summary of the invention

[0004] In view of this, the present application provides a data query method, device, storage medium and electronic device, the main purpose of which is to improve the technical problems in the current related technologies that may affect the efficiency of data query.

[0005] In a first aspect, the present application provides a data query method, comprising:

[0006] In response to a data query request sent by a client, obtaining a target query condition carried in the data query request;

[0007] When it is determined that the query is not the first query according to the target query condition, performing data query based on the target query condition through a Redis server or a MongoDB server;

[0008] Sending the query result corresponding to the target query condition to the client;

[0009] Among them, the Redis server stores query conditions and corresponding query results that have been queried within a preset time period, and / or query conditions that meet a preset query frequency and corresponding query results; the MongoDB server stores query conditions and corresponding query results that have been queried beyond the preset time period.

[0010] In a second aspect, the present application provides a data query device, comprising:

[0011] An acquisition module is configured to respond to a data query request sent by a client and acquire a target query condition carried in the data query request;

[0012] A query module is configured to perform data query based on the target query condition through a Redis server or a MongoDB server when it is determined that the query is not the first query according to the target query condition; wherein the Redis server stores query conditions that have been queried within a preset time period and corresponding query results, and / or query conditions that meet a preset query frequency and corresponding query results; and the MongoDB server stores query conditions that have been queried beyond the preset time period and corresponding query results;

[0013] The sending module is configured to send the query result corresponding to the target query condition to the client.

[0014] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0015] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the method described in the first aspect when executing the computer program.

[0016] In a fifth aspect, the present application provides a computer program product having a computer program stored thereon, and when the computer program product is executed by a processor, the method described in the first aspect is implemented.

[0017] By means of the above technical scheme, a data query method, device, storage medium and electronic device provided by the present application specifically respond to a data query request sent by a client, first obtain the target query condition carried in the data query request; then, when it is determined that it is not the first query according to the target query condition, perform data query based on the target query condition through a Redis server or a MongoDB server; and then send the query result corresponding to the target query condition to the client. Compared with the current related art, the present application is equivalent to providing a data query solution based on a general query interface. When it is determined that the user's data query request is not the first query according to the target query condition, the data query is not directly performed in the database server, but the data query is performed based on the target query condition through the Redis server or the MongoDB server, wherein the Redis server stores the query conditions and corresponding query results that have been queried within the preset time period, such as the query conditions and corresponding query results that have been queried in the database server recently, and / or the query conditions and corresponding query results that meet the preset query frequency, such as the query conditions and corresponding query results with a high query frequency; and the MongoDB server stores the query conditions and corresponding query results that have been queried beyond the preset time period, such as the query conditions and corresponding query results that have not been queried recently but have been queried in the database server. Compared with the amount of data stored in the database server, the amount of data stored in the Redis server and the MongoDB server is significantly less, so the time consumption of data query can be greatly reduced, thereby improving the efficiency of data query.

[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0021] Figure 1 A schematic diagram of a data query method provided in an embodiment of the present application is shown;

[0022] Figure 2 A schematic diagram of a data query method provided in an embodiment of the present application is shown;

[0023] Figure 3 A schematic diagram of an example process provided by an embodiment of the present application is shown;

[0024] Figure 4 A schematic diagram of the structure of a data query device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0025] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0026] In order to improve the technical problems that affect data query efficiency in the current related technologies. This embodiment provides a data query method, such as Figure 1 As shown, the method includes:

[0027] Step 101: In response to a data query request sent by a client, a target query condition carried in the data query request is obtained.

[0028] The execution subject of this embodiment may be an application server for data query or a middleware for managing data query, etc. For ease of understanding, the following description is made by taking an application server as an example.

[0029] In some embodiments, a user may input a data query instruction through a client, and the data query instruction includes a target query condition input by the user, and the target query condition may be used to indicate which data to query. By calling a general query interface, the client sends a data query request to the application server according to the data query instruction, and the data query request carries the target query condition. Among them, the general query interface can effectively reduce the workload of code development and maintenance. In the scenario where the general query interface performs high-concurrency queries, the efficiency of data query becomes very important. Therefore, in order to improve the efficiency of data query, after receiving the data query request sent by the client, the application server obtains the target query condition carried in the data query request, which is the query condition input by the user by calling the general interface, and may further execute the process shown in steps 102 to 103.

[0030] Step 102: When it is determined that the query is not the first query according to the target query condition, a data query is performed based on the target query condition through a Redis server or a MongoDB server.

[0031] In some embodiments, the application server can determine whether it is the first query based on the target query conditions. For example, each time the query conditions are executed to query data, the query conditions can be recorded accordingly, and the target query conditions can be matched with these recorded query conditions. If the match is successful, it can indicate that the query requested by the user this time is not the first query; if the match fails, it can indicate that the query requested by the user this time is the first query.

[0032] For this embodiment, when it is determined that the query requested by the user is not the first query, data query can be performed based on the target query condition through the Redis server or MongoDB server instead of directly performing data query in the database server.

[0033] The Redis server can be a Redis database cluster server, and the MongoDB server can be used to manage an intermediate database, which can be a MongoDB shard cluster. In some examples, the MongoDB shard cluster uses a data balancing mechanism to ensure that data is evenly distributed among the shards. When new shards are added to the cluster or data is unevenly distributed, the system will automatically migrate data to maintain a balanced state of data. Ensuring balanced data distribution helps MongoDB process query requests more efficiently, because data will not be concentrated on one shard, thereby reducing the risk of a single bottleneck and quickly responding to data queries.

[0034] In some embodiments, the Redis server stores query conditions and corresponding query results that have been queried within a preset time period, and / or query conditions that meet a preset query frequency and corresponding query results.

[0035] The preset time period may be pre-configured according to actual conditions. For example, the preset time period may be used to determine whether it is a query condition for a recent query, such as a time period within a preset time range before the time when the user requests the query. The preset time period may be a first preset threshold for recent query determination, and the preset time period may be 1 day, 3 days, etc. For another example, the preset time period may be a specified time period, such as a time period between July 1 and July 3, etc.

[0036] In some examples, the Redis server stores query conditions and corresponding query results that have been queried within a time range of 1 day or 3 days before the user's query request. For example, the Redis server stores query conditions and corresponding query results that have been queried within the last 1 day or 3 days.

[0037] The preset query frequency can be pre-configured according to actual conditions. The preset query frequency can be a second preset threshold for determining the frequency of queries. For example, the preset query frequency can be used to determine whether it is a frequently used query condition. For example, for query conditions that meet the preset query frequency, users often use the query condition to query data.

[0038] In some examples, the Redis server stores query conditions frequently used by users and corresponding query results.

[0039] In some embodiments, the MongoDB server stores query conditions that have been queried beyond a preset time period and corresponding query results.

[0040] For example, the Redis server stores query conditions and corresponding query results that have been queried within the last 1 day or 3 days, while query conditions and corresponding query results that have been queried beyond this time range can be stored in the MongoDB server.

[0041] For this embodiment, when it is determined to be a non-first query according to the target query condition, data query can be performed based on the target query condition through the Redis server or the MongoDB server, and the data of the non-first query can be queried in the Redis server or the MongoDB server. In this embodiment, for the hot data that has been queried recently and frequently, it can be stored in the Redis server. Redis is an in-memory data storage system, which means that it can process read and write operations very quickly, which can effectively improve the efficiency of data query. For the data that has not been queried recently, it can be stored in the MongoDB server. MongoDB is a document-oriented database that can store complex nested data structures. It is very suitable for applications whose data patterns are not fixed or often change, and MongoDB supports horizontal expansion. Data can be distributed to multiple servers through sharding to improve load capacity. Through this more reasonable data storage layout method of the present embodiment, data can be accurately and efficiently queried.

[0042] Step 103: Send the query result corresponding to the target query condition to the client.

[0043] Compared with the current related technology, this embodiment is equivalent to providing a data query solution based on a general query interface. When it is determined that the user's data query request is not the first query according to the target query condition, the data query is not directly performed in the database server, but the data query is performed based on the target query condition through the Redis server or the MongoDB server, wherein the Redis server stores the query conditions that have been queried within the preset time period and the corresponding query results, such as the query conditions that have been queried in the database server recently and the corresponding query results, and / or the query conditions that meet the preset query frequency and the corresponding query results, such as the query conditions with a high query frequency and the corresponding query results; and the MongoDB server stores the query conditions that have been queried beyond the preset time period and the corresponding query results, such as the query conditions that are not recently queried but have been queried in the database server and the corresponding query results. Compared with the amount of data stored in the database server, the amount of data stored in the Redis server and the MongoDB server is significantly less, so the time consumption of data query can be greatly reduced, thereby improving the efficiency of data query.

[0044] In order to further illustrate the specific implementation process of the method of this embodiment, this embodiment provides the following Figure 2 The specific method shown includes:

[0045] Step 201: In response to a data query request sent by a client, a target query condition carried in the data query request is obtained.

[0046] In some embodiments, a target query condition is received from a user by calling a universal interface, and then a determination is made as to whether it is a first query based on the target query condition. If it is a first query, the process shown in steps 202a to 203a may be executed; and if it is not a first query, the process shown in step 202b may be executed.

[0047] Step 202a: When it is determined that the query is the first query according to the target query condition, trigger a target number of threads to perform parallel data query based on the target query condition in the database server.

[0048] In some embodiments, the target number can be determined based on CPU utilization (usage) and the expected maximum number of threads. For example, the target number is calculated by the following formula:

[0049] threadCount=(int)((cpuUsage / 80.0)*MAX_THREADS)

[0050] In the above formula, int means rounding, threadCount is the target number of threads, cpuUsage is the CPU utilization, and MAX_THREADS is the expected maximum number of threads, which can be set by the user on the thread pool management page.

[0051] In this embodiment, when it is determined that the query is the first time according to the target query condition, the corresponding number of threads is triggered according to the CPU usage, and parallel query is performed in the database server. Multithreading is implemented using Java Runnable, and then a thread pool is created using ExecutorService, and thread safety is controlled using synchronized. By calling multiple threads to perform parallel query in the database server, the efficiency of data query is further improved.

[0052] Step 203a: store the target query condition and the corresponding query result in the Redis server.

[0053] The Redis server stores query conditions and corresponding query results that have been queried within a preset time period, and / or query conditions that meet a preset query frequency and corresponding query results.

[0054] For example, the Redis server stores recently searched query conditions and corresponding query results, and / or frequently used query conditions and corresponding query results.

[0055] Step 202b, which is parallel to step 202a, performs data query based on the target query condition through a Redis server or a MongoDB server when it is determined that the query is not the first query according to the target query condition.

[0056] In some embodiments, performing data query based on the target query condition through a Redis server or a MongoDB server may specifically include: if the target query condition is a query condition that has been queried within a preset time period, and / or the target query condition is a query condition that satisfies a preset query frequency, performing data query based on the target query condition through the Redis server; if the target query condition is a query condition that has been queried beyond the preset time period, and / or the target query condition is not a query condition that satisfies the preset query frequency, performing data query based on the target query condition through the MongoDB server.

[0057] For example, when it is determined that it is not the first query based on the target query condition, it means that the target query condition has been used for query before. It can be further determined whether the target query condition is a query condition that has been queried recently, or whether it is a query condition with a high query frequency. If so, the corresponding query result can be queried in the Redis server based on the target query condition; otherwise, the corresponding query result can be queried in the MongoDB server based on the target query condition.

[0058] In some embodiments, data query is performed based on target query conditions through a Redis server, including: if an abnormality exists in the Redis server causing the data query to fail, data query is performed based on the target query conditions through a database server.

[0059] For example, if the Redis server fails to find the query result according to the target query condition in the Redis server due to an exception, the query is directly performed in the database server to ensure that the user can successfully query the data.

[0060] In some embodiments, performing data query based on target query conditions through a MongoDB server includes: if an abnormality exists in the MongoDB server causing the data query to fail, performing data query based on the target query conditions through a database server.

[0061] For example, if the MongoDB server is abnormal and no query results are found according to the target query conditions in the MongoDB server, the query is directly performed in the database server to ensure that the user can successfully query the data.

[0062] Furthermore, in some examples, if the query conditions stored in the MongoDB server meet the preset query frequency, the MongoDB server is triggered to transfer the query conditions meeting the preset query frequency and the corresponding query results to the Redis server.

[0063] For example, the Redis server stores recently queried query conditions and corresponding query results, while query conditions and corresponding query results that have not been queried recently can be stored in the MongoDB server. If the query conditions stored in the MongoDB server are frequently used later, the query conditions and corresponding query results can be transferred from the MongoDB server to the Redis server, so as to improve the efficiency of data query by taking advantage of Redis's faster reading and writing.

[0064] Furthermore, in some examples, data queries are periodically performed through a database server based on query conditions that satisfy a preset query frequency, and the query conditions that satisfy the preset query frequency and the corresponding latest query results are updated to a Redis server.

[0065] For example, at a scheduled time every night (such as 24:00), frequently used query conditions are obtained, and these query conditions are executed to query data in the database server, and the query results are automatically synchronized from the database server to the Redis server to ensure the accuracy of the query results.

[0066] In some embodiments, for the query conditions stored in the Redis server and the MongoDB server, the updated results of the corresponding query results can be obtained from the database server at regular intervals to ensure that the query results corresponding to the query conditions stored in the Redis server and the MongoDB server are accurate.

[0067] In some embodiments, the storage duration in the Redis server can be determined based on the duration of a preset time period (i.e., a first preset threshold). Query conditions and corresponding query results that exceed this duration will be transferred to the MongoDB server. In order to save storage space in the MongoDB server, a corresponding storage duration limit can also be set. The storage duration can be greater than the storage duration in the Redis server. When the storage time of a query condition in the MongoDB server exceeds the storage duration limit, the query condition and the corresponding query results can be deleted to save storage space in the MongoDB server.

[0068] Step 204: Send the query result corresponding to the target query condition to the client.

[0069] Based on the content of the above embodiment, it is equivalent to providing a data query method based on a universal query interface to achieve the purpose of efficient and accurate data query.

[0070] In some examples, the data query interaction can be as follows Figure 3 As shown, the example methods shown in S1 to S4 below can be executed:

[0071] S1: The application server receives the query conditions input by the user (client) by calling the general interface, and determines whether it is the first query according to the query conditions. If so, the corresponding number of threads is triggered according to the CPU usage, and parallel query is performed in the database server to query the corresponding query results based on the query conditions and return them to the user. At the same time, the corresponding query conditions and query result information are stored in the Redis server. If not, go to step S2;

[0072] S2: According to the query condition, determine whether it is a recent query or whether it meets the query frequency of the second preset threshold. If so, query the corresponding query result based on the query condition in the Redis server and return it to the user side. If not, go to step S3;

[0073] The determination of recent queries is set according to a first preset threshold, such as 1 day, 3 days, etc. The Redis server stores the query conditions and query result data of recent queries, or the query conditions and query result data of queries that meet the second preset threshold query frequency;

[0074] At a preset time every night (such as 00:00), the query conditions that meet the second preset threshold query frequency query are executed, and the query results are automatically synchronized from the database to the Redis server to ensure the accuracy of the query results.

[0075] S3: According to the query conditions, the corresponding query results are queried in the MongoDB server (management intermediate database) based on the query conditions and returned to the user side.

[0076] The intermediate database caches data in the Redis server that exceeds the first preset threshold time, but when the data meets the second preset threshold query frequency, it is transferred to the Redis server. The intermediate database is a MongoDB shard cluster, which stores data that exceeds the first preset threshold time in shards.

[0077] S4: If the Redis server or the MongoDB server is abnormal and the query result is not found according to the query condition in the Redis server or the MongoDB server, the query is directly performed in the database server.

[0078] By applying the above-mentioned embodiment scheme, the efficiency of data query can be improved.

[0079] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the embodiment provides a data query device, such as Figure 4 As shown, the device includes: an acquisition module 31, a query module 32, and a sending module 33.

[0080] The acquisition module 31 is configured to respond to the data query request sent by the client and acquire the target query condition carried in the data query request;

[0081] The query module 32 is configured to perform data query based on the target query condition through a Redis server or a MongoDB server when it is determined that the query is not the first query according to the target query condition; wherein the Redis server stores query conditions that have been queried within a preset time period and corresponding query results, and / or query conditions that meet a preset query frequency and corresponding query results; the MongoDB server stores query conditions that have been queried beyond the preset time period and corresponding query results;

[0082] The sending module 33 is configured to send the query result corresponding to the target query condition to the client.

[0083] In some examples of this embodiment, the query module 32 is specifically configured to perform data query based on the target query condition through the Redis server if the target query condition is a query condition that has been queried within the preset time period and / or the target query condition is a query condition that satisfies the preset query frequency; if the target query condition is a query condition that has been queried and exceeds the preset time period, and / or the target query condition is not a query condition that satisfies the preset query frequency, perform data query based on the target query condition through the MongoDB server.

[0084] In some examples of this embodiment, the query module 32 is further configured to perform data query based on the target query condition through the database server if an abnormality occurs in the Redis server causing the data query to fail.

[0085] In some examples of this embodiment, the query module 32 is further configured to perform data query based on the target query condition through the database server if the MongoDB server has an abnormality that causes the data query to fail.

[0086] In some examples of this embodiment, the sending module 33 is also configured to trigger the MongoDB server to transfer the query conditions that meet the preset query frequency and the corresponding query results to the Redis server if the query conditions stored in the MongoDB server meet the preset query frequency.

[0087] In some examples of this embodiment, the query module 32 is also configured to periodically perform data queries through the database server based on query conditions that meet the preset query frequency, and update the query conditions that meet the preset query frequency and the corresponding latest query results to the Redis server.

[0088] In some examples of this embodiment, the query module 32 is also configured to trigger a target number of threads when it is determined that the query is the first time according to the target query condition, and perform parallel data query in the database server based on the target query condition, and the target number is determined according to the CPU utilization and the expected maximum number of threads; the target query condition and the corresponding query result are stored in the Redis server.

[0089] It should be noted that for other corresponding descriptions of the functional units involved in the data query device provided in this embodiment, please refer to Figure 1 and Figure 2 The corresponding description in will not be repeated here.

[0090] Based on the above Figure 1 and Figure 2 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 and Figure 2 The method shown.

[0091] Based on the above Figure 1 and Figure 2 The method shown in the embodiment also provides a computer program product, on which a computer program is stored, and when the computer program product is executed by a processor, the above-mentioned Figure 1 and Figure 2 The method shown.

[0092] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.

[0093] Based on the above Figure 1 and Figure 2 The method shown, and Figure 4 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, such as a computer, a server and other network devices, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 and Figure 2 The method shown.

[0094] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0095] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.

[0096] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0097] Through the description of the above implementation mode, the technicians in this field can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the technical solution of this embodiment, it is equivalent to providing a data query solution based on a general query interface. When the user's data query request is determined to be a non-first query according to the target query condition, the data query is not directly performed in the database server, but the data query is performed based on the target query condition through the Redis server or the MongoDB server, wherein the Redis server stores the query conditions and corresponding query results that have been queried within the preset time period, such as the query conditions and corresponding query results that have been queried in the database server recently, and / or the query conditions and corresponding query results that meet the preset query frequency, such as the query conditions and corresponding query results with a high query frequency; and the MongoDB server stores the query conditions and corresponding query results that have been queried beyond the preset time period, such as the query conditions and corresponding query results that have been queried but not recently queried but have been queried in the database server. Compared with the amount of data stored in the database server, the amount of data stored in the Redis server and the MongoDB server is significantly less, so the time consumption of data query can be greatly reduced, thereby improving the efficiency of data query.

[0098] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0099] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.

Claims

1. A data query method, characterized in that: include: In response to a data query request sent by a client, obtaining a target query condition carried in the data query request; When it is determined that the query is not the first query according to the target query condition, performing data query based on the target query condition through a Redis server or a MongoDB server; Sending the query result corresponding to the target query condition to the client; Among them, the Redis server stores query conditions and corresponding query results that have been queried within a preset time period, and / or query conditions that meet a preset query frequency and corresponding query results; the MongoDB server stores query conditions and corresponding query results that have been queried beyond the preset time period.

2. The method according to claim 1, characterized in that The performing of data query based on the target query condition through the Redis server or the MongoDB server includes: If the target query condition is a query condition that has been queried within the preset time period, and / or the target query condition is a query condition that satisfies the preset query frequency, data query is performed based on the target query condition through the Redis server; If the target query condition is a query condition that has been queried and is beyond the preset time period, and / or the target query condition is not a query condition that satisfies the preset query frequency, data query is performed based on the target query condition through the MongoDB server.

3. The method according to claim 2, characterized in that Performing data query based on the target query condition through the Redis server includes: If the Redis server has an abnormality that causes the data query to fail, the database server performs a data query based on the target query condition; Performing data query based on the target query condition through the MongoDB server includes: If the MongoDB server has an abnormality that causes the data query to fail, the database server performs a data query based on the target query condition.

4. The method according to claim 1, characterized in that: The method further comprises: If the query condition stored in the MongoDB server meets the preset query frequency, the MongoDB server is triggered to transfer the query condition meeting the preset query frequency and the corresponding query result to the Redis server.

5. The method according to claim 1, characterized in that The method further comprises: Data queries are regularly performed through the database server based on query conditions that meet the preset query frequency, and the query conditions that meet the preset query frequency and the corresponding latest query results are updated to the Redis server.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: In the case where it is determined that the query is the first time according to the target query condition, triggering a target number of threads, and performing parallel data query based on the target query condition in the database server, wherein the target number is determined according to CPU utilization and an expected maximum number of threads; The target query condition and the corresponding query result are stored in the Redis server.

7. A data query device, characterized in that: include: An acquisition module is configured to respond to a data query request sent by a client and acquire a target query condition carried in the data query request; A query module is configured to perform data query based on the target query condition through a Redis server or a MongoDB server when it is determined that the query is not the first query according to the target query condition; wherein the Redis server stores query conditions that have been queried within a preset time period and corresponding query results, and / or query conditions that meet a preset query frequency and corresponding query results; and the MongoDB server stores query conditions that have been queried beyond the preset time period and corresponding query results; The sending module is configured to send the query result corresponding to the target query condition to the client.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product having a computer program stored thereon, characterized in that: When the computer program product is executed by a processor, the method according to any one of claims 1 to 6 is implemented.