Data enquire method and device
Technical field
The application relates to field of computer technology, particularly relates to a kind of data enquire method and device.
Background technology
Along with the develop rapidly of computer and network technologies, network access data scale increases increasingly.The mass data how process information explosion time generation produces, becomes problem demanding prompt solution.In traditional centralized data base system, application program is concentrated and is run on one computer, once this computing machine breaks down, then whole system is affected.In addition, centralized processing causes the scale of system and configures all underactions, and the expandability of system is poor.Visible, traditional centralized data base system cannot meet the application needs of large-scale data.
Distributed data base system grows up on the basis of centralized data base system, is the product that computer technology and network technology combine.Distributed data base is logically a unified entirety, is then be stored in respectively on different physical nodes physically.Application program by the connection of network can visiting distribution at the database of diverse location.The distributivity performance data in a database of distributed data base system are stored on the memory device of different computing machines, and user can be connected to by network and wherein any computing machine perform global application.The reliability of distributed data base system is high, and when in system, a certain computing machine breaks down, system can operate the identical copies on another computing machine, can not cause the paralysis of whole system because of place's fault.And distributed data base system can be selected to operate from the data trnascription that user is nearest according to distance, reduces communication cost, improves the performance of whole system.
But, distributed data base system in use, data in database are stored on the memory device of different computing machines, therefore application server is needed to be connected with multiple database, there is the problem of application server and database link number deficiency, causing user inefficiency or appearance exception when carrying out query manipulation.In prior art, database is split, or introduce memory cache, still can not solve the problem of data source link number deficiency.
Summary of the invention
The object of this invention is to provide a kind of data enquire method and device, to solve the problem of data source link number deficiency in large-scale distributed Database Systems.
First aspect, provides a kind of data enquire method, and described method comprises:
Data bus receives the data inquiry request that application server sends, and described inquiry request carries data query conditions information;
Described data bus inquires about the first corresponding data according to described querying condition information in memory cache;
If described data bus inquires described first data, then described first data are sent to described application server;
If described data bus does not inquire described first data, then described data inquiry request is sent to actuator, inquire about described first data for described actuator in a database according to described data query conditions information.
Second aspect, provides a kind of data query arrangement, and described device comprises:
Receiving element, receive the data inquiry request of application server transmission for data bus, described inquiry request carries data query conditions information;
First query unit, inquires about the first corresponding data for described data bus according to described querying condition information in memory cache;
Judging unit, for judging whether described data bus inquires described first data in memory cache.
Described first data for inquiring described first data when described data bus, are then sent to described application server by the first transmitting element;
Second transmitting element, for not inquiring described first data when described data bus, then sends to actuator by described data inquiry request;
Second query unit, inquires about described first data for described actuator in a database according to described data query conditions information.
The data enquire method that the application provides and device, by increasing the setting of data bus in distributed data base system, thus add distributed caching, through the forwarding of data bus, reduce the consumption of data source link number, improve the query performance of application server.
Accompanying drawing explanation
The data enquire method process flow diagram that Fig. 1 provides for the embodiment of the present application one;
Fig. 2 is single database mode profile formula Database Systems schematic diagram in prior art;
Fig. 3 is multiple database mode profile formula Database Systems schematic diagram in prior art;
Fig. 4 introduces distributed data base system schematic diagram after memory cache in prior art;
The distributed data base system schematic diagram that Fig. 5 provides for the embodiment of the present application one;
The data query arrangement schematic diagram that Fig. 6 provides for the embodiment of the present application two.
Embodiment
For making the object of the embodiment of the present application, technical scheme and advantage clearly, below in conjunction with the accompanying drawing in the embodiment of the present application, technical scheme in the embodiment of the present application is clearly and completely described, obviously, described embodiment is some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all belong to the scope of the application's protection.
The data enquire method that the embodiment of the present application provides and device, first application server sends data inquiry request to data bus, data bus is inquired about in memory cache according to querying condition information, if data bus does not inquire the Query Result meeting querying condition, then data inquiry request is sent to actuator, actuator is inquired about in a database according to data query conditions information.The present invention adds the setting of data bus in distributed data base system, through the forwarding of data bus, decreases the link number of application server and database, improves search efficiency.
Embodiment one
The data enquire method process flow diagram that Fig. 1 provides for the embodiment of the present application one.Described method specifically comprises:
Step 101, data bus receives the data inquiry request that application server sends, and described inquiry request carries data query conditions information.
The network environment that method in the present invention is run can be, but not limited to the distributed data base system under cloud computing environment.
In prior art distributed data base system, application server is directly connected with database, and single database mode profile formula Database Systems schematic diagram as shown in Figure 2.The link number of single database and the link of N platform application server is M × N.
In order to reduce link number, split database, database defines multiple database pattern database system after splitting, as shown in Figure 3.After single database splits into i database, total links total number of N platform application server and i database link is M × N × i, does not solve the problem of data source link number deficiency.
Even if introducing memory cache, because memory cache cannot send to application server feedback information, application server still needs to link with database, the links total number of N platform application server and i database link or M × N × i, the problem of data source link number deficiency can not be solved, as shown in Figure 4.
In order to solve the problem of data source link number deficiency, the present invention introduces data bus in distributed data base system, data bus in the present invention comprises memory cache and SQL (StructuredQueryLanguage, Structured Query Language (SQL)) actuator.Owing to introducing Q bar data bus, the links total number of N platform application server and i database link is Q × i (Q<M × N), decreases the consumption of database link number.As shown in Figure 5.
Described application server is upper-layer service system, for the treatment of the business that the demand of user is relevant.As, user accesses shopping website, and search meets the merchandise news etc. of certain condition.
Described data query conditions information is the condition of upper-layer service combination in any, as, user wants purchase price at the woollen overcoat of Ms's black of 1000 ~ 2000 yuans, search key can be " Ms "+" black "+" woollen cloth "+" overcoat "+" 1000 ~ 2000 yuan ", if want to expand hunting zone, can choose above partial key and carry out combination in any, the merchandise news so meeting above combination condition is searched to feeding back to user.
In the present embodiment, application server sends to described data bus by SQL the described data inquiry request carrying querying condition information.Data bus gathers the SQL query request of upper-layer service system, through the forwarding of described data bus, effectively can reduce the use of database link number.
Step 102, described data bus inquires about the first corresponding data according to described querying condition information in memory cache.
Be specially, described data bus accesses the query interface of described memory cache according to major key, and in described memory cache, inquiry meets the data of querying condition, and described first data are the data meeting querying condition.
Step 103, judges whether there are described first data in described memory cache.
Be specially, if described data bus inquires the data satisfied condition in memory cache, then continue to perform step 106, meeting the data feedback of querying condition to application server, using for upper-layer service system.Otherwise, perform step 104.
Step 104, described data bus does not inquire described first data, and described data inquiry request is sent to actuator.
If described data bus does not inquire the information meeting querying condition in memory cache, then described data inquiry request is sent to actuator, trigger actuator, continue to perform step 105.
Described actuator is SQL actuator, utilizes SOL to carry out query manipulation to database.
Step 105, described actuator inquires about described first data in a database according to described data query conditions information.
Be specially, described actuator is inquired about in a database according to described data query conditions Information Pull SQL.
Described database is mysql database, uses SQL accessing database.SQL actuator obtains inquiring about table name from inquiry request SQL, selects database, inquire about the data satisfied condition according to inquiry table name.
Described first data are sent to described application server by step 106.
If described data bus inquires the data satisfied condition in described memory cache, then described first data are sent to application server by data bus, meet upper-layer service system and use needs.
If described actuator inquires the data satisfied condition in a database, then the first data are sent to application server by actuator, meanwhile, are stored in memory cache by the data meeting described querying condition, upgrade buffer memory, are convenient to next user and search needs.
The data enquire method that the embodiment of the present application provides, first application server sends data inquiry request to data bus, data bus is inquired about in memory cache according to querying condition information, if data bus does not inquire the Query Result meeting querying condition, then data inquiry request is sent to actuator, actuator is inquired about in a database according to data query conditions information.The present invention adds the setting of data bus in distributed data base system, thus adds distributed caching, through the forwarding of data bus, reduces the consumption of data source link number, improves the query performance of application server.
Embodiment two
With above-mentioned data enquire method accordingly, a kind of data query arrangement that the embodiment of the present application also provides, the device schematic diagram that Fig. 3 provides for the embodiment of the present application two, this device comprises: receiving element 201, first query unit 202, judging unit 203, first transmitting element 204, second transmitting element 205, second query unit 206 and storage unit 207.
Described receiving element 201, receive the data inquiry request of application server transmission for data bus, described inquiry request carries data query conditions information.
Described first query unit 202, inquires about the first corresponding data for described data bus according to described querying condition information in memory cache.
Described judging unit 203, for judging whether described data bus inquires described first data in memory cache.
Described first data for inquiring described first data when described data bus, are then sent to described application server by described first transmitting element 204.
Described second transmitting element 205, for not inquiring described first data when described data bus, then sends to actuator by described data inquiry request.
Described second query unit 206, inquires about described first data for described actuator in a database according to described data query conditions information.
Described device also comprises storage unit 207, for described first data inquired are sent to described application server, and described first data is stored in described memory cache.
The device that the embodiment of the present application two provides implants the method that the embodiment of the present application one provides, and therefore, the specific works process of the device that the application provides, does not repeat again at this.
The data query arrangement that the embodiment of the present application provides, first application server sends data inquiry request to data bus, data bus is inquired about in memory cache according to querying condition information, if data bus does not inquire the Query Result meeting querying condition, then data inquiry request is sent to actuator, actuator is inquired about in a database according to data query conditions information.The present invention adds the setting of data bus in distributed data base system, thus adds distributed caching, through the forwarding of data bus, reduces the consumption of data source link number, improves the query performance of application server.
Professional should recognize further, in conjunction with object and the algorithm steps of each example of embodiment disclosed herein description, can realize with electronic hardware, computer software or the combination of the two, in order to the interchangeability of hardware and software is clearly described, generally describe composition and the step of each example in the above description according to function.These functions perform with hardware or software mode actually, depend on application-specific and the design constraint of technical scheme.Professional and technical personnel can use distinct methods to realize described function to each specifically should being used for, but this realization should not think the scope exceeding the application.
The software module that the method described in conjunction with embodiment disclosed herein or the step of algorithm can use hardware, processor to perform, or the combination of the two is implemented.Software module can be placed in the storage medium of other form any known in random access memory (RAM), internal memory, ROM (read-only memory) (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field.
Above-described embodiment; the object of the application, technical scheme and beneficial effect are further described; be understood that; the foregoing is only the embodiment of the application; and be not used in the protection domain limiting the application; within all spirit in the application and principle, any amendment made, equivalent replacement, improvement etc., within the protection domain that all should be included in the application.