A kind of shared drive data bank access method
Technical field
The present invention relates to a kind of shared drive data bank access method of avoiding process communication.
Background technology
Present visit to memory database; Generally all be to adopt the Socket communication mode; Be that application program is when needing the access memory database; Send solicited message through the Socket communication port to the memory database service processes; After the memory database service processes received the Socket request instruction, inquiry was perhaps revised internal storage data, then result is sent to application program through Socket again; Application program receives result, accomplishes once the visit to memory database.
When this Socket communication mode has seriously restricted and has disposed with main frame to the access efficiency of internal memory.As a rule, generally within several microseconds, and the speed of Socket communication is because the consumption of network I/O, the mutual wait of communicating pair etc., slow about 10 times than direct internal storage access of its interactive speed to the access speed of internal memory for process.Because the processing time major part expends in communication, " fast access of the internal memory " advantage of making can't obtain fully effectively performance.
Summary of the invention
Technical matters to be solved by this invention provides a kind of application program and avoids the method that the Socket communication mode directly conducts interviews to memory database, to improve the access speed of application program to memory database.
The technical scheme that the present invention solves the problems of the technologies described above is following: a kind of shared drive data bank access method comprises the steps:
Step 1: the memory database service processes is put into shared drive to internal storage data;
Step 2: client-side program sends the Socket connection request to said memory database service processes;
Step 3: the memory database service processes receives said connection request, and the internal memory ID of said shared drive is sent to said client-side program;
Step 4: after said client-side program receives said internal memory ID, the pairing shared drive of this internal memory ID is mapped to its oneself the process space;
Step 5: said client-side program is directly visited said shared drive, and the internal storage data in the shared drive is increased and/or deletes and/or change and/or look into operation;
Step 6: client-side program withdraws from, and the memory database service processes discharges and is connected with the Socket of client-side program.
Client-side program wherein is the types of applications program that needs the access memory database.
The invention has the beneficial effects as follows: the memory database service processes is with the shared drive ID Spoke-to-Client end program of memory database; Client-side program is mapped to the process space of oneself with it and then can directly conducts interviews to this shared drive; Thereby direct visit and operation have been realized to memory database; The time waste of having avoided each visit all must carry out Socket communication and having caused, the access time of having practiced thrift memory database.
On the basis of technique scheme, the present invention can also do following improvement.
Further, said client-side program and memory database service processes operate on the same main frame.
Adopt the beneficial effect of above-mentioned further scheme to be, when having solved client-side program and memory database service processes and having operated on the same main frame, the time waste problem of client-side program access memory database.
Further, in the step 3, the memory database service processes is accepted behind the said connection request client-side program to be carried out purview certification, and is authenticated through then the internal memory ID of said shared drive being sent to said client-side program; If authentication is not passed through, then do not send internal memory ID.
Adopt the beneficial effect of above-mentioned further scheme to be,, strengthened the shared drive safeness of Data Bank through purview certification.
Further, in step 4, when client-side program increases internal storage data and/or deletes and/or change and/or look into when operation, operation note in the interim affairs district that this Socket connects, and is locked to operation.
Further, in step 4, when client-side program to the increasing and/or delete and/or change and/or when looking into EO of internal storage data, will be in the interim affairs district should operation record deletion, and remove the lock of operation.
Adopt the beneficial effect of above-mentioned further scheme to be; Operation note can be known the operation note of current client-side program for the memory database service processes in the interim affairs district that this Socket connects, integrality and consistance that operation is locked and can guarantee data in the shared drive database.
Further; In step 4; When client-side program withdraws from unusually; The memory database service processes is inquired about interim affairs district; If in the interim affairs district uncompleted transaction journal is arranged and/or the lock that does not discharge is arranged, then proceed the subsequent operation of this connection according to the lock of uncompleted transaction journal and/or not release in the interim affairs district.
Adopt the beneficial effect of above-mentioned further scheme to be, avoid, guarantee that memory database data can not cause damage because of the unusual of client-side program because the fault of client-side program impacts to memory database.
Through memory database access method of the present invention, when application program (client-side program) and memory database are deployed on same the main frame, make application program can get around Socket communication, directly the data in the access memory database.Through the method, can significantly improve the efficient of the application access memory database of disposing with main frame, adapt to the high speed requirement that handle online Real-time Transaction in fields such as telecommunications, finance.
Description of drawings
Fig. 1 is the system architecture diagram of memory database access method of the present invention;
Fig. 2 is the process flow diagram of memory database access method of the present invention.
Embodiment
Below in conjunction with accompanying drawing principle of the present invention and characteristic are described, institute gives an actual example and only is used to explain the present invention, is not to be used to limit scope of the present invention.
As shown in Figure 1; Shared drive data bank access method of the present invention is applicable to that client-side program and memory database service processes run on same the main frame; Earlier setting up socket with the memory database service processes when client-side program will be visited the shared drive database in the shared drive district is connected; Through after the authentication; The memory database service processes sends to client-side program with the internal memory ID of shared drive; Client-side program is directly visited shared drive according to this internal memory ID; The shared drive database is increased and/or deletes and/or change and/or operation such as look into; Thereby all necessary trouble that connects through socket when having walked around, thereby accelerated time memory database operation at every turn to memory database operation.
The idiographic flow of memory database access method of the present invention as shown in Figure 2, comprises the steps:
Step 1: the memory database service processes is put into shared drive to internal storage data;
Step 2: client-side program sends the Socket connection request to said memory database service processes;
Step 3: the memory database service processes receives said connection request, and the internal memory ID of said shared drive is sent to said client-side program;
Step 4: after said client-side program receives said internal memory ID, the pairing shared drive of this internal memory ID is mapped to its oneself the process space;
Step 5: said client-side program is directly visited said shared drive, and the internal storage data in the shared drive is increased and/or deletes and/or change and/or look into operation;
Step 6: client-side program withdraws from, and the memory database service processes discharges and is connected with the Socket of client-side program.
Above-mentioned client-side program is the types of applications program that needs the access memory database.
Wherein, in the step 3, the memory database service processes is accepted behind the said connection request client-side program to be carried out purview certification, and is authenticated through then the internal memory ID of said shared drive being sent to said client-side program; If authentication is not passed through, then do not send internal memory ID.
In the step 4, when client-side program increases internal storage data and/or deletes and/or change and/or look into when operation, operation note in the interim affairs district that this Socket connects, and is locked to operation; When client-side program to the increasing and/or delete and/or change and/or when looking into EO of internal storage data, will be in the interim affairs district should operation record deletion, and remove the lock of operation, thereby guarantee the integrality and the consistance of data in the shared drive database.When client-side program withdraws from unusually; The memory database service processes is inquired about interim affairs district; If uncompleted transaction journal is arranged and/or the lock that does not discharge is arranged in the interim affairs district; Then proceed the subsequent operation of this connection according to the lock of uncompleted transaction journal and/or not release in the interim affairs district; To avoid fault owing to client-side program; Impact to memory database, guarantee that memory database data can not cause damage because of the unusual of client-side program.
With the ticketing system is example, and accounting routine (client-side program) and memory database are deployed on same the main frame, deposits the tariff package information that each phone number is ordered in the memory database.
Accounting routine is at first set up Socket with the memory database service processes and is connected; After authentication; Accounting routine obtains the shared drive ID that the memory database service processes sends over, and then this piece shared drive is mapped to the process space of oneself, accomplishes and lands preliminary work.
Next; Accounting routine is opened CDR file; Take out every ticket one by one, directly search the corresponding tariff package information of this number in the shared drive according to phone number then, combine the charging of every tickets of information completion such as air time, the other side's number of ticket.
When searching tariff package, accounting routine is directly visited shared drive, does not carry out Socket with the memory database process and communicates by letter, thereby make access efficiency significantly improve.
The present invention is being owing to increasing and/or deleting and/or change and/or look into the data in when operation direct control memory database, thereby increases substantially the access speed to memory database.On the main frame of CPU frequency 1.65GHz, from a table with 1,000 ten thousand records, according to record of search index, adopt the visit of Socket communication modes, average 60 microseconds consuming time; And adopt access method of the present invention, average only 7 microseconds consuming time.For the application scenarios of frequent access, the overall time of practicing thrift will be above more than 5 times.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.