Data query method and device, electronic equipment and storage medium

By selecting the appropriate storage hierarchy among multiple storage hierarchies to execute data queries and storing and switching based on the query results, the problems of low efficiency and poor stability of data queries under high concurrency and large data volumes are solved, and more efficient and stable data queries are achieved.

CN120030059APending Publication Date: 2025-05-23SHANSHU TECH (BEIJING) CO LTD +5
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510188748.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In application scenarios with high concurrent requests and large data volumes, traditional data query technology is inefficient and poorly stable, especially when complex queries or query conditions change frequently, query reuse technology cannot work effectively.

Method used

By selecting the appropriate storage hierarchy among multiple storage hierarchies to perform data query operations, the data query order is characterized at the level. If the query is successful, the result will be stored, and if it fails, the next storage hierarchy will be switched to the next storage hierarchy for querying.

Benefits of technology

Improve the efficiency and stability of data queries, reduce the access to the main database through multi-level caching strategies, optimize the query order at a hierarchy, and the fault-tolerant mechanism ensures that the system can still provide services when a certain level is unavailable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030059A_ABST
    Figure CN120030059A_ABST
Patent Text Reader

Abstract

The invention discloses a data query method and device, electronic equipment and a storage medium, and relates to the technical field of data query. The method comprises the steps that for an obtained data query request, according to levels corresponding to a plurality of storage levels, a first storage level is selected from the storage levels to execute data query operation, and the levels represent a data query sequence; if the data query succeeds, storing a data result obtained by query in a corresponding storage level according to a first level corresponding to the first storage level; and if the data query fails, selecting a second storage level from the plurality of storage levels to execute the data query operation according to the levels respectively corresponding to the plurality of storage levels. Therefore, according to the technical scheme, the efficiency and the stability of data query can be effectively improved through measures such as a multi-level cache strategy, query sequence optimization, a fault-tolerant mechanism, data backup and redundancy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of Internet technology, the amount of data has exploded, especially in the fields of online transactions, social networks and big data analysis. The frequency and amount of data access requests are increasing sharply, which puts higher requirements on database systems. Especially when dealing with high-concurrency requests and large amounts of data, traditional data query technology will face the problems of low efficiency and poor stability.

[0003] One of the existing data query optimization technologies is query reuse technology, which identifies and stores previously executed queries and their results so that the cached results can be directly used in subsequent identical query requests, thereby reducing repeated queries and calculations on the database and improving query efficiency. Query reuse technology can realize the process of data manipulation functions and determine the efficient execution plan for a given query. Among them, the execution plan, that is, the query tree, consists of a series of internal operators, which form an execution plan for the query according to certain operation relationships.

[0004] However, for complex queries or situations where query conditions change frequently, the slight differences in each query may make it impossible to reuse previous query results. Query reuse technology may not work effectively, affecting the stability of data queries. Summary of the invention

[0005] The embodiments of the present application provide a data query method, device, electronic device and storage medium to solve the problems of low data query efficiency and poor stability in application scenarios with high concurrent requests and large data volumes.

[0006] On the one hand, an embodiment of the present application provides a data query method, including:

[0007] For the obtained data query request, according to the levels respectively corresponding to the multiple storage levels, a first storage level is selected from the multiple storage levels to perform a data query operation, where the level represents a data query order;

[0008] If the data query is successful, the data results obtained by the query are stored in the corresponding storage level according to the first level corresponding to the first storage level;

[0009] If the data query fails, a second storage layer is selected from the multiple storage layers according to the levels respectively corresponding to the multiple storage layers to perform the data query operation.

[0010] On the one hand, an embodiment of the present application provides a data query device, including:

[0011] A selection module is used for selecting a first storage layer from among the multiple storage layers to perform a data query operation according to the levels corresponding to the multiple storage layers for the obtained data query request, wherein the levels represent a data query order;

[0012] A storage module, for storing the data results obtained by the query in a corresponding storage layer according to the first level corresponding to the first storage layer if the data query is successful;

[0013] The switching module selects a second storage layer from the multiple storage layers to perform a data query operation according to the levels respectively corresponding to the multiple storage layers if the data query fails.

[0014] In some embodiments, the selection module is used to: determine the number of operations corresponding to the data query operation, and the first level of the storage hierarchy corresponding to the first number of operations; select the first storage hierarchy corresponding to the first level among multiple storage hierarchies, and perform the data query operation on the first storage hierarchy.

[0015] In some embodiments, multiple storage levels include a first cache, a second cache, and a main database; then, among the multiple storage levels, the selection module is used to: if the number of operations corresponding to the first level is 1, the first cache is used as the first storage level, and a data query operation is performed on the first cache; if the number of operations corresponding to the first level is 2, the second cache is used as the first storage level, and a data query operation is performed on the second cache; if the number of operations corresponding to the first level is 3, the main database is used as the first storage level, and a data query operation is performed on the main database.

[0016] In some embodiments, the storage module is used to: determine whether the first level represents that the data query order of the first storage level is ranked first; if not, determine at least one storage level whose data query order is before the first level, and store the data results obtained by the query in at least one storage level respectively.

[0017] In some embodiments, multiple storage levels include a first cache, a second cache, and a main database, the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third; then, the storage module is used to: if the first level represents that the data query order of the first storage level is ranked first, then directly return the data result; if the first level represents that the data query order of the first storage level is ranked second, then store the data result in the first cache and return the data result; if the first level represents that the data query order of the first storage level is ranked third, then store the data result in the first cache and the second cache, and return the data result.

[0018] In some embodiments, the switching module is used to: determine, among the levels corresponding to multiple storage levels, a second level whose data query order is adjacent to the first level and is arranged after the first level; select a second storage level corresponding to the second level among the multiple storage levels, and perform a data query operation on the second storage level.

[0019] In some embodiments, multiple storage levels include a first cache, a second cache, and a main database, the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third; then, the switching module is used to: if the first level is characterized as the data query order of the first storage level being ranked first, then perform a data query operation on the second cache; if the first level is characterized as the data query order of the first storage level being ranked second, then perform a data query operation on the main database.

[0020] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes any one of the above-mentioned data query methods.

[0021] On the one hand, the present application provides a computer-readable storage medium, which includes a program code. When the storage medium is run on an electronic device, the program code is used to enable the electronic device to execute any of the above-mentioned data query methods.

[0022] The beneficial effects of this application are as follows:

[0023] (1) Improve data query efficiency. First, a multi-level cache strategy is adopted. By selecting the first storage level from multiple storage levels to perform data query operations, direct access to the main database is avoided, which can significantly reduce data access latency. In addition, if the query data exists in the first storage level, there is no need to access the database, which can reduce the query load of the database and improve the throughput of the overall system. Second, in the technical solution of the present application, the levels represent the order of data queries. In this way, data can be queried in order from fastest to slowest, so that results can be returned immediately when data is found, rather than disordered queries that lead to potentially long waits. Third, when a query is successful, the data is stored in the corresponding storage level, which helps to maintain the freshness of the cached data while also reducing the latency of subsequent queries.

[0024] (2) Improve the stability of data query. First, when the query fails at the first storage level, the system will switch to the next storage level for query according to the level order. This fault-tolerant mechanism ensures that the system can still provide services when a certain level is unavailable. Second, by storing data in multiple storage levels, even if a storage level fails, the data can be recovered from other levels, thereby improving data reliability and system stability.

[0025] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0027] Figure 1 This is a schematic diagram of an application scenario in an embodiment of the present application;

[0028] Figure 2 This is a flowchart of an implementation of a data query method in an embodiment of the present application;

[0029] Figure 3 This is an example diagram of a data query method in an embodiment of the present application;

[0030] Figure 4 This is a structural diagram of a data query device in an embodiment of the present application;

[0031] Figure 5 The present invention is a schematic diagram of a hardware structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0033] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.

[0034] The following is a brief introduction to the design concept of the embodiment of the present application:

[0035] In order to improve the efficiency of data query, one of the existing data query optimization technologies is query reuse technology. This technology identifies and stores previously executed queries and their results so that the cached results can be directly used in subsequent identical query requests, thereby reducing repeated queries and calculations on the database and improving query efficiency. Query reuse technology can realize the process of data manipulation functions and determine the process of efficient execution plan for a given query. Among them, the execution plan, that is, the query tree, consists of a series of internal operators, which form an execution plan for the query according to a certain operation relationship. However, for complex queries or situations where query conditions change frequently, the slight differences in each query may make it impossible to reuse the previous query results. Query reuse technology may not work effectively, affecting the stability of data queries.

[0036] In view of this, the embodiments of the present application provide a data query method, device, electronic device and storage medium. Among them, the data query method includes: for the obtained data query request, according to the levels corresponding to the multiple storage levels, select the first storage level in the multiple storage levels to perform the data query operation, and the level represents the data query order; if the data query is successful, according to the first level corresponding to the first storage level, the data results obtained by the query are stored in the corresponding storage level; if the data query fails, according to the levels corresponding to the multiple storage levels, select the second storage level in the multiple storage levels to perform the data query operation. In this way, the technical solution of the present application can effectively improve the efficiency and stability of data query through multi-level cache strategy, query order optimization, fault tolerance mechanism, data backup and redundancy, load balancing and other measures.

[0037] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0038] like Figure 1 , which is a schematic diagram of an application scenario provided by an embodiment of the present application. In the schematic diagram of the application scenario, a terminal device 101 and a server 102 are included. The terminal device 101 and the server 102 communicate with each other through a communication network.

[0039] The terminal device 101 is an electronic device used by the target object, and the electronic device may be a personal computer, a mobile phone, a tablet computer, a notebook, an e-book reader, a vehicle-mounted terminal, etc. In addition, a data query-related client may be installed on the terminal device 101, and the client may be a software (e.g., an APP, a browser, etc.), or a web page, a small program, etc. The target object may use the above-mentioned data query-related client through the terminal device 101 to perform data query-related operations.

[0040] The server 102 may be an independent physical server or an edge device 102 in the field of cloud computing. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, cloud functions, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (English name: Content Delivery Network, abbreviated as CDN), as well as big data and artificial intelligence platforms.

[0041] There is no restriction on the number of the terminal devices 101 and / or servers 102 .

[0042] It should be noted that the data query method in the embodiment of the present application can be executed by the terminal device 101 or the server 102 alone, or can be executed jointly by the terminal device 101 and the server 102. For example, when executed jointly by the terminal device 101 and the server 102, the terminal device 101 creates a data query request and sends the data query request to the server 102. The server 102 selects the first storage level from the multiple storage levels to perform the data query operation according to the levels corresponding to the multiple storage levels for the obtained data query request, and the levels represent the order of data query; if the data query is successful, the data result obtained by the query is stored in the corresponding storage level according to the first level corresponding to the first storage level, and is returned to the terminal device 101; if the data query fails, the second storage level is selected from the multiple storage levels to perform the data query operation according to the levels corresponding to the multiple storage levels.

[0043] The following describes the data query method provided by the exemplary embodiment of the present application in combination with the above-mentioned application scenarios and with reference to the accompanying drawings. It should be noted that the above-mentioned application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation methods of the present application are not subject to any limitations in this regard.

[0044] refer to Figure 2 , is an implementation flow chart of a data query method provided in an embodiment of the present application, which is introduced here with the server as the execution subject. The specific implementation process of the method is as follows:

[0045] S201, for an acquired data query request, according to the levels respectively corresponding to the multiple storage levels, select a first storage level from the multiple storage levels to perform a data query operation, where the level represents a data query order.

[0046] In an embodiment of the present application, the target object can send a data query request to the server through a terminal device. The target object here can be a user or a developer or tester.

[0047] After receiving the data query request, the server selects storage levels in turn from the multiple storage levels according to the levels corresponding to the multiple storage levels to perform the data query operation until the data query result corresponding to the data query request is obtained, wherein the levels corresponding to the multiple storage levels respectively represent the data query order of the multiple storage levels.

[0048] Optionally, when the multiple storage levels are the first cache, the second cache, and the main database, the levels of the first cache, the second cache, and the main database can be set to 1, 2, and 3, which means that when executing the data query operation instruction for the data query request, the data query needs to be performed in the order of the first cache, the second cache, and the main database, and the levels corresponding to the multiple storage levels correspond to the data query order. Among them, the first cache can be ehcache, or Caffeine, Hazelcast, etc.; the second cache can be redis, or Valkey, Riak, Aerospike, etc.; the main database can be mysql, or PostgreSQL, Oracle Database, MariaDB, etc., depending on the application scenario.

[0049] It can be seen from this that each time a data query operation is performed, it is necessary to select a corresponding first storage level from multiple storage levels according to the levels corresponding to the multiple storage levels to perform the current data query operation. The specific method includes: determining the number of operations corresponding to the data query operation, and the first level of the storage level corresponding to the first number of operations; among multiple storage levels, selecting the first storage level corresponding to the first level, and performing the data query operation on the first storage level.

[0050] In one implementation, the multiple storage levels include a first cache, a second cache, and a main database; then, among the multiple storage levels, a first storage level corresponding to the first level is selected, and a data query operation is performed on the first storage level, including: determining the number of data operations corresponding to the data query request of the first level, if the number of operations corresponding to the first level is 1, using the first cache as the first storage level, and performing a data query operation on the first cache; if the number of operations corresponding to the first level is 2, using the second cache as the first storage level, and performing a data query operation on the second cache; if the number of operations corresponding to the first level is 3, using the main database as the first storage level, and performing a data query operation on the main database.

[0051] S202: If the data query is successful, the data results obtained by the query are stored in the corresponding storage layer according to the first level corresponding to the first storage layer.

[0052] After executing the data query instruction on the first storage layer, a data query result can be obtained, and the data query result includes a data query success and a data query failure.

[0053] When the data query result is that the data query is successful, it indicates that the data result corresponding to the data query request has been queried in the first storage layer. At this time, the data result is returned to the target object, and according to the first level corresponding to the first storage layer, the queried data result is stored in the corresponding storage layer, including:

[0054] Determine whether the first level represents that the data query order of the first storage level is ranked first; if so, directly return the data results obtained by the query; if not, determine at least one storage level whose data query order is before the first level, and store the data results obtained by the query in at least one storage level respectively.

[0055] In one embodiment, multiple storage levels include a first cache, a second cache, and a main database, and the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third. According to the first level corresponding to the first storage level, the data results obtained by the query are stored in the corresponding storage level, including: judging the data query order ranking of the first storage level represented by the first level; if the data query order ranking of the first storage level represented by the first level is ranked first, directly returning the data result; if the data query order ranking of the first storage level represented by the first level is ranked second, storing the data result in the first cache and returning the data result; if the data query order ranking of the first storage level represented by the first level is ranked third, storing the data result in the first cache and the second cache, and returning the data result.

[0056] For example, refer to Figure 3 As shown, there are three storage levels of ehcache, redis, and mysql database, among which ehcache and redis are the first cache and the second cache respectively, and the mysql database is the main database. In this example, after the user initiates a data query request, for the data request, the data query operation is first performed on the ehcache cache to determine whether there is the result data to be queried in the ehcache cache. If there is the result data to be queried in the ehcache cache, the result data obtained by the query is returned; if there is no result data to be queried in the ehcache cache, the data query operation is further performed on the redis cache, and it is determined whether there is the result data to be queried in the redis cache; if there is the result data to be queried in the redis cache, the result data is saved in the ehcache cache, and if there is no result data to be queried in the redis cache, the data query operation is further performed on the mysql database, the result data obtained by the query is saved in the redis cache and the ehcache cache, and the result data is returned to the user.

[0057] In this way, hierarchical query is implemented on multiple storage levels, data is obtained from the cache first, and then from the main database. This can improve data query efficiency and avoid excessive load on the main database. At the same time, the query result data is saved in the corresponding storage level, which can also improve the reliability of subsequent data queries.

[0058] In one embodiment, when the query result data is saved in a storage layer with a higher query priority, the corresponding data in the storage layer of the query result data can be deleted to release memory and reduce storage pressure.

[0059] For example, when the result data to be queried does not exist in the ehcache cache, a data query operation is performed on the redis cache, and it is determined whether there is result data to be queried in the redis cache. At this time, if there is result data to be queried in the redis cache, the result data is saved in the ehcache cache. At the same time, the result data in the redis cache can be deleted to release the memory of redis; if there is no result data to be queried in the redis cache, a data query operation is further performed on the mysql database, and the result data obtained by the query is saved in the redis cache and the ehcache cache. At this time, according to the application scenario and data type, for example, in a test scenario or when the result data is temporary, non-critical, and unimportant data, the result data in the mysql database can be deleted.

[0060] Based on the above content, it can be known that if the result data corresponding to the query request is queried in the current first storage layer, and the first storage layer is not the storage layer with the highest query priority, then the result data obtained by the query can be saved in the storage layer with a higher query priority. In this way, the number of accesses to the storage layer with a lower query priority can be reduced, which helps to improve the overall data query efficiency. At the same time, in some scenarios, some high-priority storage layers may provide better data protection measures, and storing important data in these layers can improve data security.

[0061] S203: If the data query fails, a second storage layer is selected from the multiple storage layers to perform a data query operation according to the levels corresponding to the multiple storage layers.

[0062] In the embodiment of the present application, if the result data corresponding to the data query request is not obtained in the first storage layer, it is necessary to further select a second storage layer from the multiple storage layers to perform the data query operation according to the levels corresponding to the multiple storage layers, including:

[0063] Among the levels corresponding to the multiple storage levels, a second level whose data query order is adjacent to the first level and is arranged after the first level is determined; a second storage level corresponding to the second level is selected among the multiple storage levels, and a data query operation is performed on the second storage level.

[0064] It should be noted that the first storage level here does not necessarily represent the storage level with the highest data query priority, but only represents the storage level on which the data query operation currently needs to be performed.

[0065] In one embodiment, the multiple storage levels include a first cache, a second cache, and a main database, the first cache is ranked first in data query order, the second cache is ranked second in data query order, and the main database is ranked third in data query order; then, according to the levels corresponding to the multiple storage levels, the second storage level is selected from the multiple storage levels to perform a data query operation, including:

[0066] Determine the data query order of the first storage level represented by the first level, wherein each level has a one-to-one correspondence with the data query order of its corresponding storage level. Figure 3 In the data query order of ehcache, redis, and mysql databases, the order of data query is order 1, order 2, and order 3. If the corresponding levels are named level 1, level 2, and level 3, then order 1, order 2, and order 3 correspond to level 1, level 2, and level 3 respectively, and the corresponding data query order can be found according to the level. If the first level is represented by the first storage level, the data query order is ranked first, then the data query operation is performed on the second cache; if the first level is represented by the first storage level, the data query order is ranked second, then the data query operation is performed on the main database.

[0067] For example, refer to Figure 3, multiple storage levels are ehcache, redis, and mysql database, wherein the first data query operation is performed based on ehcache, the second data query operation is performed based on redis, and the third data query operation is performed based on mysql database. That is to say, the data query order of the three storage levels of ehcache, redis, and mysql database is level 1, level 2, and level 3 respectively. Therefore, if the first level corresponding to the first storage level is level 1, it is determined that the data query order is adjacent to the first level, and the second level after the first level is level 2, that is, the corresponding second storage level is redis cache; if the first level corresponding to the first storage level is level 2, it is determined that the data query order is adjacent to the first level, and the second level after the first level is level 3, that is, the corresponding second storage level is mysql database. After determining the second storage level, the data query operation can be performed on the second storage level.

[0068] Based on the technical solution of this application, the following technical effects can be achieved:

[0069] (1) Improve data query efficiency. First, a multi-level cache strategy is adopted. By selecting the first storage level from multiple storage levels to perform data query operations, direct access to the main database is avoided, which can significantly reduce data access latency. In addition, if the query data exists in the first storage level, there is no need to access the database, which can reduce the query load of the database and improve the throughput of the overall system. Second, in the technical solution of the present application, the levels represent the order of data queries. In this way, data can be queried in order from fastest to slowest, so that results can be returned immediately when data is found, rather than disordered queries that lead to potentially long waits. Third, when a query is successful, the data is stored in the corresponding storage level, which helps to maintain the freshness of the cached data while also reducing the latency of subsequent queries.

[0070] (2) Improve the stability of data query. First, when the query fails at the first storage level, the system will switch to the next storage level for query according to the level order. This fault-tolerant mechanism ensures that the system can still provide services when a certain level is unavailable. Second, by storing data in multiple storage levels, even if a storage level fails, the data can be recovered from other levels, thereby improving data reliability and system stability.

[0071] Based on the same inventive concept, the present application embodiment also provides a data query device. Figure 4 As shown, it is a schematic diagram of the structure of a data query device 400, which may include:

[0072] A selection module 401 is used for selecting a first storage layer from among multiple storage layers to perform a data query operation according to the levels corresponding to the multiple storage layers for the obtained data query request, wherein the levels represent the order of data query;

[0073] The storage module 402 is used to store the query result in the corresponding storage level according to the first level corresponding to the first storage level if the data query is successful;

[0074] The switching module 403 selects a second storage layer from the multiple storage layers to perform a data query operation according to the levels respectively corresponding to the multiple storage layers if the data query fails.

[0075] In some embodiments, the selection module 401 is used to: determine the number of operations corresponding to the data query operation, and the first level of the storage hierarchy corresponding to the first number of operations; among multiple storage hierarchies, select the first storage hierarchy corresponding to the first level, and perform the data query operation on the first storage hierarchy.

[0076] In some embodiments, the multiple storage levels include a first cache, a second cache, and a main database; then, among the multiple storage levels, the selection module 401 is used to: if the number of operations corresponding to the first level is 1, the first cache is used as the first storage level, and a data query operation is performed on the first cache; if the number of operations corresponding to the first level is 2, the second cache is used as the first storage level, and a data query operation is performed on the second cache; if the number of operations corresponding to the first level is 3, the main database is used as the first storage level, and a data query operation is performed on the main database.

[0077] In some embodiments, the storage module 402 is used to: determine whether the first level represents that the data query order of the first storage level is ranked first; if not, determine at least one storage level whose data query order is before the first level, and store the data results obtained by the query in at least one storage level respectively.

[0078] In some embodiments, multiple storage levels include a first cache, a second cache, and a main database, the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third; then, the storage module 402 is used to: if the first level represents that the data query order of the first storage level is ranked first, then directly return the data result; if the first level represents that the data query order of the first storage level is ranked second, then store the data result in the first cache and return the data result; if the first level represents that the data query order of the first storage level is ranked third, then store the data result in the first cache and the second cache, and return the data result.

[0079] In some embodiments, the switching module 403 is used to: determine, among the levels corresponding to multiple storage levels, a second level whose data query order is adjacent to the first level and is arranged after the first level; select a second storage level corresponding to the second level among the multiple storage levels, and perform a data query operation on the second storage level.

[0080] In some embodiments, multiple storage levels include a first cache, a second cache, and a main database, the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third; then, the switching module 403 is used to: if the first level is characterized as the data query order of the first storage level is ranked first, then perform a data query operation on the second cache; if the first level is characterized as the data query order of the first storage level is ranked second, then perform a data query operation on the main database.

[0081] The technical effects achieved by the above data query device can be referred to the data query method part, which will not be described in detail here.

[0082] In some possible implementations, the data query device according to the present application may include at least a processor and a memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the data query method according to various exemplary implementations of the present application described in this specification. For example, the processor may execute the following steps: Figure 2 Follow the steps shown in .

[0083] Based on the same inventive concept, an electronic device is also provided in the embodiment of the present application. The electronic device can implement the functions of the aforementioned data query method and device. Figure 5 , electronic equipment includes:

[0084] At least one processor 501, and a memory 502 connected to the at least one processor 501. The specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of the present application. Figure 5 In the example, the processor 501 and the memory 502 are connected via a bus 500. The bus 500 is Figure 5 The connections between other components are shown in bold lines, and are not intended to be limiting. The bus 500 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 501 can also be called a controller, and there is no limitation on the name.

[0085] In the embodiment of the present application, the memory 502 stores instructions that can be executed by at least one processor 501. The at least one processor 501 can execute the data query method discussed above by executing the instructions stored in the memory 502. The processor 501 can implement Figure 4 The functions of each module in the device shown.

[0086] Among them, the processor 501 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 502 and calling data stored in the memory 502, the various functions of the device and processing data, the device can be monitored as a whole.

[0087] In one possible design, the processor 501 may include one or more processing units, and the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 501. In some embodiments, the processor 501 and the memory 502 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.

[0088] Processor 501 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the data query method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.

[0089] The memory 502 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 502 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 502 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 502 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0090] By designing and programming the processor 501, the code corresponding to the data query method described in the above embodiment can be fixed into the chip, so that the chip can execute the data query method when running. Figure 2 The steps of the data query method of the embodiment shown are as follows: How to design and program the processor 501 is a technique known to those skilled in the art and will not be described in detail here.

[0091] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the data query method discussed above.

[0092] In some possible implementations, various aspects of the data query method provided by the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on an apparatus, the program code is used to enable the control device to execute the steps of the data query method according to various exemplary implementations of the present application described above in this specification.

[0093] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0094] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0095] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0096] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0097] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data query method, characterized in that: include: In response to the obtained data query request, selecting a first storage layer from the multiple storage layers to perform a data query operation according to the levels respectively corresponding to the multiple storage layers, wherein the levels represent a data query order; If the data query is successful, the data result obtained by the query is stored in the corresponding storage layer according to the first level corresponding to the first storage layer; If the data query fails, a second storage layer is selected from the multiple storage layers according to the levels respectively corresponding to the multiple storage layers to perform the data query operation.

2. The method according to claim 1, characterized in that: The step of selecting a first storage level from among the multiple storage levels to perform a data query operation according to the levels corresponding to the multiple storage levels respectively includes: Determining an operation number corresponding to the data query operation, and a first level of a storage hierarchy corresponding to the first operation number; Among the multiple storage levels, a first storage level corresponding to the first level is selected, and the data query operation is performed on the first storage level.

3. The method according to claim 2, characterized in that: The multiple storage levels include a first cache, a second cache, and a main database; then, selecting a first storage level corresponding to the first level from the multiple storage levels, and performing the data query operation on the first storage level, includes: If the number of operations corresponding to the first level is 1, the first cache is used as the first storage level, and the data query operation is performed on the first cache; If the number of operations corresponding to the first level is 2, the second cache is used as the first storage level, and the data query operation is performed on the second cache; If the number of operations corresponding to the first level is 3, the main database is used as the first storage level, and the data query operation is performed on the main database.

4. The method according to claim 1, characterized in that: According to the first level corresponding to the first storage level, storing the query result in the corresponding storage level includes: Determining whether the first level represents that the data query order of the first storage level is ranked first; If not, at least one storage level whose data query order is before the first level is determined, and the data results obtained by the query are respectively stored in the at least one storage level.

5. The method according to claim 1, characterized in that: The multiple storage levels include a first cache, a second cache, and a main database, the first cache is ranked first in data query order, the second cache is ranked second in data query order, and the main database is ranked third in data query order; then, according to the first level corresponding to the first storage level, storing the query result in the corresponding storage level includes: If the first level represents that the data query order of the first storage layer is ranked first, directly returning the data result; If the first level represents that the data query order of the first storage level is ranked second, storing the data result in the first cache and returning the data result; If the first level represents that the data query order of the first storage level is ranked third, the data result is stored in the first cache and the second cache, and the data result is returned.

6. The method according to claim 1, characterized in that: The selecting a second storage level from the multiple storage levels to perform the data query operation according to the levels respectively corresponding to the multiple storage levels includes: Determining, among the levels respectively corresponding to the plurality of storage levels, a second level whose data query order is adjacent to the first level and is arranged after the first level; A second storage layer corresponding to the second level is selected from the multiple storage layers, and the data query operation is performed on the second storage layer.

7. The method according to claim 1, characterized in that: The multiple storage levels include a first cache, a second cache, and a main database, the data query order of the first cache is ranked first, the data query order of the second cache is ranked second, and the data query order of the main database is ranked third; then, selecting the second storage level in the multiple storage levels to perform the data query operation according to the levels respectively corresponding to the multiple storage levels includes: If the first level characterizes that the data query order of the first storage level is ranked first, performing the data query operation on the second cache; If the first level characterizes that the data query order of the first storage layer is ranked second, the data query operation is performed on the main database.

8. A data query device, characterized in that: include: A selection module is used to select a first storage layer from among the multiple storage layers to perform a data query operation according to the levels respectively corresponding to the multiple storage layers for the obtained data query request, wherein the levels represent a data query order; A storage module, configured to store the data results obtained by the query in a corresponding storage layer according to the first level corresponding to the first storage layer if the data query is successful; The switching module selects a second storage layer from the multiple storage layers to perform the data query operation according to the levels respectively corresponding to the multiple storage layers if the data query fails.

9. An electronic device, characterized in that: The device comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes any one of the methods in claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium comprises a program code, and when the storage medium is run on an electronic device, the program code is used to enable the electronic device to execute any one of the methods described in claims 1 to 7.