Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are some of the embodiments of the present invention, instead of all the embodiments.Based on this hair
Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall within the protection scope of the present invention.
It should be appreciated that ought use in this specification and in the appended claims, term " includes " and "comprising" instruction
Described feature, entirety, step, operation, the presence of element and/or component, but one or more of the other feature, whole is not precluded
Body, step, operation, the presence or addition of element, component and/or its set.
It is also understood that mesh of the term used in this description of the invention merely for the sake of description specific embodiment
And be not intended to limit the present invention.As description of the invention and it is used in the attached claims, unless on
Other situations are hereafter clearly indicated, otherwise " one " of singular, "one" and "the" are intended to include plural form.
Fig. 1 and Fig. 2 are please referred to, Fig. 1 is a kind of application scenarios signal of data access method provided in an embodiment of the present invention
Figure, Fig. 2 are a kind of flow diagram of data access method provided in an embodiment of the present invention.The data access method is applied to clothes
It is engaged in device or terminal, wherein terminal can be smart phone, tablet computer, laptop, desktop computer, personal digital assistant
Electronic equipment with wearable device etc. with communication function.As an application, as shown in Figure 1, the data access method application
In server 10, which can execute described for a server in Distributed Services platform, the server 10
Interface access request is completed if executing interface access request, is fed back in terminal according to implementing result generated, specifically,
The server 10 can feed back the implementing result of interface access request in terminal 20 connected to it.
It should be noted that only illustrate a terminal 20 in Fig. 1, in the actual operation process, server 10 can be with
Implementing result is sent to more terminals 20.
Referring to Fig. 2, Fig. 2 is a kind of schematic flow diagram of data access method provided in an embodiment of the present invention.Such as Fig. 2 institute
Show, this approach includes the following steps S101~S106.
S101 configures blocker in presetting method.
In embodiments of the present invention, the presetting method can be config method, specifically, matching in config method
That sets blocker can be with are as follows: is added to blocker in the preset group of config method, more specifically, in config method
In, preset group can be by calling push method to add blocker, and following lattice can be used in preset group addition blocker
Formula: preset group .push (blocker).
Further, as shown in figure 3, the step S101 includes step S202~S204.
S202 determines the interceptors array in the presetting method.
In the present embodiment, the preset group of the presetting method is interceptors array.
S204 calls push method according to the interceptors array, and configures blocker in push method.
Specifically, interceptors array can add blocker by calling push method in config method,
Following format: interceptors.push (blocker) can be used in interceptors array addition blocker.
S102 carries out the interface access request using the blocker if receiving the interface access request of user
Pretreatment.
In embodiments of the present invention, the interface access request includes solicited message, which includes desired mesh
The interface name of tag splice mouth, it is described that the interface access request is pre-processed using the blocker, comprising: to be blocked using described
It cuts device and token is written in the interface access request, and the token being written is saved into local data base.Specifically, clothes
Business device end is received the interface using a variable using blocker and accessed when receiving the interface access request of user's transmission
It is written used variable as token into the interface access request while request, and by the variable save in server
In the local data base at end, it will unify to intercept when user's each transmission interface access request, and user is transmitted
Token in the local data base of token and server end compares, if the same grant access, otherwise denied access.
S103 parses the interface access request, and obtains the solicited message carried in the interface access request.
In embodiments of the present invention, the interface access request is TCP access request, and the solicited message includes that target connects
The interface name of mouth, the solicited message is for determining whether the local cache list is stored with corresponding to the solicited message
Information.Specifically, different solicited messages corresponds to different interfaces, different solicited messages, requested interface data is not yet
Together.For example, the entitled session1 of the interface of solicited message, that is with regard to the session1 interface in corresponding server end.More specifically,
Server end can parse interface access request, and obtain the interface for being directed to target interface in request token analytically
Name, wherein institute received interface access request can be user terminal transmission request, be also possible to other server ends send
Request, herein with no restriction to the object of the transmission interface access request.
S104 searches whether that there are the solicited messages from local cache list.
In embodiments of the present invention, it is cached with history interface data in the local cache list, the data cached
Interface name and interface parameters comprising corresponding interface obtain interface name by parsing the interface access request, by the interface
Name is compared with the history interface data cached in the local cache list of server end, if interface name and sheet in request
The interface name cached in ground cache list corresponds, and judges that there are the solicited messages in the local cache list.
Further, as shown in figure 4, the step S104 includes step S302~S304.
S302, by the interface name cached in the interface name carried in the interface access request and local cache list into
Row compares.
S304, if the interface name carried in the interface access request and the interface name one cached in local cache list
One is corresponding, determines that there are the solicited messages in the local cache list.
S105, if executing the interface access request and from institute there are the solicited message in the local cache list
It states and obtains corresponding interface data in local cache list;Otherwise, S106 is executed.
S106 executes the interface access request to issue corresponding interface data, and will be described using the blocker
Interface data is cached into local cache column.
As seen from the above, the embodiment of the present invention in presetting method by configuring blocker;If receiving the interface of user
Access request pre-processes the interface access request using the blocker;The interface access request is parsed, and is obtained
Take the solicited message carried in the interface access request;Search whether that there are the solicited messages from local cache list;
If executing the interface access request and from the local cache list there are the solicited message in the local cache list
It is middle to obtain corresponding interface data;Otherwise, the interface access request is executed to issue corresponding interface data, and described in utilization
Blocker caches the interface data into local cache column.The present invention is based on data processings, can be improved number of ports
According to access efficiency, reduce the wasting of resources, improve the usage experience of user.
Referring to Fig. 5, a kind of corresponding above-mentioned data access method, the embodiment of the present invention also proposes a kind of data access dress
It sets, which includes: configuration unit 101, pretreatment unit 102, resolution unit 103, searching unit 104, execution unit
105。
Wherein, the configuration unit 101, for configuring blocker in presetting method.In embodiments of the present invention, described
Presetting method can be config method, specifically, configure blocker in config method can be with are as follows: add blocker
Into the preset group of config method, more specifically, in config method, preset group can be by calling push method
Blocker is added, following format: preset group .push (blocker) can be used in preset group addition blocker.
Pretreatment unit 102, if the interface access request for receiving user, using the blocker to the interface
Access request is pre-processed.In embodiments of the present invention, the interface access request includes solicited message, the request packet
Interface name containing desired target interface, it is described that the interface access request is pre-processed using the blocker, comprising:
Token is written in the interface access request using the blocker, and the token being written is saved to local data base
In.Specifically, server end is connect using blocker using a variable when receiving the interface access request of user's transmission
It is written used variable as token into the interface access request while receiving the interface access request, and by the variable
It is stored in the local data base of server end, will unify to intercept when user's each transmission interface access request, and
Token in the local data base of the token of user's transmitting and server end is compared, if the same grant access, no
Then denied access.
Resolution unit 103 for parsing the interface access request, and obtains asking of carrying in the interface access request
Seek information.In embodiments of the present invention, the interface access request is TCP access request, and the solicited message includes that target connects
The interface name of mouth, the solicited message is for determining whether the local cache list is stored with corresponding to the solicited message
Information.Specifically, different solicited messages corresponds to different interfaces, different solicited messages, requested interface data is not yet
Together.For example, the entitled session1 of the interface of solicited message, that is with regard to the session1 interface in corresponding server end.More specifically,
Server end can parse interface access request, and obtain the interface for being directed to target interface in request token analytically
Name, wherein institute received interface access request can be user terminal transmission request, be also possible to other server ends send
Request, herein with no restriction to the object of the transmission interface access request.
Searching unit 104, for searching whether that there are the solicited messages from local cache list.Implement in the present invention
In example, it is cached with history interface data in the local cache list, the data cached include the interface name of corresponding interface
And interface parameters, interface name is obtained by parsing the interface access request, the local of the interface name and server end is delayed
The history interface data cached in list is deposited to be compared, if cached in the interface name and local cache list in request
Interface name corresponds, and judges that there are the solicited messages in the local cache list.
Execution unit 105, if executing the interface access for there are the solicited messages in the local cache list
It requests and obtains corresponding interface data from the local cache list;Otherwise, the interface access request is executed to issue
Corresponding interface data, and cached the interface data into local cache column using the blocker.
As seen from the above, the embodiment of the present invention in presetting method by configuring blocker;If receiving the interface of user
Access request pre-processes the interface access request using the blocker;The interface access request is parsed, and is obtained
Take the solicited message carried in the interface access request;Search whether that there are the solicited messages from local cache list;
If executing the interface access request and from the local cache list there are the solicited message in the local cache list
It is middle to obtain corresponding interface data;Otherwise, the interface access request is executed to issue corresponding interface data, and described in utilization
Blocker caches the interface data into local cache column.The present invention is based on data processings, can be improved number of ports
According to access efficiency, reduce the wasting of resources, improve the usage experience of user.
Referring to Fig. 6, the configuration unit 101, comprising:
Determination unit 101a, for determining the interceptors array in the presetting method.In the present embodiment, institute
The preset group for stating presetting method is interceptors array.
Subelement 101b is configured, for calling push method according to the interceptors array, and in push method
Middle configuration blocker.Specifically, interceptors array can be by calling the addition of push method to block in config method
Device is cut, following format: interceptors.push (blocker) can be used in interceptors array addition blocker.
Referring to Fig. 7, the searching unit 104, comprising:
Comparing unit 104a, for will delay in the interface name carried in the interface access request and local cache list
The interface name deposited is compared.
Judging unit 104b, if delaying in interface name for being carried in the interface access request and local cache list
The interface name deposited corresponds, and determines that there are the solicited messages in the local cache list.
Above-mentioned data access device and above-mentioned data access method one-to-one correspondence, specific principle and process and above-mentioned reality
It is identical to apply the method, repeats no more.
Above-mentioned data access device can be implemented as a kind of form of computer program, and computer program can be in such as Fig. 8
Shown in run in computer equipment.
Fig. 8 is a kind of structure composition schematic diagram of computer equipment of the present invention.The equipment can be terminal, be also possible to take
Business device, wherein terminal can be smart phone, tablet computer, laptop, desktop computer, personal digital assistant and wearing
Formula device etc. has the electronic device of communication function.Server can be independent server, be also possible to multiple server groups
At server cluster.Referring to Fig. 8, the computer equipment 500 include the processor 502 connected by system bus 501, it is non-easily
The property lost storage medium 503, built-in storage 504 and network interface 505.Wherein, the non-volatile memories of the computer equipment 500 are situated between
Matter 503 can storage program area 5031 and computer program 5032, which is performed, and may make processor
502 execute a kind of data access method.The processor 502 of the computer equipment 500 is for providing calculating and control ability, support
The operation of entire computer equipment 500.The built-in storage 504 is the computer program 5032 in non-volatile memory medium 503
Operation provide environment, when which is executed by processor, processor 502 may make to execute a kind of data access side
Method.The network interface 505 of computer equipment 500 such as sends the task dispatching of distribution for carrying out network communication.Those skilled in the art
Member is appreciated that structure shown in Fig. 8, only the block diagram of part-structure relevant to application scheme, composition pair
The restriction for the computer equipment that application scheme is applied thereon, specific computer equipment may include than as shown in the figure more
More or less component perhaps combines certain components or with different component layouts.
Wherein, following operation is realized when the processor 502 executes the computer program:
Blocker is configured in presetting method;
If receiving the interface access request of user, the interface access request is located in advance using the blocker
Reason;
The interface access request is parsed, and obtains the solicited message carried in the interface access request;
Search whether that there are the solicited messages from local cache list;
If executing the interface access request and from the local there are the solicited message in the local cache list
Corresponding interface data is obtained in cache list;Otherwise, the interface access request is executed to issue corresponding interface data, and
The interface data is cached into local cache column using the blocker.
It is in one embodiment, described that blocker is configured in presetting method, comprising:
Determine the interceptors array in the presetting method;
Push method is called according to the interceptors array, and configures blocker in push method.
It is in one embodiment, described that the interface access request is pre-processed using the blocker, comprising:
Token is written in the interface access request using the blocker, and the token being written is saved to local
In database.
In one embodiment, the solicited message includes the interface name of target interface, described from local cache list
Search whether that there are the solicited messages, comprising:
The interface name cached in the interface name carried in the interface access request and local cache list is compared
Compared with;
If the interface name carried in the interface access request and the interface name cached in local cache list one are a pair of
It answers, determines that there are the solicited messages in the local cache list.
In one embodiment, the interface access request is TCP access request, and the solicited message includes target interface
Interface name, the solicited message is for determining whether the local cache list is stored with the letter corresponding to the solicited message
Breath.
It will be understood by those skilled in the art that the embodiment of computer equipment shown in Fig. 8 is not constituted to computer
The restriction of equipment specific composition, in other embodiments, computer equipment may include components more more or fewer than diagram, or
Person combines certain components or different component layouts.For example, in some embodiments, computer equipment only includes memory
And processor, in such embodiments, the structure and function of memory and processor are consistent with embodiment illustrated in fig. 8, herein
It repeats no more.
The present invention provides a kind of computer readable storage medium, computer-readable recording medium storage has one or one
A above computer program, the one or more computer program can be held by one or more than one processor
Row, to perform the steps of
Blocker is configured in presetting method;
If receiving the interface access request of user, the interface access request is located in advance using the blocker
Reason;
The interface access request is parsed, and obtains the solicited message carried in the interface access request;
Search whether that there are the solicited messages from local cache list;
If executing the interface access request and from the local there are the solicited message in the local cache list
Corresponding interface data is obtained in cache list;Otherwise, the interface access request is executed to issue corresponding interface data, and
The interface data is cached into local cache column using the blocker.
It is in one embodiment, described that blocker is configured in presetting method, comprising:
Determine the interceptors array in the presetting method;
Push method is called according to the interceptors array, and configures blocker in push method.
It is in one embodiment, described that the interface access request is pre-processed using the blocker, comprising:
Token is written in the interface access request using the blocker, and the token being written is saved to local
In database.
In one embodiment, the solicited message includes the interface name of target interface, described from local cache list
Search whether that there are the solicited messages, comprising:
The interface name cached in the interface name carried in the interface access request and local cache list is compared
Compared with;
If the interface name carried in the interface access request and the interface name cached in local cache list one are a pair of
It answers, determines that there are the solicited messages in the local cache list.
In one embodiment, the interface access request is TCP access request, and the solicited message includes target interface
Interface name, the solicited message is for determining whether the local cache list is stored with the letter corresponding to the solicited message
Breath.
Present invention storage medium above-mentioned include: magnetic disk, CD, read-only memory (Read-Only Memory,
The various media that can store program code such as ROM).
Unit in all embodiments of the invention can pass through universal integrated circuit, such as CPU (Central
Processing Unit, central processing unit), or pass through ASIC (Application Specific Integrated
Circuit, specific integrated circuit) Lai Shixian.
Step in data access method of the embodiment of the present invention can according to actual needs the adjustment of carry out sequence, merge and delete
Subtract.
Unit in data access device of the embodiment of the present invention can be combined, divided and deleted according to actual needs.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can readily occur in various equivalent modifications or replace
It changes, these modifications or substitutions should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with right
It is required that protection scope subject to.