Data request response method, device, storage medium and electronic device

By querying and returning corresponding timeliness data in the database according to the interface and response level of client data requests, the problem that different data timeliness requirements in the prior art is solved, and efficient resource utilization and data timeliness are achieved.

CN119782396APending Publication Date: 2025-04-08INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411835983.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The prior art cannot meet the timeliness requirements required by different data in cache configuration, resulting in the timeliness of some data being unable to meet and the computing resource consumption is unreasonable.

Method used

By receiving the data request from the client, the interface to receive the data request is determined, and the response level of the data request is determined based on the interface. Query the corresponding data in the corresponding database and return the data to the client. The data refresh frequency in the corresponding databases at different response levels is different.

Benefits of technology

It realizes the return of corresponding timeliness data according to the timeliness requirements of data requests, which meets the timeliness requirements of data requests, and saves computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782396A_ABST
    Figure CN119782396A_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method, device, computer-readable storage medium and electronic device for responding to a data request, which relates to the field of computers. The method includes: receiving a data request sent by a client, determining an interface for receiving the data request; determining a response level of the data request according to the interface for receiving the data request; querying the data corresponding to the data request in a corresponding database according to the response level of the data request, and returning the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different. The refresh frequency of the data in the database corresponding to different response levels is different, so that the response level of the data request can be determined, and the data corresponding to the response level is returned. The refresh frequency of the returned data is adapted to the response level of the data request, which better meets the data timeliness required by the data request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and more specifically, to a method and device for responding to a data request, a computer-readable storage medium, and an electronic device. Background Art

[0002] With the development of the Internet and cloud computing technologies, the scale of data continues to expand. In storage systems, in order to increase the speed of data access, cache technology is usually used. By using local cache to cache data from remote servers to local servers, the number of calls to remote servers is reduced. By minimizing remote data access, the data processing efficiency of the storage system can be significantly improved.

[0003] In the related art, in order to balance the timeliness of data and the consumption of computer resources, a reasonable fixed refresh frequency is usually configured for the cache, that is, the cache will update the data at fixed intervals.

[0004] However, different data require different timeliness, and related technical methods cannot meet the timeliness requirements of certain data. Summary of the invention

[0005] The embodiments of the present application provide a method, device, computer-readable storage medium and electronic device for responding to a data request, which can return corresponding timely data based on the timeliness of the data required by the data request, thereby meeting the timeliness requirements of the data request to the greatest extent.

[0006] According to one embodiment of the present application, a method for responding to a data request is provided, the method comprising: receiving a data request sent by a client, and determining an interface for receiving the data request; determining a response level of the data request based on the interface for receiving the data request; based on the response level of the data request, querying a corresponding database for data corresponding to the data request, and returning the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

[0007] In an exemplary embodiment, according to the response level of the data request, the data corresponding to the data request is queried in the corresponding database, and the data is returned to the client, including: when it is determined that the response level of the data request is a real-time response level, determining that the database corresponding to the data request is a remote database, and sending a query request to the remote database; receiving real-time data returned by the remote database in response to the query request; and returning the real-time data to the client.

[0008] In an exemplary embodiment, when it is determined that the response level of the data request is a non-real-time response level, the database corresponding to the data request is determined to be a cache library; according to the non-real-time response level of the data request, the cache library corresponding to the data request is determined, and a query request is sent to the corresponding cache library; in response to the query request, the target data is queried in the cache library; when the target data exists in the cache library, the target data is returned to the client; when the target data does not exist in the cache library, the query request is forwarded to a remote database, the target data returned by the remote database in response to the query request is received, and the target data is returned to the client; before determining that the database corresponding to the data request is a cache library, the data request response method also includes: constructing multiple cache libraries, wherein each cache library includes different data; configuring scheduled tasks for the multiple cache libraries respectively, wherein the time intervals of the scheduled tasks configured for each cache library are different; sending query requests to the remote database respectively according to the multiple scheduled tasks, wherein the query requests are used to query the data corresponding to each cache library; receiving the data fed back by the remote database in response to the corresponding query request; and storing the data in the corresponding cache library.

[0009] In an exemplary embodiment, multiple cache libraries are constructed, including: constructing a master node and a slave node of a target cache library, wherein the target cache library is one of multiple databases, the master node is used to write and delete data in the target cache library, and the slave node is used to store operation logs recording the master node, the operation log includes the operation mode, operation data, operation timestamp, and updates the data in the target cache library according to the operation log; in the case of determining that the master node fails, the slave node is used as the new master node.

[0010] In an exemplary embodiment, before receiving a data request sent by a client and determining an interface for receiving the data request, the method includes: configuring one of multiple interfaces as a real-time interface; configuring a response level corresponding to the real-time interface to be a real-time response level; configuring other interfaces among the multiple interfaces except the real-time interface to be non-real-time interfaces; configuring the response levels corresponding to multiple non-real-time interfaces to be non-real-time response levels, wherein each non-real-time interface is configured with a different non-real-time response level.

[0011] In an exemplary embodiment, the response level of a data request is determined according to an interface that receives the data request, including: querying a pre-configured response level correspondence based on identification information of the interface that receives the data request to determine the response level of the interface that receives the data request; determining the response level of the data request according to the response level of the interface that receives the data request.

[0012] In an exemplary embodiment, the response level of the data request is determined according to the response level of the interface that receives the data request, including: when it is determined that the response level of the interface that receives the data request is a real-time response level, determining the response level of the data request is a real-time response level; when it is determined that the response level of the interface that receives the data request is a non-real-time response level, determining the non-real-time response level of the data request according to the response level correspondence.

[0013] According to another embodiment of the embodiment of the present application, a device for responding to a data request is further provided, the device comprising:

[0014] An interface determination module, used to receive a data request sent by a client and determine an interface for receiving the data request;

[0015] A level determination module, used to determine the response level of the data request according to the interface receiving the data request;

[0016] The response module is used to query the data corresponding to the data request in the corresponding database according to the response level of the data request, and return the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

[0017] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0018] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0019] According to another embodiment of the present application, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0020] Through the data request response method of the present application, the interface for receiving the data request can be determined. And according to the interface for receiving the data request, the response level of the data request is determined. Then, according to the response level of the data request, the data corresponding to the data request is queried in the corresponding database, and the data is returned to the client. The refresh frequency of the data in the database corresponding to different response levels is different, so that the response level of the data request can be determined, and the data corresponding to the response level is returned. The refresh frequency of the returned data is adapted to the response level of the data request, which better meets the data timeliness required by the data request. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0022] Figure 1 It is a hardware structure block diagram of a server device of a data request response method according to an embodiment of the present application;

[0023] Figure 2 is a flow chart of a method for responding to a data request according to an embodiment of the present application;

[0024] Figure 3 This is a second flowchart of a method for responding to a data request according to an embodiment of the present application;

[0025] Figure 4 This is a flowchart of a method for responding to a data request according to an embodiment of the present application;

[0026] Figure 5 This is a fourth flowchart of a method for responding to a data request according to an embodiment of the present application;

[0027] Figure 6 is a fifth flowchart of a method for responding to a data request according to an embodiment of the present application;

[0028] Figure 7 This is a sixth flowchart of a method for responding to a data request according to an embodiment of the present application;

[0029] Figure 8 is a seventh flowchart of a method for responding to a data request according to an embodiment of the present application;

[0030] Fig. 9 is a flowchart of a method for responding to a data request according to an embodiment of the present application;

[0031] Fig.10 is a structural block diagram of a data request response device according to an embodiment of the present application;

[0032] Fig.11 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0033] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0034] It should be noted that 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.

[0035] The data request response method embodiment provided in the embodiment of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a data request response method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0036] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the response method of the data request in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0037] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0038] As described in the background technology, the server in the related technology has the problem of insufficient response speed for some data with high timeliness requirements when responding to the data request of the client. The inventor has found that this is because, in order to improve the speed of data access, the related technology usually adopts caching technology, that is, using local cache to cache data from the remote server to the local cache, so as to reduce the number of calls to the remote server and improve the efficiency of data response. However, in the cache of the related technology, all data are refreshed at a fixed frequency, that is, the refresh frequency of all cached data is the same, for example, it is maintained at half an hour. Once the data requested by the client requires a high timeliness, such as real-time data, the data in the cache is still refreshed once every half an hour, so the timeliness of the data cannot meet the requirements. In addition, for some data with very low timeliness requirements, it can be refreshed at a lower refresh frequency, such as two hours, but the cache is still refreshed at a frequency of half an hour, resulting in a waste of computing resources.

[0039] In view of the above problems, a method for responding to a data request is provided in this embodiment. Figure 2 As shown, the method includes the following steps S200-220:

[0040] Step S200: receiving a data request sent by a client, and determining an interface for receiving the data request.

[0041] Specifically, when the client sends a data request to the server, it can select which interface of the server to send the data to according to the expected response speed of the data request.

[0042] Exemplarily, the interface for receiving the data request may be an application programming interface (Application Programming Interface, API).

[0043] Step S210: determining a response level of the data request according to the interface for receiving the data request.

[0044] Specifically, the response level of the data request can be determined according to the interface of the server receiving the data request. That is, each interface is assigned a response level according to its data stability and business requirements, which determines the refresh frequency of the data to be obtained.

[0045] Step S220: According to the response level of the data request, the corresponding database is searched for data corresponding to the data request, and the data is returned to the client.

[0046] The refresh frequencies of the data in the database corresponding to different response levels are different. For example, a data request with high real-time requirements may be response level 0 (real-time data refresh), and the data in the corresponding database is refreshed in real time, so the data returned to the client is real-time data. A data request with infrequent data changes may be response level 3 (daily refresh), and the data in the corresponding database is refreshed in real time, so the data returned to the client may be data refreshed within one day.

[0047] In this embodiment, the interface for receiving the data request can be determined. And according to the interface for receiving the data request, the response level of the data request can be determined. Then, according to the response level of the data request, the data corresponding to the data request is queried in the corresponding database, and the data is returned to the client. The refresh frequency of the data in the database corresponding to different response levels is different, so that the response level of the data request can be determined, and the data corresponding to the response level can be returned. The refresh frequency of the returned data is adapted to the response level of the data request, which better meets the data timeliness required by the data request.

[0048] In one embodiment, Figure 3 As shown, step S220, according to the response level of the data request, the corresponding database is searched for the data corresponding to the data request, and the data is returned to the client. It includes: steps S300-S320:

[0049] Step S300: When it is determined that the response level of the data request is a real-time response level, it is determined that the database corresponding to the data request is a remote database, and a query request is sent to the remote database.

[0050] Specifically, when a data request is identified as a real-time response level (such as response level 0), it means that the client has extremely high requirements for the timeliness of the data and needs to obtain the latest data status immediately. In this case, the query request is sent directly to the remote database (i.e., the backend database or data source) that stores the real-time data.

[0051] Step S310: receiving real-time data returned by the remote database in response to the query request.

[0052] Specifically, after receiving the query request, the remote database performs the corresponding data retrieval or calculation, and then returns the real-time data. This real-time data may include the latest records in the database table, real-time calculation results, the latest information of the external data source, etc.

[0053] Step S320, returning the real-time data to the client.

[0054] Specifically, after receiving the real-time data, it can be encapsulated into a format understandable to the client and then returned to the client through the network to complete the response to the data request.

[0055] In this embodiment, a data request at the real-time response level directly queries a remote database to obtain data, thereby ensuring that the data is up-to-date and meeting the customer's strict requirements on data timeliness.

[0056] In one embodiment, Figure 4 As shown, step S220, according to the response level of the data request, the corresponding database is searched for the data corresponding to the data request, and the data is returned to the client. It includes: steps S400-S440:

[0057] Step S400: When it is determined that the response level of the data request is a non-real-time response level, it is determined that the database corresponding to the data request is a cache library.

[0058] Specifically, the non-real-time response level means that the response to the data request can have a certain delay, but the higher requirements are data processing efficiency and resource conservation. In this case, you can choose to access the cache library instead of directly accessing the remote database to reduce the consumption of backend resources.

[0059] Step S410: determining a cache library corresponding to the data request according to the non-real-time response level of the data request, and sending a query request to the corresponding cache library.

[0060] Specifically, data requests with different non-real-time response levels will be mapped to cache libraries with different refresh strategies to query data. For example, data requests that are refreshed at the minute level will be queried in the minute-level cache library, while data requests that are refreshed at the daily level will be queried in the cache library that is refreshed at the daily level. Therefore, different refresh frequencies can be used to refresh data with different response requirements, saving cache resources.

[0061] Exemplarily, the architecture of the present application is described, and the present application includes a client, a server, and a remote database. The server includes middleware and multiple cache libraries. Middleware (such as Ngin×, HAProxy, and custom Python decorators) can intercept data requests issued by the client, and then identify the interface associated with the data request, and then determine the response level of the data request. The cache library can be a Remote Dictionary Server (Redis) distributed cache library, which includes multiple cache libraries, and different cache libraries query and store data from the remote database at different frequencies. If the response level of the data request is determined to be a real-time response level, the latest data is directly queried from the remote database according to the data request. If the response level of the data request is determined to be a non-real-time response level, the required data is queried from the corresponding cache library according to the data request.

[0062] Step S420: In response to the query request, query the target data in the cache library.

[0063] Step S430: if the target data exists in the cache library, the target data is returned to the client.

[0064] Step S440: if the target data does not exist in the cache, forward the query request to the remote database, receive the target data returned by the remote database in response to the query request, and return the target data to the client.

[0065] Specifically, after receiving the query request, the cache library searches for the target data in the cache library according to the query request. If the data exists, the cache library returns the data immediately. If the data does not exist, it needs to query the remote database.

[0066] like Figure 5 As shown, before determining in step S400 that the database corresponding to the data request is a cache library, the method for responding to the data request further includes: steps S500-S540:

[0067] Step S500, constructing multiple cache libraries.

[0068] Each cache library includes different data.

[0069] Step S510: configuring scheduled tasks for multiple cache libraries respectively.

[0070] The time intervals of the scheduled tasks configured for each cache library are different.

[0071] Step S520: sending query requests to the remote database according to the multiple scheduled tasks.

[0072] The query request is used to query the data corresponding to each cache library.

[0073] Step S530: receiving data fed back by the remote database in response to the corresponding query request.

[0074] Step S540: store the data into the corresponding cache library.

[0075] Specifically, in order to implement the data cache classification strategy, it is necessary to build multiple cache libraries, each of which stores data of different response levels. At the same time, a scheduled task is configured for each cache library, and different data refresh frequencies are set according to data stability or business needs. When the scheduled task is triggered, the cache library will send a query request to the remote database, obtain data, and store the data in the cache library.

[0076] In this embodiment, when a data request requires a non-real-time response, by accessing the cache library instead of directly accessing the remote database, the load on the back-end system can be significantly reduced, the processing speed of the data request can be improved, and network resources and computing resources can be saved. The cache classification strategy ensures the balance between the timeliness and accuracy of the data and resource consumption and processing efficiency. Cache libraries of different levels meet the data request requirements in different scenarios, improving the overall performance and responsiveness of the system. Searching for data in the cache library greatly improves the response speed of data requests, reduces dependence on the remote database, thereby reducing the load on the remote database and improving the responsiveness and stability of the system. By constructing multiple cache libraries and configuring timed refresh tasks, the present invention can achieve data cache classification, and different levels of data correspond to different refresh frequencies, thereby ensuring the timeliness and accuracy of the data while minimizing the consumption of back-end resources and improving the overall performance and stability of the system.

[0077] In one embodiment, Figure 6 As shown, step S500, construct multiple cache libraries. It includes: steps S600-S610:

[0078] Step S600, constructing the master node and slave nodes of the target cache library.

[0079] Among them, the target cache library is one of multiple databases, the master node is used to write and delete data in the target cache library, and the slave node is used to store and record the operation log of the master node. The operation log includes the operation mode, operation data, operation timestamp, and updates the data in the target cache library according to the operation log.

[0080] Specifically, in order to ensure the reliability and consistency of cached data, the present invention adopts a master-slave replication architecture to build each cache library, realizing redundant backup of data. The master node is responsible for all write and delete operations, while the slave node records the logs of these operations so that when the master node fails, the data state can be restored according to the logs.

[0081] Step S610: When it is determined that the master node fails, the slave node is used as a new master node.

[0082] Specifically, once a master node failure is detected, the slave node can be used as a new master node to continue to provide cache services.

[0083] In this embodiment, the cache library includes a master node and a slave node architecture to improve the reliability of the cache library. Even if the master node fails, the slave node can take over the work. In addition, through the recording and application of operation logs, data consistency is guaranteed, avoiding data loss or inconsistency caused by master node failure.

[0084] In one embodiment, Figure 7 As shown, in step S200, a data request sent by a client is received, and before an interface for receiving the data request is determined, the method for responding to the data request includes: steps S700-S730:

[0085] Step S700: configuring one of the multiple interfaces as a real-time interface.

[0086] Specifically, one of the multiple interfaces is configured as a real-time interface, and the real-time interface is used to receive data requests with high real-time requirements, such as data requests involving real-time transactions, real-time monitoring or instant feedback.

[0087] Step S710: configure the response level corresponding to the real-time interface to be a real-time response level.

[0088] Specifically, the response level of the real-time interface is set to the real-time response level to distinguish it from the non-real-time interface, ensuring that the processing strategy for the real-time interface is different from that for other interfaces.

[0089] Step S720: configure the other interfaces among the multiple interfaces except the real-time interface as non-real-time interfaces.

[0090] Specifically, except for the real-time interface, other interfaces are configured as non-real-time interfaces. These interfaces have relatively low requirements on the real-time performance of data, so they can be processed using a cache classification strategy to improve efficiency and resource utilization.

[0091] Step S730: configure the response levels corresponding to the multiple non-real-time interfaces as non-real-time response levels.

[0092] Each non-real-time interface is configured with a different non-real-time response level. For non-real-time interfaces, different non-real-time response levels should be configured according to their business characteristics and data change frequency. This means that different non-real-time interfaces may correspond to cache libraries with different refresh frequencies to meet different business needs.

[0093] Exemplarily, in the corresponding relationship of the response level of the interface, an identifier is assigned to each interface, and an identifier representing the real-time response level is set, such as "0, 1, 2, 3". 0, 1, 2, and 3 represent the response level. The larger the value, the lower the response level, which means that the cache data of the interface needs to be refreshed less frequently. Among them, 0 means that the data of the interface needs to be real-time data and needs to be queried in real time without querying from the cache database. 1 means that the data of the interface needs to be refreshed at the minute level. 2 means that the data of the interface needs to be refreshed at the hour level. 3 means that the data of the interface needs to be refreshed on a daily basis.

[0094] In this embodiment, by configuring the interface as a real-time interface, data requests of the real-time interface can be efficiently processed, thereby improving the response capability to real-time data demand scenarios. By configuring the interface as a non-real-time interface, data in the cache library can be used to respond to response requests of the non-real-time interface, thereby reducing the number of queries to the backend database, reducing the database load, and improving the overall response speed and performance of the system.

[0095] In one embodiment, Figure 8 As shown, step S210, according to the interface receiving the data request, determines the response level of the data request. It includes: steps S800-S810:

[0096] Step S800: query a pre-configured response level correspondence relationship according to the identification information of the interface receiving the data request to determine the response level of the interface receiving the data request.

[0097] Step S810: determining the response level of the data request according to the response level of the interface receiving the data request.

[0098] Specifically, the response level of the interface determines the processing method of the data request, and the response level of the data request can be directly determined according to the response level of the interface.

[0099] In this embodiment, by determining the response level of the data request, the system can intelligently select the data acquisition method. For requests with high real-time requirements, direct queries can be performed to ensure the immediacy and accuracy of the data. For non-real-time requests, cache is used to improve the response speed and reduce the load on the remote database, thus achieving effective utilization and optimization of resources.

[0100] In one embodiment, Fig. 9 As shown, step S810, according to the response level of the interface receiving the data request, determines the response level of the data request. It includes: steps S900-S910:

[0101] Step S900: When it is determined that the response level of the interface receiving the data request is the real-time response level, determine the response level of the data request as the real-time response level.

[0102] Step S910: When it is determined that the response level of the interface receiving the data request is a non-real-time response level, the non-real-time response level of the data request is determined according to the response level correspondence relationship.

[0103] In this embodiment, when it is determined that the response level of the interface receiving the data request is a real-time response level, the response level of the data request is directly determined to be a real-time response level. When it is determined that the response level of the interface receiving the data request is a non-real-time response level, it is necessary to query the response level correspondence to determine the non-real-time response level of the data request, thereby achieving the classification of the response level of the data request. For requests with high real-time requirements, direct inquiries can be made to ensure the immediacy and accuracy of the data. For non-real-time requests, cache is used to improve the response speed, while reducing the load of the remote database, thereby achieving effective utilization and optimization of resources.

[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0105] In this embodiment, a response device for data request is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0106] Fig.10 : is a structural block diagram of a data request response device according to an embodiment of the present application, the device comprising:

[0107] The interface determination module 1001 is used to receive a data request sent by a client and determine an interface for receiving the data request.

[0108] The level determination module 1002 is used to determine the response level of the data request according to the interface for receiving the data request.

[0109] The response module 1003 is used to query the data corresponding to the data request in the corresponding database according to the response level of the data request, and return the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

[0110] The above device can determine the interface for receiving the data request. And according to the interface for receiving the data request, determine the response level of the data request. Then, according to the response level of the data request, query the data corresponding to the data request in the corresponding database, and return the data to the client. The refresh frequency of the data in the database corresponding to different response levels is different, so that the response level of the data request can be determined, and the data corresponding to the response level can be returned. The refresh frequency of the returned data is adapted to the response level of the data request, which better meets the data timeliness required by the data request.

[0111] In an exemplary embodiment, the response module 1003 is further configured to, when determining that the response level of the data request is a real-time response level, determine that the database corresponding to the data request is a remote database, and send a query request to the remote database, receive real-time data returned by the remote database in response to the query request, and return the real-time data to the client.

[0112] In an exemplary embodiment, the response module 1003 is also used to determine that the database corresponding to the data request is a cache library when it is determined that the response level of the data request is a non-real-time response level. According to the non-real-time response level of the data request, the cache library corresponding to the data request is determined, and a query request is sent to the corresponding cache library. In response to the query request, the target data is queried in the cache library. In the case that the target data exists in the cache library, the target data is returned to the client. In the case that the target data does not exist in the cache library, the query request is forwarded to the remote database, the target data returned by the remote database in response to the query request is received, and the target data is returned to the client.

[0113] In an exemplary embodiment, the above device further includes:

[0114] The database construction module is used to construct multiple cache libraries, wherein each cache library includes different data.

[0115] The scheduled task configuration module is used to configure scheduled tasks for multiple cache libraries respectively, wherein the time interval of the scheduled tasks configured for each cache library is different.

[0116] The query module is used to send query requests to the remote database according to multiple scheduled tasks, wherein the query request is used to query the data corresponding to each cache library.

[0117] The receiving module is used to receive data fed back by the remote database in response to the corresponding query request.

[0118] The storage module is used to store data into the corresponding cache library.

[0119] In an exemplary embodiment, the database construction module is also used to construct a master node and a slave node of a target cache library, wherein the target cache library is one of multiple databases, the master node is used to write and delete data in the target cache library, and the slave node is used to store and record the operation log of the master node, the operation log includes the operation mode, operation data, operation timestamp, and update the data in the target cache library according to the operation log. In the case of determining that the master node fails, the slave node is used as a new master node.

[0120] In an exemplary embodiment, the above device further includes:

[0121] The first configuration module is used to configure one of the multiple interfaces as a real-time interface.

[0122] The second configuration module is used to configure the response level corresponding to the real-time interface to be a real-time response level.

[0123] The third configuration module is used to configure the other interfaces among the multiple interfaces except the real-time interface as non-real-time interfaces.

[0124] The fourth configuration module is used to configure the response levels corresponding to the multiple non-real-time interfaces as non-real-time response levels, wherein the non-real-time response level configured for each non-real-time interface is different.

[0125] In an exemplary embodiment, the level determination module 1002 is further configured to query a pre-configured response level correspondence relationship according to the identification information of the interface receiving the data request to determine the response level of the interface receiving the data request. According to the response level of the interface receiving the data request, the response level of the data request is determined.

[0126] In an exemplary embodiment, the level determination module 1002 is further configured to determine the response level of the data request as the real-time response level when the response level of the interface receiving the data request is determined to be the real-time response level. When the response level of the interface receiving the data request is determined to be the non-real-time response level, the non-real-time response level of the data request is determined according to the response level correspondence.

[0127] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above modules are all located in the same processor. Alternatively, the above modules are located in different processors in any combination.

[0128] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0129] Optionally, in this embodiment, the computer program may be configured to perform the following steps by means of the computer program:

[0130] S1, receiving a data request sent by a client and determining an interface for receiving the data request.

[0131] S2, determining a response level of the data request according to the interface for receiving the data request.

[0132] S3, according to the response level of the data request, query the data corresponding to the data request in the corresponding database, and return the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

[0133] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0134] The embodiment of the present application also provides an electronic device, such as Fig.10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps in any of the above method embodiments through the computer program.

[0135] Optionally, in this embodiment, the processor 1004 may be configured to perform the following steps through a computer program:

[0136] S1, receiving a data request sent by a client and determining an interface for receiving the data request.

[0137] S2, determining a response level of the data request according to the interface for receiving the data request.

[0138] S3, according to the response level of the data request, query the data corresponding to the data request in the corresponding database, and return the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

[0139] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0140] Alternatively, a person skilled in the art may understand that: Fig.11 The structure shown is for illustration only. Fig.11 The structure of the electronic device is not limited. For example, the electronic device may also include Fig.11More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.11 Different configurations are shown.

[0141] Among them, the memory 1102 can be used to store software programs and modules, such as the program instructions / modules corresponding to the data request response method and the data request response device in the embodiment of the present application. The processor 1104 executes various functional applications and data processing by running the software programs and modules stored in the memory 1102, that is, realizing the above-mentioned data request response method. The memory 1102 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1102 may further include a memory remotely located relative to the processor 1104, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1102 can be specifically, but not limited to, used to store information such as system configuration files. As an example, such as Fig.11 As shown, the memory 1102 may include but is not limited to the modules in the above-mentioned data request response device. In addition, it may also include but is not limited to other module units in the above-mentioned data request response device, which will not be repeated in this example.

[0142] Optionally, the transmission device 1106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 1106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1106 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0143] In addition, the electronic device further includes: a display 1108; and a connection bus 1111, which is used to connect various module components in the electronic device.

[0144] In other embodiments, the electronic device may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes in the form of network communication. Among them, the nodes may form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.

[0145] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0146] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0147] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above method embodiments.

[0148] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0149] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for responding to a data request, characterized in that: The method comprises: Receive a data request sent by a client, and determine an interface for receiving the data request; Determining a response level of the data request according to an interface for receiving the data request; According to the response level of the data request, the data corresponding to the data request is queried in the corresponding database, and the data is returned to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

2. The method for responding to a data request according to claim 1, characterized in that: The querying of the data corresponding to the data request in the corresponding database according to the response level of the data request, and returning the data to the client, comprises: In the case where it is determined that the response level of the data request is a real-time response level, determining that the database corresponding to the data request is a remote database, and sending a query request to the remote database; Receiving real-time data returned by the remote database in response to the query request; The real-time data is returned to the client.

3. The method for responding to a data request according to claim 2, characterized in that: The querying of the data corresponding to the data request in the corresponding database according to the response level of the data request, and returning the data to the client, comprises: In the case where it is determined that the response level of the data request is a non-real-time response level, determining that the database corresponding to the data request is a cache library; Determine, according to the non-real-time response level of the data request, a cache library corresponding to the data request, and send a query request to the corresponding cache library; In response to the query request, query the cache library for target data; If the target data exists in the cache library, returning the target data to the client; If the target data does not exist in the cache, forwarding the query request to the remote database, receiving the target data returned by the remote database in response to the query request, and returning the target data to the client; Before determining that the database corresponding to the data request is a cache library, the data request response method further includes: constructing a plurality of cache libraries, wherein each cache library includes different data; configuring scheduled tasks for the multiple cache libraries respectively, wherein the time intervals of the scheduled tasks configured for each cache library are different; According to the plurality of scheduled tasks, query requests are sent to the remote database respectively, wherein the query request is used to query the data corresponding to each cache library; Receiving data fed back by the remote database in response to a corresponding query request; The data is stored in the corresponding cache library.

4. The method for responding to a data request according to claim 3, characterized in that: The construction of multiple cache libraries includes: Constructing a master node and a slave node of a target cache library, wherein the target cache library is one of the multiple databases, the master node is used to write and delete data in the target cache library, and the slave node is used to store an operation log recording the master node, the operation log including an operation mode, operation data, and an operation timestamp, and updating the data in the target cache library according to the operation log; When it is determined that the master node fails, the slave node is used as a new master node.

5. The method for responding to a data request according to claim 2, characterized in that: Before receiving the data request sent by the client and determining the interface for receiving the data request, the method includes: configuring one of the multiple interfaces as a real-time interface; Configuring the response level corresponding to the real-time interface to be a real-time response level; Configuring the other interfaces among the multiple interfaces except the real-time interface as non-real-time interfaces; The response levels corresponding to the plurality of non-real-time interfaces are configured as non-real-time response levels, wherein the non-real-time response level configured for each of the non-real-time interfaces is different.

6. The method for responding to a data request according to claim 5, characterized in that: The step of determining a response level of the data request according to an interface for receiving the data request includes: According to the identification information of the interface receiving the data request, querying a pre-configured response level correspondence relationship to determine the response level of the interface receiving the data request; The response level of the data request is determined according to the response level of the interface that receives the data request.

7. The method for responding to a data request according to claim 6, characterized in that: The step of determining the response level of the data request according to the response level of the interface receiving the data request comprises: In the case where it is determined that the response level of the interface receiving the data request is the real-time response level, determining the response level of the data request to be the real-time response level; In the case where it is determined that the response level of the interface receiving the data request is a non-real-time response level, the non-real-time response level of the data request is determined according to the response level correspondence.

8. A device for responding to a data request, characterized in that: The device comprises: An interface determination module, used to receive a data request sent by a client and determine an interface for receiving the data request; A level determination module, used to determine the response level of the data request according to the interface receiving the data request; The response module is used to query the data corresponding to the data request in the corresponding database according to the response level of the data request, and return the data to the client, wherein the refresh frequency of the data in the database corresponding to different response levels is different.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.