CN112818336A - Data access method, data access device and computer readable storage medium - Google Patents

Data access method, data access device and computer readable storage medium Download PDF

Info

Publication number
CN112818336A
CN112818336A CN202011579612.2A CN202011579612A CN112818336A CN 112818336 A CN112818336 A CN 112818336A CN 202011579612 A CN202011579612 A CN 202011579612A CN 112818336 A CN112818336 A CN 112818336A
Authority
CN
China
Prior art keywords
data access
response information
function
server
access request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011579612.2A
Other languages
Chinese (zh)
Inventor
黄晓贵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Iwelan Technology Co ltd
Original Assignee
Shenzhen Iwelan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Iwelan Technology Co ltd filed Critical Shenzhen Iwelan Technology Co ltd
Priority to CN202011579612.2A priority Critical patent/CN112818336A/en
Publication of CN112818336A publication Critical patent/CN112818336A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Automation & Control Theory (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请适用于通信技术领域,提供了一种数据访问方法、数据访问装置、计算机设备及计算机可读存储介质,所述数据访问方法包括:通过应用程序从预设连接池中调用目标连接,向服务器发送第一数据访问请求;其中,服务器用于根据第一数据访问请求返回响应信息;调用操作系统监听函数对所述响应信息进行监听操作;若监听到响应信息,则通过应用程序调用目标连接获取并加载响应信息。上述数据访问方法通过目标连接发送第一数据访问请求,并在监听到响应信息时调用目标连接获取响应信息,因此,该数据访问方法无需通过该标识信息确定该第一数据访问请求对应的响应信息。该数据访问方法实现过程简单,降低了处理过程的复杂度,进而提高了处理效率。

Figure 202011579612

The present application is applicable to the field of communication technology, and provides a data access method, a data access device, computer equipment and a computer-readable storage medium. The data access method includes: calling a target connection from a preset connection pool through an application program, and sending a The server sends a first data access request; wherein, the server is used to return response information according to the first data access request; call the operating system monitoring function to monitor the response information; if the response information is monitored, call the target connection through the application program Get and load response information. The above data access method sends the first data access request through the target connection, and calls the target connection to obtain the response information when monitoring the response information. Therefore, the data access method does not need to determine the response information corresponding to the first data access request through the identification information. . The implementation process of the data access method is simple, the complexity of the processing process is reduced, and the processing efficiency is improved.

Figure 202011579612

Description

Data access method, data access device and computer readable storage medium
Technical Field
The present application belongs to the field of communications technologies, and in particular, to a data access method, a data access device, a computer device, and a computer-readable storage medium.
Background
Currently, with the development of the mobile internet, under many application scenarios, the processing of a large amount of data and high concurrency service requests has become a normal state. Existing solutions typically employ an asynchronous processing based data access approach to these highly concurrent requests. The asynchronous processing means that after the client sends the request to the server, the client can process other transactions without waiting for the processing result of the server, and after the server finishes processing, the client receives the response corresponding to the request.
However, in the existing data access method, a virtual channel needs to be established on a channel where a server is connected with a client, the server receives first data access requests sent by the client through the virtual channel, and each first data access request carries identification information, so that the server needs to determine result data corresponding to a certain first data access request based on the identification information and then send the result data to the client. Therefore, the existing data access method has the problems of complicated implementation process, increased complexity of the processing process and reduced processing efficiency.
Disclosure of Invention
The embodiment of the application provides a data access method, a data access device, computer equipment and a computer readable storage medium, and can solve the problems that the existing data access method is complicated in implementation process, increases the complexity of a processing process and reduces the processing efficiency.
In a first aspect, an embodiment of the present application provides a data access method, including:
calling a target connection from a preset connection pool through an application program, and sending a first data access request to a server; the server is used for returning response information according to the first data access request;
calling an operating system monitoring function to monitor the response information;
and if the response information is monitored, calling the target connection through the application program to acquire and load the response information.
Further, the target connection is configured with a socket, the operating system monitor function is an epoll function, and the application program is configured with a callback function; the calling an operating system monitoring function to monitor the response information, which comprises the following steps:
placing the target connection in a monitoring queue of the epoll function, and binding the target connection with the callback function;
and calling the epoll function to monitor the socket of the target connection.
Further, the target connection is configured with a sending function and a receiving function, the calling the target connection from the preset connection pool through the application program, and sending the first data access request to the server includes:
executing the sending function through the target connection, and sending the first data access request to the server;
correspondingly, the obtaining and loading the response information by calling the target connection through the application program includes:
and calling the target connection through the callback function to execute the receiving function, and receiving the response information.
Further, after the calling the monitoring function of the operating system performs the monitoring operation on the response information, the method further includes:
and if the response information is not monitored, executing a first preset operation.
Further, after the target connection is called from the preset connection pool by the application program and the first data access request is sent to the server, the method further includes:
receiving response information returned by the server;
if the response information is used for indicating that the server successfully receives the first data access request, executing a second preset operation;
if the response information is used for indicating that the server does not receive the first data access request, first prompt information is sent to the application program; the first prompt message is used for prompting that the first data access request fails to be sent.
Further, before the target connection is called from the preset connection pool by the application program and the first data access request is sent to the server, the method further includes:
initializing the connection with preset number, and placing the connection after initialization in the preset connection pool.
Further, after the calling the target connection by the application program to obtain and load the response information, the method further includes:
and returning the target connection to the preset connection pool.
In a second aspect, an embodiment of the present application provides a data access apparatus, including:
the first sending unit is used for calling a target connection from a preset connection pool through an application program and sending a first data access request to the server; the server is used for returning response information according to the first data access request;
the calling unit is used for calling an operating system monitoring function to monitor the response information;
and the acquisition unit is used for calling the target connection through the application program to acquire and load the response information if the response information is monitored.
In a third aspect, an embodiment of the present application provides a computer device, including:
a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the data access method according to any of the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the data access method according to any one of the first aspect.
In a fifth aspect, the present application provides a computer program product, which when run on a computer device, enables the computer device to execute the data access method of any one of the above first aspects.
Compared with the prior art, the embodiment of the application has the advantages that:
according to the data access method provided by the embodiment of the application, the target connection is called from the preset connection pool through the application program, and a first data access request is sent to the server; the server is used for returning response information according to the first data access request; calling an operating system monitoring function to monitor the response information; and if the response information is monitored, calling the target connection through the application program to acquire and load the response information. According to the data access method, the first data access request is sent by obtaining the target connection in the preset connection pool, and the response information is obtained by calling the target connection when the response information is monitored, so that the first data access request in the data access method does not need to carry identification information, the response information corresponding to the first data access request does not need to be determined through the identification information, the response information corresponding to the first data access request can be obtained by only calling the target connection sending the first data access request, the data access method is simple in implementation process, the complexity of a processing process is reduced, and the processing efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a schematic diagram of a data access system provided by an embodiment of the present application;
FIG. 2 is a flowchart of an implementation of a data access method provided in an embodiment of the present application;
fig. 3 is a flowchart of a specific implementation of S202 in a data access method provided in an embodiment of the present application;
FIG. 4 is a flowchart illustrating an implementation of a data access method according to another embodiment of the present application;
fig. 5 is a flowchart of specific implementation of S201 and S203 in a data access method provided in an embodiment of the present application;
FIG. 6 is a flowchart illustrating an implementation of a data access method according to yet another embodiment of the present application;
FIG. 7 is a schematic structural diagram of a data access device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a computer device according to another embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data access system to which a data access method according to an embodiment of the present disclosure is applied, and as shown in fig. 1, the data access system may include a data access device 10 and a server 20 communicatively connected to the data access device 10. The data access device 10 may include, but is not limited to, a smart phone, a tablet computer, a desktop computer, or the like. The server 20 may be a smartphone, tablet or desktop computer, etc.
The data access device 10 further includes application programs 30 (only one of which is shown in the figure).
In the embodiment of the present application, the data access device 10 is further configured with a predetermined connection pool (not shown in the figure). The preset connection pool is used for storing a plurality of connections, and the connections are used for sending a data access request from the application program 30 to the server 20 and returning response information for the data access request from the server 20 to the application program 30. The data access request is used to request data, i.e., response information corresponding to the data access request, to be acquired from the server 20.
Referring to fig. 2, fig. 2 is a flowchart illustrating an implementation of a data access method according to an embodiment of the present application. In the embodiment of the application, the execution subject of the data access method is a data access device. As shown in fig. 2, a data access method provided in an embodiment of the present application may include S201 to S203, which are detailed as follows:
in S201, calling a target connection from a preset connection pool through an application program, and sending a first data access request to a server; and the server is used for returning response information according to the first data access request.
In the embodiment of the application, when an application program in the data access device needs to access the server, the data access device may call the target connection from the preset connection pool through the application program, and send the first data access request to the server. Wherein the target connection refers to a connection for sending the first data access request.
It should be noted that, when the data access apparatus invokes the target connection from the preset connection pool through the application program and sends the first data access request to the server, the server may return response information according to the first data access request, that is, the response information is for the first data access request.
In S202, an operating system snoop function is called to perform a snoop operation on the response information.
In the embodiment of the application, after the data access device sends the first data access request to the server, an operating system monitor function can be called to monitor the response information. The os snoop function may be determined according to actual needs, and is not limited herein, and the os snoop function may be, for example, an epoll function, a select function, or a poll function.
In an embodiment of the present application, since the epoll function is used to listen for the response message, the data access device does not need to add an additional module to poll for the response message, and the target connection is configured with a Socket (Socket), and the application is configured with a callback function.
The socket is a basic operation unit of network communication supporting a Transmission Control Protocol (TCP)/Internet Protocol (IP), and may be regarded as an end point of two-way communication performed by processes between different hosts, which is simply an agreement between two communicating parties, and a communication process is completed by using a related function in the socket.
A callback function refers to a function called by a function pointer. In particular, a pointer (address) to a function may be passed as a parameter to another function, and when this pointer is used to call the function to which it points, the function to which it points is a callback function. It should be noted that the callback function is not directly called by the implementing side of the function, but is called by another side when a specific event or condition occurs, and is used for responding to the event or condition.
Based on this, the data access device can specifically implement the listening operation through steps S301 to S302 shown in fig. 3, which are detailed as follows:
in S301, the target connection is placed in a listening queue of the epoll function, and the target connection is bound to the callback function.
In this embodiment, the epoll function may monitor multiple connections at the same time, and therefore, the data access device may place the target connection in a monitoring queue of the epoll function. Meanwhile, in order to return the response information to the application program in time when the epoll function monitors the response information, the data access device can also bind the target connection with the callback function, so that the data access device can call the target connection to acquire the response information through the callback function when monitoring the response information.
In S302, the epoll function is called to monitor the socket of the target connection.
In this embodiment, after the data access device places the target connection in the listening queue of the epoll function and binds the target connection with the callback function, the data access device may call the epoll function to listen to the socket of the target connection, and determine whether response information for the first data access request is returned.
In the embodiment of the application, after calling the monitoring function of the operating system to perform monitoring operation on the response information, the data access device determines whether the response information is returned or not through the monitoring function of the operating system. If the data access device monitors the response message, the data access device executes step S203.
It should be noted that, in an actual application, since the server will send the response information of the data access request to the application program in a short time after receiving the data access request, in another embodiment of the present application, after the data access device calls the operating system snoop function to perform a snoop operation on the response information, if the response information of the data access request is not returned within the first preset time period, which indicates that the response information of the data access request is lost, the data access device sends the second prompt information to the application program. The first preset time period may be set according to actual needs, and is not limited herein, and for example, the first preset time period may be one minute. The second prompt message is used for prompting that the response message of the data access request is not monitored in the first preset time period.
In S203, if the response information is monitored, the application program calls the target connection to acquire and load the response information.
In the embodiment of the application, after monitoring the response information, the data access device indicates that the server returns corresponding information according to the first data access request, and therefore, the data access device can call the target connection through the application program to acquire and load the response information.
In an embodiment of the application, after the data access device calls the target connection through the application program to obtain and load the response information, the target connection can be put back to the preset connection pool, so that the data access device can conveniently continue to use the target connection to send other data access requests to the server.
As can be seen from the above, in the method provided in this embodiment, the target connection is called from the preset connection pool through the application program, and the first data access request is sent to the server; the server is used for returning response information according to the first data access request; calling an operating system monitoring function to monitor the response information; and if the response information is monitored, calling the target connection through the application program to acquire and load the response information. According to the data access method, the first data access request is sent by obtaining the target connection in the preset connection pool, and the response information is obtained by calling the target connection when the response information is monitored, so that the first data access request in the data access method does not need to carry identification information, the response information corresponding to the first data access request does not need to be determined through the identification information, the response information corresponding to the first data access request can be obtained by only calling the target connection sending the first data access request, the data access method is simple in implementation process, the complexity of a processing process is reduced, and the processing efficiency is improved.
Referring to fig. 4, fig. 4 is a flowchart illustrating an implementation of a data access method according to another embodiment of the present application. With respect to the embodiment corresponding to fig. 2, the data access apparatus of the present embodiment further includes S401 after S202, which is detailed as follows:
in S401, if the response message is not monitored, a first preset operation is performed.
In this embodiment, when the data access apparatus does not listen to the response information, the first preset operation may be executed. The first preset operation may be set according to actual needs, and is not limited herein.
In an implementation manner of the embodiment of the present application, the first preset operation may be: and calling a second connection from the preset connection pool through the application program, and sending a second data access request to the server. Wherein the second connection is different from the target connection and the second data access request is different from the first data access request.
The data access device executes the first preset operation, so that the data access device can continue to call a new connection from the preset connection pool through the application program and send the new data access request to the server without waiting for the response information of the first data access request to return after sending the first data access request to the server, and the speed of processing the data access request by the data access device is improved.
In another implementation manner of the embodiment of the present application, the first preset operation may further be: and processing the preset transaction. The preset transaction may be determined according to actual needs, and is not limited herein. It should be noted that the preset transaction refers to a transaction other than sending a data access request to the server.
As can be seen from the above, according to the data access method provided in this embodiment, when the response information is not monitored, the first preset operation may be executed, so that the data access apparatus does not need to wait for the response information to return when the response information is not monitored, but may execute other operations.
In practical applications, because the target connection is usually configured with an execution function, and the data access apparatus usually calls the target connection to execute the execution function through the application program to implement sending of the data access request and returning of the response information, after the data access apparatus calls the target connection to execute the execution function through the application program and sends the data access request to the server, the data access apparatus can only wait for the return of the response information all the time, and continue to call the target connection to execute the execution function to obtain the response information, and then can process other transactions, which not only takes a long time, but also reduces the processing efficiency of the data access apparatus.
Based on this, in one embodiment of the present application, the data access device splits the execution function of the target connection into a sending function and a receiving function, i.e., the target connection is configured with the sending function and the receiving function. Referring to fig. 5, fig. 5 is a flowchart illustrating an implementation of S201 and S203 in the embodiment corresponding to fig. 2 according to the present application; in some possible implementations of the present application, the S201 specifically includes S501, and the S203 specifically includes S503, which is detailed as follows:
in S501, the sending function is executed through the target connection, and the first data access request is sent to the server.
In S202, an operating system snoop function is called to perform a snoop operation on the response information.
In S503, the target connection is called by the callback function to execute the receiving function, and the response information is received.
In this embodiment, when the data access device needs to send the first data access request to the server, the target connection may be called from the preset connection pool through the application program, and the sending function is executed through the target connection, so as to send the first data access request to the server.
After the data access device sends the first data access request to the server, the data access device can also call an operating system monitoring function to monitor the response information. The os snoop function may be determined according to actual needs, and is not limited herein, and the os snoop function may be, for example, an epoll function, a select function, or a poll function.
In an embodiment of the present application, since the epoll function is used to listen for the response message, the data access device does not need to add an additional module to poll for the response message, and the target connection is configured with a Socket (Socket), and the application is configured with a callback function.
The socket is a basic operation unit of network communication supporting a Transmission Control Protocol (TCP)/Internet Protocol (IP), and may be regarded as an end point of two-way communication performed by processes between different hosts, which is simply an agreement between two communicating parties, and a communication process is completed by using a related function in the socket.
A callback function refers to a function called by a function pointer. In particular, a pointer (address) to a function may be passed as a parameter to another function, and when this pointer is used to call the function to which it points, the function to which it points is a callback function. It should be noted that the callback function is not directly called by the implementing side of the function, but is called by another side when a specific event or condition occurs, and is used for responding to the event or condition.
When the data access device monitors the response information, the target connection can be called through a callback function of the application program, and the response information is received by executing the receiving function through the target connection.
As can be seen from the above, in the data access method provided in this embodiment, the executing function of the target connection is split into the sending function and the receiving function, so that the data access device can respectively call the sending function or the receiving function of the target connection as needed, and when the response information is monitored, the receiving function of the target connection is called to receive the response information without waiting for the return of the response information, thereby improving the processing efficiency of the data access device.
Referring to fig. 6, fig. 6 is a flowchart illustrating an implementation of a data access method according to still another embodiment of the present application. With respect to the embodiment corresponding to fig. 2, the data access device in this embodiment further includes steps S601 to S603 after S201, which are detailed as follows:
in S601, response information returned by the server is received.
In this embodiment, after sending the first data access request to the server, the data access device may receive response information returned by the server. And the response information is used for describing whether the server successfully receives the first data access request.
After receiving the response information returned by the server, the data access device may perform a corresponding operation according to the response information. If the data access device detects that the response information is used to indicate that the server successfully receives the first data access request, which indicates that the data access device has successfully sent the first data access request, then step S602 is executed; if the data access device detects that the response information indicates that the server has not received the first data access, and indicates that the data access device has failed to send the first data access request to the server, the data access device executes step S603.
In an embodiment of the present application, the failure of the data access apparatus to send the first data access request to the server may be: the data access device does not receive the response information sent by the server within a second preset time period. The second preset time period may be set according to actual needs, and is not limited herein.
In S602, if the response information is used to indicate that the server successfully receives the first data access request, a second preset operation is performed.
In this embodiment, when the data access device detects that the response information is used to indicate that the server successfully receives the first data access request, it indicates that the data access device successfully sends the first data access request to the server, and therefore, the data access device may perform the second preset operation. The second preset operation may be set according to actual needs, and is not limited herein.
In an implementation manner of the embodiment of the present application, the first preset operation may be: and calling a second connection from the preset connection pool through the application program, and sending a second data access request to the server. Wherein the second connection is different from the target connection and the second data access request is different from the first data access request.
The data access device executes the first preset operation, so that the data access device can continue to call a new connection from the preset connection pool through the application program and send the new data access request to the server without waiting for the response information of the first data access request to return after sending the first data access request to the server, and the speed of processing the data access request by the data access device is improved.
In another implementation manner of the embodiment of the present application, the first preset operation may further be: and processing the preset transaction. The preset transaction may be determined according to actual needs, and is not limited herein. It should be noted that the preset transaction refers to a transaction other than sending a data access request to the server.
In S603, if the response information is used to indicate that the server does not receive the first data access request, sending first prompt information to the application program; the first prompt message is used for prompting that the first data access request fails to be sent.
In this embodiment, when the data access device detects that the response information is used to indicate that the server has not received the first data access request, it indicates that the data access device has failed to send the first data access request to the server, and therefore, the data access device may send the first prompt information to the application program. The first prompt message is used for prompting that the first data access request fails to be sent.
As can be seen from the above, in the data access method provided in this embodiment, after the first data access request is sent to the server, the response information sent by the server may also be received, and it is determined whether the first data access request is successfully sent to the server according to the response information, so that the data access device may execute corresponding operations according to whether the first data access request is successfully sent to the server, and the processing efficiency of the data access device is improved.
In another embodiment of the present application, the data access apparatus may further perform an initialization operation on a preset number of connections before the first data access request is sent to the server by using the application program to call the target connection from the preset connection pool, and place the connections after the initialization operation in the preset connection pool. When the data access device needs to send a data access request to the server, the target connection can be directly obtained from the preset connection pool without creating a new connection, so that the time and the resources of the data access device are saved, and the processing efficiency of the data access device is improved.
The preset data may be set according to actual needs, and is not limited here, for example, the preset number is determined according to how many data access requests need to be sent. The initialization operation refers to restoring the connection to a default state.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 7 shows a block diagram of a data access device provided in an embodiment of the present application, corresponding to a data access method described in the foregoing embodiment, and only the relevant parts of the embodiment of the present application are shown for convenience of description. Referring to fig. 7, the data access apparatus 700 includes: a first sending unit 71, a calling unit 72 and an acquiring unit 73. Wherein:
the first sending unit 71 is configured to invoke a target connection from a preset connection pool through an application program, and send a first data access request to the server; and the server is used for returning response information according to the first data access request.
The calling unit 72 is configured to call an operating system listening function to perform a listening operation on the response information.
The obtaining unit 73 is configured to, if the response information is monitored, call the target connection through the application program to obtain and load the response information.
In an embodiment of the present application, the target connection is configured with a socket, the operating system monitor function is an epoll function, and the application is configured with a callback function; the invoking unit 72 specifically includes: a binding unit and a monitoring unit. Wherein:
the binding unit is configured to place the target connection in a listening queue of the epoll function, and bind the target connection and the callback function.
And the monitoring unit is used for calling the epoll function to monitor the socket connected with the target.
In an embodiment of the present application, the target connection is configured with a sending function and a receiving function, and the first sending unit 71 is specifically configured to: and executing the sending function through the target connection, and sending the first data access request to the server.
Correspondingly, the obtaining unit 73 is specifically configured to: and calling the target connection through the callback function to execute the receiving function, and receiving the response information.
In one embodiment of the present application, the data access device 700 further comprises: a first execution unit.
The first execution unit is used for executing a first preset operation if the response information is not monitored.
In one embodiment of the present application, the data access device 700 further comprises: the device comprises a receiving unit, a second execution unit and a second sending unit.
The receiving unit is used for receiving the response information returned by the server.
The second execution unit is configured to execute a second preset operation if the response information is used to indicate that the server successfully receives the first data access request.
The second sending unit is used for sending first prompt information to the application program if the response information is used for indicating that the server does not receive the first data access request; the first prompt message is used for prompting that the first data access request fails to be sent.
In one embodiment of the present application, the data access device 700 further comprises: and initializing the unit.
The initialization unit is used for performing initialization operation on a preset number of connections and placing the connections after the initialization operation in the preset connection pool.
In one embodiment of the present application, the data access device 700 further comprises: and placing the unit.
The placing unit is used for placing the target connection back to the preset connection pool.
As can be seen from the above, in the data access device provided in the embodiment of the present application, the target connection is called from the preset connection pool through the application program, and the first data access request is sent to the server; the server is used for returning response information according to the first data access request; calling an operating system monitoring function to monitor the response information; and if the response information is monitored, calling the target connection through the application program to acquire and load the response information. According to the data access method, the first data access request is sent by obtaining the target connection in the preset connection pool, and the response information is obtained by calling the target connection when the response information is monitored, so that the first data access request in the data access method does not need to carry identification information, the response information corresponding to the first data access request does not need to be determined through the identification information, the response information corresponding to the first data access request can be obtained by only calling the target connection sending the first data access request, the data access method is simple in implementation process, the complexity of a processing process is reduced, and the processing efficiency is improved.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the embodiment of the method of the present application, and specific reference may be made to the part of the embodiment of the method, which is not described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Fig. 8 is a schematic structural diagram provided in an embodiment of the present application. As shown in fig. 8, the computer device 8 of this embodiment includes: at least one processor 80 (only one shown in fig. 8), a memory 81, and a computer program 82 stored in the memory 81 and operable on the at least one processor 80, the processor 80 implementing the steps in any of the various data access method embodiments described above when executing the computer program 82.
The computer device may include, but is not limited to, a processor 80, a memory 81. Those skilled in the art will appreciate that fig. 8 is merely an example of the computer device 8 and does not constitute a limitation of the computer device 8, and may include more or less components than those shown, or combine certain components, or different components, such as input output devices, network access devices, etc.
The Processor 80 may be a Central Processing Unit (CPU), and the Processor 80 may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 81 may in some embodiments be an internal storage unit of the computer device 8, such as a memory of the computer device 8. The memory 81 may also be an external storage device of the computer device 8 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the computer device 8. The memory 81 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer program. The memory 81 may also be used to temporarily store data that has been output or is to be output.
The embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the above-mentioned method embodiments.
The embodiments of the present application provide a computer program product, which when executed on a computer device, enables the computer device to implement the steps in the above method embodiments.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or apparatus capable of carrying computer program code to a terminal device, recording medium, computer Memory, Read-Only Memory (ROM), Random-Access Memory (RAM), electrical carrier wave signals, telecommunications signals, and software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed data access device and method may be implemented in other ways. For example, the above-described apparatus/network device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implementing, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method of data access, comprising:
calling a target connection from a preset connection pool through an application program, and sending a first data access request to a server; the server is used for returning response information according to the first data access request;
calling an operating system monitoring function to monitor the response information;
and if the response information is monitored, calling the target connection through the application program to acquire and load the response information.
2. The data access method of claim 1, wherein the target connection is configured with a socket, the operating system snoop function is an epoll function, and the application is configured with a callback function; the calling an operating system monitoring function to monitor the response information, which comprises the following steps:
placing the target connection in a monitoring queue of the epoll function, and binding the target connection with the callback function;
and calling the epoll function to monitor the socket of the target connection.
3. The data access method of claim 2, wherein the target connection is configured with a send function and a receive function, and the sending of the first data access request to the server by the application calling the target connection from a preset connection pool comprises:
executing the sending function through the target connection, and sending the first data access request to the server;
correspondingly, the obtaining and loading the response information by calling the target connection through the application program includes:
and calling the target connection through the callback function to execute the receiving function, and receiving the response information.
4. The data access method of claim 1, wherein after the invoking operating system snoop function performs a snoop operation on the response information, further comprising:
and if the response information is not monitored, executing a first preset operation.
5. The data access method of claim 1, wherein after the invoking of the target connection from the predetermined connection pool by the application program and the sending of the first data access request to the server, further comprises:
receiving response information returned by the server;
if the response information is used for indicating that the server successfully receives the first data access request, executing a second preset operation;
if the response information is used for indicating that the server does not receive the first data access request, first prompt information is sent to the application program; the first prompt message is used for prompting that the first data access request fails to be sent.
6. The data access method of claim 1, wherein the invoking of the target connection by the application from the predetermined connection pool further comprises, prior to sending the first data access request to the server:
initializing the connection with preset number, and placing the connection after initialization in the preset connection pool.
7. The data access method of any of claims 1 to 6, wherein after the obtaining and loading the response information by the application invoking the target connection, further comprising:
and returning the target connection to the preset connection pool.
8. A data access device, comprising:
the first sending unit is used for calling a target connection from a preset connection pool through an application program and sending a first data access request to the server; the server is used for returning response information according to the first data access request;
the calling unit is used for calling an operating system monitoring function to monitor the response information;
and the acquisition unit is used for calling the target connection through the application program to acquire and load the response information if the response information is monitored.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the data access method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out a data access method according to any one of claims 1 to 7.
CN202011579612.2A 2020-12-28 2020-12-28 Data access method, data access device and computer readable storage medium Pending CN112818336A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011579612.2A CN112818336A (en) 2020-12-28 2020-12-28 Data access method, data access device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011579612.2A CN112818336A (en) 2020-12-28 2020-12-28 Data access method, data access device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN112818336A true CN112818336A (en) 2021-05-18

Family

ID=75854093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011579612.2A Pending CN112818336A (en) 2020-12-28 2020-12-28 Data access method, data access device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112818336A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113886099A (en) * 2021-08-27 2022-01-04 北京房江湖科技有限公司 Interface access request processing method and storage medium
CN113934591A (en) * 2021-09-27 2022-01-14 青岛海尔科技有限公司 Data monitoring method and device, storage medium and electronic device
CN115599563A (en) * 2022-11-29 2023-01-13 北京卡普拉科技有限公司(Cn) Parallel I/O control method, device and equipment for serial I/O access
CN116016660A (en) * 2022-12-30 2023-04-25 北京奇艺世纪科技有限公司 Data grabbing method, device, equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103560937A (en) * 2013-11-01 2014-02-05 北京蓝汛通信技术有限责任公司 Data accessing method and entry server
CN104901928A (en) * 2014-03-07 2015-09-09 中国移动通信集团浙江有限公司 Data interaction method, device and system
CN105471869A (en) * 2015-11-23 2016-04-06 珠海全志科技股份有限公司 Internet television content request connection reuse method and system thereof
CN105808638A (en) * 2016-02-23 2016-07-27 平安科技(深圳)有限公司 Data processing method and system
CN108600378A (en) * 2018-04-28 2018-09-28 武汉斗鱼网络科技有限公司 A kind of document down loading method, device, terminal and storage medium
CN109275359A (en) * 2017-05-18 2019-01-25 北京小米移动软件有限公司 Method, device, user equipment and base station for protecting user equipment
CN109660573A (en) * 2017-10-10 2019-04-19 北京京东尚科信息技术有限公司 Data transmission method and device
CN111245887A (en) * 2019-12-17 2020-06-05 航天信息股份有限公司 Hbase connection dynamic holding method, Hbase connection dynamic holding equipment, Hbase connection dynamic storage medium and Hbase connection dynamic storage system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103560937A (en) * 2013-11-01 2014-02-05 北京蓝汛通信技术有限责任公司 Data accessing method and entry server
CN104901928A (en) * 2014-03-07 2015-09-09 中国移动通信集团浙江有限公司 Data interaction method, device and system
CN105471869A (en) * 2015-11-23 2016-04-06 珠海全志科技股份有限公司 Internet television content request connection reuse method and system thereof
CN105808638A (en) * 2016-02-23 2016-07-27 平安科技(深圳)有限公司 Data processing method and system
CN109275359A (en) * 2017-05-18 2019-01-25 北京小米移动软件有限公司 Method, device, user equipment and base station for protecting user equipment
CN109660573A (en) * 2017-10-10 2019-04-19 北京京东尚科信息技术有限公司 Data transmission method and device
CN108600378A (en) * 2018-04-28 2018-09-28 武汉斗鱼网络科技有限公司 A kind of document down loading method, device, terminal and storage medium
CN111245887A (en) * 2019-12-17 2020-06-05 航天信息股份有限公司 Hbase connection dynamic holding method, Hbase connection dynamic holding equipment, Hbase connection dynamic storage medium and Hbase connection dynamic storage system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵一江: "多代理数据库事务连接池的研究", 《计算机工程与设计》, vol. 32, no. 6, 16 June 2011 (2011-06-16), pages 2031 - 2034 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113886099A (en) * 2021-08-27 2022-01-04 北京房江湖科技有限公司 Interface access request processing method and storage medium
CN113934591A (en) * 2021-09-27 2022-01-14 青岛海尔科技有限公司 Data monitoring method and device, storage medium and electronic device
CN115599563A (en) * 2022-11-29 2023-01-13 北京卡普拉科技有限公司(Cn) Parallel I/O control method, device and equipment for serial I/O access
CN115599563B (en) * 2022-11-29 2023-06-13 北京卡普拉科技有限公司 Parallel I/O control method, device and equipment for serial I/O access
CN116016660A (en) * 2022-12-30 2023-04-25 北京奇艺世纪科技有限公司 Data grabbing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111026367B (en) Micro-service arrangement method, device, terminal equipment and storage medium
CN112818336A (en) Data access method, data access device and computer readable storage medium
CN109922158A (en) Data processing method, device, medium and electronic equipment based on micro services
CN111163130B (en) Network service system and data transmission method thereof
CN112346794A (en) Interface calling method, device, device and medium
CN111277639A (en) Method and device for maintaining data consistency
CN105354142B (en) Middleware test method and device
CN110933075B (en) Service calling method and device, electronic equipment and storage medium
US20200053084A1 (en) Intelligent redirection of authentication devices
CN115237481A (en) Method, device and equipment for driving external equipment and storage medium
CN114979295A (en) Gateway management method and device
CN114386838B (en) Indicator configuration method, device, computer equipment and computer readable storage medium
CN113055250B (en) Networking communication method, device, terminal equipment and storage medium
CN114816684A (en) Business processing method, device, equipment, readable storage medium and product
CN112732547B (en) Service testing method and device, storage medium and electronic equipment
CN110730197A (en) Service discovery method and system
CN112202605A (en) Service configuration method, device, equipment and storage medium
CN111580987B (en) Remote procedure call method, device, storage medium and terminal device
CN114697888B (en) 5G message processing method, device and storage medium
CN113760693B (en) Method and device for local debugging of microservice system
CN110876852A (en) Network game data processing method and system of micro-service
CN115757263A (en) Method and device for realizing interaction between components, electronic equipment and storage medium
CN111061576A (en) A method and system for creating an entity object
CN116010126B (en) Service aggregation method, device and system
CN109284141B (en) Plug-in management system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210518

RJ01 Rejection of invention patent application after publication