Specific embodiment
In order to make those skilled in the art more fully understand the technical solution in this specification one or more, below will
In conjunction with the attached drawing in this specification one or more embodiment, to the technical solution in this specification one or more embodiment into
Row clearly and completely describes, it is clear that and described embodiment is only this specification one or more a part of the embodiment, and
The embodiment being not all of.Based on the embodiment in this specification one or more, those of ordinary skill in the art are not making
The model of this specification one or more protection all should belong in every other embodiment obtained under the premise of creative work out
It encloses.
This specification one or more embodiment provides a kind of db transaction processing method and processing device, in database thing
In implementation procedure of being engaged in, the data cached identification information that the db transaction is related to is recorded, so that db transaction is submitted or is returned
After rolling, be automatically deleted for the db transaction record data cached identification information it is corresponding data cached, in this way
When need to inquire the identification information it is corresponding data cached when, will be obtained from database automatically the deposit of corresponding target data this
In ground caching, it can guarantee that database is consistent with the data in local cache, is avoided the occurrence of because of database and local in this way
Data are inconsistent in caching causes follow-up data operation the problem of mistake occur.
Fig. 1 is the first process signal for the db transaction processing method that this specification one or more embodiment provides
Figure, as shown in Figure 1, this method at least includes the following steps:
S101, in the service code operation for target database affairs, acquisition target database affairs are related to slow
Deposit data mark, wherein after target database affairs are opened, the service code of the automatic running target database affairs, the industry
Business code is included: the bytecode obtained based on compilation of source code and is patrolled using the target that dynamic proxy technology is woven into the bytecode
Code is collected, which can be the dynamic generation during bytecode compiling, be also possible to move during bytecode is run
What state generated;
Specifically, operation is directed to the service code of target database affairs, i.e., the business datum in target database is held
The relevant preset data operation of row db transaction can be for example, operating for a certain db transaction to target database
In business datum execute a series of data additions and deletions and change and look into operation, if the business datum in operated target database is delayed
It deposits, it is determined that the operated business datum corresponding caching key when performance objective db transaction;
S102, the data cached mark that storage is got for target database affairs, specifically, to the caching got
Data Identification carries out storage processing, data cached mark can be stored in designated storage location;
Wherein, it is contemplated that thread context is a container being bound in java thread, and java thread is for number
According to the creation of library affairs, the corresponding different java thread of different db transactions, i.e. thread context and db transaction
With certain corresponding relationship, therefore, in order to ensure for a certain db transaction delete it is corresponding data cached when, Neng Gouzhun
Really it is read as the data cached mark of db transaction record, it is preferable that by what is got for target database affairs
In data cached mark write-in thread context, i.e., by performance objective db transaction when operated database in business number
According in corresponding caching key write-in thread context;
S103 deletes the caching number got for target database affairs if target database affairs execute completion
It is corresponding data cached according to identifying, wherein target database affairs, which execute, to be completed to include: that affairs submit completion or database
Data rewind is completed, and affairs submit the volume of data operation for completing characterization target database affairs to be completely executed completion, number
It is not executed fully according to the volume of data operation that library data rewind completes characterization target database affairs.
In this specification one or more embodiment, in db transaction implementation procedure, records the db transaction and relate to
And data cached identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction remember
The data cached identification information of record is corresponding data cached, in this way when needing to inquire the corresponding caching number of the identification information
According to when, will can guarantee database and this so automatically from being obtained in corresponding target data deposit local cache in database
Data in ground caching are consistent, avoid the occurrence of because database with data in local cache are inconsistent that follow-up data is caused to operate
There is the problem of mistake.
Further, due to needing in db transaction implementation procedure, increase about record buffer memory Data Identification and
Data cached processing logic is deleted, therefore, it is necessary to the source codes based on db transaction to generate comprising newly-increased processing logic generation
The service code of code, and in order to guarantee that newly-increased processing logical code without intrusion, is woven by source code using dynamic proxy technology
Required service code is obtained in bytecode, it is corresponding, as shown in Fig. 2, above-mentioned S101 obtains what target database affairs were related to
Before data cached mark, further includes:
S104 is woven into target logic code and obtains using dynamic proxy technology in the bytecode of target database affairs
The service code of target database affairs, wherein the target logic code includes: to patrol for realizing the first of interception caching
Collect code and for realizing the second logical code for intercepting affairs submission or rollback;
Wherein, above-mentioned bytecode refers to that the source code to target database affairs was compiled patrols not comprising target
The original .class file of code is collected, above-mentioned service code refers to adds target logic using dynamic proxy technology in bytecode
Purpose .class file after code;Above-mentioned first logical code includes the class function for record buffer memory Data Identification, above-mentioned
Second logical code includes for deleting data cached class function;
Wherein, above-mentioned dynamic proxy technology refers to, one of java language design pattern, may be implemented with number of targets
According in the relevant bytecode of the source code of library affairs specified interface or method call before and after execute one section of target logic code, with
Just it realizes and newly-increased service logic is added in bytecode, so that the real service code now for target database affairs is transported
It automatically determines and is stored after the completion of operated at least one caching key and target database affairs are executed during row and deleted
Except this, at least one caching key is corresponding data cached, wherein dynamic proxy can allow system that can move according to actual needs
State creates proxy class, allows the same proxy class that can act on behalf of multiple and different true theme class and can act on behalf of different sides
Method;
Specifically, during bytecode compiling or during operation, being blocked using dynamic proxy technology in target database affairs
The specified interface or method of caching in bytecode are cut, i.e., for operating the class function of caching in perception bytecode, by first
Logical code is inserted into bytecode before the specified interface of caching or method, specifically, utilizing dynamic proxy Sense of Technology
Know the class function for being used for caching in bytecode, the class function for being used for record buffer memory Data Identification is added in bytecode and is used
Before the class function of operation caching;
And using the specified interface or method of affairs submission or rolling back action in dynamic proxy technical intercept bytecode, i.e.,
The class function in bytecode for affairs submission or rolling back action is perceived, the second logical code is inserted into affairs in bytecode and is mentioned
After the specified interface or method of friendship or rolling back action, specifically, using affairs are used in dynamic proxy technology perception bytecode
Submit or rolling back action class function, will be used to delete data cached class function be added in bytecode be used for affairs submit or
After the class function of rolling back action;
It wherein, can be with for the process being added to target logic code in the bytecode obtained based on compilation of source code
Target logic code is added during compilation of source code is bytecode, can also be added during bytecode is run target logic generation
Code generates the new bytecode for being added with target logic code, using the new bytecode as the business of target database affairs
Code, the generating process of the service code specifically:
(1) for target logic code is added during compilation of source code is bytecode the case where, corresponding, above-mentioned S104
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains target database affairs
Service code, specifically include:
When the source code to target database affairs is compiled to obtain bytecode, using dynamic proxy technology in the word
It saves and adds target logic code in code, obtain the service code of target database affairs.
(2) for target logic code is added during bytecode operation the case where, corresponding, above-mentioned S104 utilizes dynamic
Agent skill group is woven into target logic code and obtains the business generation of target database affairs in the bytecode of target database affairs
Code, specifically includes:
The source code of target database affairs is compiled, the bytecode of target database affairs is obtained;
In the bytecode of operational objective db transaction, target is added in the bytecode using dynamic proxy technology and is patrolled
Code is collected, the service code of target database affairs is obtained.
In this specification one or more embodiment, target logic either is added during compilation of source code is bytecode
Code obtains service code, or adds target logic code during bytecode operation and obtain service code, is all made of dynamic
Agent skill group is woven into the first logic before or after being used to operate the class function of caching in the bytecode of target database affairs
Code, and in the bytecode of target database affairs submitted for affairs or the class function of rolling back action after be woven into the
Two logical codes can guarantee that the service logic of source code is constant, shields technical detail in this way, have source code without intrusion
Property, without user's manual modification and source code is write, improves the weaving efficiency of target logic code.
Wherein, for the collection process of data cached mark, above-mentioned S101 obtains the caching that target database affairs are related to
Data Identification specifically includes:
If detecting the first logical code in operational objective logical code, intercept adjacent with first logical code
For operate caching class function, i.e., perception target database affairs involved in database manipulation it is corresponding be used for operate it is slow
The class function deposited;
Wherein, for service code generating process, if for being inserted into before operating the class function cached in bytecode
First logical code then intercepts use adjacent with first logical code and positioned at first logical code after adjacent
In the class function of operation caching;If being inserted into first logical code after the class function for operating caching in bytecode,
Then intercept the class adjacent with first logical code and positioned at first logical code before adjacent for being used to operate caching
Function;
It determines the data cached mark for including in the class function for operating caching intercepted, is used for specifically, extracting
Operate the value of the parameter for characterizing caching key in the class function of caching;
The data cached mark that the data cached mark determined is related to as target database affairs.
Specifically, since most caching technologies do not support affairs, if operating database and caching simultaneously in affairs, in height
It may cause caching in the case where concurrent and the data for being directed to same Data Identification in database be inconsistent, for example, working as database
There is exception in the process of implementation in affairs, need to carry out data rewind, at this time the data rewind in database, but the number in caching
According to non-rollback, corresponding data of a certain Data Identification in database is caused to become data before changing, and the data in caching
Identifying corresponding data is still changed data;
By taking consumed transaction as an example, the account balance that stores is 100 in database and caching before db transaction starting
Member about the payment application amount of money is 10 yuan of db transaction for one, the data stored in database be account balance by
100 yuan become 90 yuan, at this time if needing to carry out data rewind because going wrong in db transaction implementation procedure, count at this time
The non-rollback of data according to the data rewind in library, but in caching, causes account balance in database to roll back to 100 yuan, but cache
Middle account balance is still 90 yuan, and when user being caused to inquire account balance again, the miscue that display account balance is 90 yuan is believed
Breath.
For another example, before the submission of target database affairs, the corresponding data of a certain Data Identification are deleted in caching, due to
Db transaction does not complete, and the corresponding data of the database Data Identification are still data before changing, if other threads at this time
The corresponding data of the Data Identification are inquired in request, then the data in database before changing are loaded into caching automatically, but when number
After submitting according to library affairs, the corresponding data of the Data Identification become changed data in database, and the data in caching
Identify corresponding data still and be data before changing;
By taking refund transaction as an example, the account balance that stores is 100 in database and caching before db transaction starting
Member about the reimbursement application amount of money is 50 yuan of db transaction for one, if the user in db transaction implementation procedure
Request inquiry account balance, since db transaction does not complete, the account balance stored in database is still 100 yuan, this hour hand
Account balance is automatically in 100 deposit cachings, still, when db transaction mentions by the request to the inquiry account balance, system
After friendship, the account balance stored in database becomes 150 yuan (containing 50 yuan of refund amounts), and the account balance stored in caching
It is still 100 yuan;However, will be prompted to user's reimbursement success, but the account stored in caching at this time after db transaction submission
Remaining sum is still 100 yuan, when user being caused to inquire account balance again, shows that account balance is 100 yuan of miscue information.
Therefore, in order to guarantee that caching is consistent with the data in database, the byte in target database affairs is needed
Target logic code is added in code, realization records in target database affairs implementation procedure is grasped in the target database affairs
The Data Identification of work, the Data Identification is corresponding data cached in deletion local cache after the completion of target database affairs, this
Sample when need to inquire the Data Identification it is corresponding data cached when, the newest Data Identification pair will be obtained from database automatically
In the data deposit local cache answered;
Wherein, in a certain db transaction implementation procedure, it may relate to the business number in multiple pairs of target database
According to data additions and deletions change and look into operation, if the business datum in operated target database has been buffered, it needs to be determined that in data
It is operated in the affairs implementation procedure of library to cache corresponding all caching key;Specifically, using dynamic proxy technology, in number of targets
The first logical code is added before all class functions for operating caching in bytecode according to library affairs, to be somebody's turn to do in operation
When the first logical code, record all for operating the corresponding caching key of class function of caching.
Wherein, it is carried out by taking the trading template Transaction Template of spring frame and buffer service tair as an example
Illustrate, using dynamic proxy technology, the first logical code is woven into the bytecode of target database affairs, realizes that interception is used for
The interface class of tair buffer service is operated, for example, intercepting refreshable common tair cache manager Refreshable Common
Tair Cache Manager example;
Specifically, intercepting Refreshable Common Tair Cache Manager example using dynamic proxy technology
In put Object, the relevant method such as incr, decr, i.e., any method comprising buffer update operation, e.g., put
Object With Expire, put Object, put Object Modify Date etc..
Wherein, due to being stored in the variable of the thread context bound in java thread, the information is accessed in different time
Identical value can be obtained, and thread context and db transaction have certain corresponding relationship, can will be directed to so not
Therefore data cached mark is stored in corresponding thread or more by the data cached mark isolation of same db transaction storage
Wen Zhong is directed to target database affairs to be accurately read out from the thread context when deletion of further cache data
The data cached mark of record is completed to read so that it is guaranteed that the data cached mark stored in affairs implementation procedure and affairs execute
Data cached mark it is identical, and then improve the accuracy of data cached deletion, it is ensured that accurate for a certain db transaction
Ground deletion is corresponding data cached, is based on this, as shown in figure 3, what above-mentioned S102 storage was got for target database affairs
Data cached mark, specifically includes:
S1021, the data cached mark deposit that target database affairs are related to are corresponding with the target database affairs
In thread context, specifically, the corresponding caching key of the caching is stored in thread by triggering before caching execution
In context.
Specifically, the storing process of data cached mark is directed to, since data cached mark can be from for operating caching
Class function in extract, it is corresponding, corresponding subject thread can be determined according to the class function, further according to subject thread determine
Corresponding thread context, so that the data cached mark is stored in thread bound in the corresponding subject thread of the class function
In context, specifically, the deposit of data cached mark and the target database that target database affairs are related to by above-mentioned S1021
In the corresponding thread context of affairs, specifically include:
Determine subject thread corresponding with the class function for operating caching intercepted, wherein thread is to execute code most
Junior unit, each class function both correspond to a thread, on the thread that the code about class function is bound on respective thread
Hereinafter execute;
In the thread context that the data cached mark determined write-in is bound in above-mentioned subject thread, specifically,
In the thread context that data cached mark deposit is used to operate in the corresponding subject thread of class function of caching, in this way
When subsequent data cached for the deletion of target database affairs, directly from all about of execution target database affairs operation
Reading cache data mark in the thread context bound on thread for operating the code of the class function of caching.
Specifically, defining a static thread local variable ThreadLocal variable, ThreadLocal refers to java
For operating a class of thread context in thread, can use ThreadLocal will cache key deposit caching correspondence
Thread on Thread Local variable in bound thread context;For the class for being used to operate caching in bytecode
This is used to operate by the case where being inserted into first logical code before function before the class function for operating caching executes
The value of the parameter for characterizing caching key in the class function of caching is stored in Thread Local variable, wherein each line
It is thread isolation that journey, which reads and writes data into corresponding ThreadLocal, mutually isolated between multithreading, be independent of each other.
Wherein, for the corresponding data cached process of the data cached mark of deletion, it is contemplated that there may be multiple data
The case where library affairs execute parallel, therefore, for being completed, affairs are submitted or the db transaction of rollback executes data cached delete
Except the process of operation, need to guarantee the data cached corresponding caching of caching key to store for the db transaction deleted
It is data cached to be necessary to ensure that affairs execution is completed to store in the data cached mark and the affairs implementation procedure that read for data
It identifies identical, avoids the occurrence of and accidentally delete or the wrong corresponding data cached problem of caching key for deleting the storage of other db transactions, have
Body, the data cached mark that above-mentioned S103 deletion is got for target database affairs is corresponding data cached, specific to wrap
It includes:
If detecting the second logical code in operational objective logical code, intercept adjacent with second logical code
For operate affairs submit or rollback class function, i.e., in perception service code operate affairs submit or rollback class function;
Determine the db transaction mark for including in the class function for operating affairs submission or rollback intercepted, specifically
, extract the value of the parameter for characterizing Transaction Identifier in the class function for operating affairs submission or rollback;
For each data cached mark corresponding with the db transaction mark determined, searched in local cache with
The data cached mark is corresponding data cached, wherein each data cached mark be from the db transaction mark determined
Know what reading in the thread context bound in corresponding multiple subject threads obtained;
Specifically, the thread context bound on identifying corresponding multiple subject threads with the db transaction determined
Middle reading cache data mark;Searched in local cache it is corresponding data cached with each data cached mark read, i.e.,
In local cache, the corresponding data cached value of each caching key for being directed to target database transaction journal is searched
Value;
Deletion is found corresponding data cached with data cached mark from local cache, and deletes thread or more
The data cached mark stored in text, wherein the thread context is corresponding multiple with the db transaction mark determined
The thread context bound in subject thread;
Specifically, be woven into the second logical code in the bytecode of target database affairs using dynamic proxy technology, it is real
Transaction operation template class is now intercepted, after perception operation affairs submission or rollback, triggering is deleted slow with storage in local cache
Deposit data mark is corresponding data cached, and the data cached mark stored in thread context is deleted in triggering, i.e., by data
The operated corresponding data cached deletion of caching key, can eliminate in this way since high concurrent causes in the affairs implementation procedure of library
Local cache in the corresponding value of caching key and cache that key is corresponding to be worth inconsistent hidden danger in database.
Wherein, still by taking the trading template Transaction Template of spring frame and buffer service tair as an example into
Second logical code is woven into the bytecode of target database affairs by row explanation using dynamic proxy technology, is realized and is intercepted
Transaction operation template class in spring frame, for example, intercepting trading template Transaction Template example;
Specifically, intercepting execute in Transaction Template example using dynamic proxy technology and (submitting thing
Business) method, using try...finnally block, calling execute method will be in service code in finnally in try
The caching key stored in the Thread Local variable in the corresponding thread context of class function for operating caching is corresponding
Data cached deletion, and remove the caching key in Thread Local variable.
As shown in figure 4, in a specific embodiment, giving db transaction processing method is realization principle signal
Figure, specifically includes:
S40 opens target database affairs, after affairs unlatching, the business generation of the automatic running target database affairs
Code, wherein the service code is included: the bytecode obtained based on compilation of source code and is woven into the byte using dynamic proxy technology
Target logic code in code, the target logic code include: for realizing the first logical code and use of caching is intercepted
In the second logical code for realizing the submission of interception affairs or rollback
Specifically, above-mentioned service code can be the dynamic generation during bytecode compiling, it is also possible in bytecode
Dynamic generation during operation;
S41 executes the database manipulation for including in service code, looks into for example, carrying out additions and deletions to the data in database and changing
Operation;
S42 obtains the corresponding caching key of the caching if detecting the first logical code in operation service code,
And caching key is stored into corresponding thread context;
S43 executes the caching for including in service code, wherein the data that database manipulation is directed in S41 use
Caching, therefore, it is necessary to execute corresponding operation to data corresponding in caching, for example, being updated, inserting to the data in caching
The operation such as enter;
S44, affairs are submitted or rollback, wherein may include multiple S41, S42, S43, i.e. database between S43 and S44
In affairs implementation procedure, multiple database manipulation and caching may be executed, it is corresponding, it will acquire for db transaction
Multiple caching key, key will be cached respectively and stored into the thread context bound on corresponding thread;
S45 will be stored in caching with the online text of thread if detecting second logical code in operation service code
The corresponding data cached deletion of key is cached, and removes the caching key in thread context.
Db transaction processing method in this specification one or more embodiment, in the business of target database affairs
When code is run, the data cached mark that target database affairs are related to is obtained;The caching that storage target database affairs are related to
Data Identification;If target database affairs execute completion, the data cached mark for deleting storage is corresponding data cached.This theory
In bright book one or more embodiment, in db transaction implementation procedure, record the db transaction be related to it is data cached
Identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction record it is data cached
Identification information it is corresponding data cached, in this way when need to inquire the identification information it is corresponding data cached when, will be automatic
From being obtained in corresponding target data deposit local cache in database, it can guarantee the number in database and local cache in this way
According to being consistent, avoid the occurrence of causes follow-up data operation asking for mistake occur because database and data in local cache are inconsistent
Topic.
The db transaction processing method of corresponding above-mentioned Fig. 1 to Fig. 4 description, based on the same technical idea, this specification
One or more embodiments additionally provide a kind of db transaction processing unit, and Fig. 5 is this specification one or more embodiment
The module composition schematic diagram of the db transaction processing unit of offer, the device are used to execute the database thing of Fig. 1 to Fig. 4 description
Business processing method, as shown in figure 5, the device includes:
Cashing indication obtains module 501, for obtaining the target in the service code operation of target database affairs
The data cached mark that db transaction is related to;
Cashing indication memory module 502, the data cached mark being related to for storing the target database affairs;
Data cached removing module 503 deletes the caching number if executing completion for the target database affairs
It is corresponding data cached according to identifying.
In this specification one or more embodiment, in db transaction implementation procedure, records the db transaction and relate to
And data cached identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction remember
The data cached identification information of record is corresponding data cached, in this way when needing to inquire the corresponding caching number of the identification information
According to when, will can guarantee database and this so automatically from being obtained in corresponding target data deposit local cache in database
Data in ground caching are consistent, avoid the occurrence of because database with data in local cache are inconsistent that follow-up data is caused to operate
There is the problem of mistake.
Optionally, above-mentioned apparatus further includes service code generation module, is used for:
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains number of targets
According to the service code of library affairs, wherein the target logic code includes: for realizing the first logic generation of caching is intercepted
Code and for realizing intercept affairs submit or rollback the second logical code.
Optionally, the cashing indication obtains module 501, is specifically used for:
If detecting operation first logical code, the class function for operating caching is intercepted;
Determine the data cached mark for including in the class function for operating caching;
The data cached mark that the data cached mark is related to as the target database affairs.
Optionally, the cashing indication memory module 502, is specifically used for:
In the data cached mark deposit thread context that the target database affairs are related to.
Optionally, the service code generation module, is specifically used for:
When the source code to target database affairs is compiled to obtain bytecode, using dynamic proxy technology described
Target logic code is added in bytecode, obtains the service code of target database affairs.
Optionally, the service code generation module, also particularly useful for:
The source code of target database affairs is compiled, the bytecode of the target database affairs is obtained;
When running the bytecode, target logic code is added in the bytecode using dynamic proxy technology, is obtained
To the service code of target database affairs.
Optionally, the cashing indication memory module 502, is further specifically used for:
Determine subject thread corresponding with the class function for operating caching intercepted;
In the thread context that the data cached mark write-in is bound in the subject thread.
Optionally, the data cached removing module 503, is specifically used for:
If detecting operation second logical code, the class function for operating affairs submission or rollback is intercepted;
Determine the db transaction mark for including in the class function for operating affairs submission or rollback;
For each data cached mark corresponding with db transaction mark, searched in local cache with
The data cached mark is corresponding data cached;
It is deleted from the local cache and finds described data cached, and deleted and stored in the thread context
The data cached mark.
Db transaction processing unit in this specification one or more embodiment, in the business of target database affairs
When code is run, the data cached mark that target database affairs are related to is obtained;The caching that storage target database affairs are related to
Data Identification;If target database affairs execute completion, the data cached mark for deleting storage is corresponding data cached.This theory
In bright book one or more embodiment, in db transaction implementation procedure, record the db transaction be related to it is data cached
Identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction record it is data cached
Identification information it is corresponding data cached, in this way when need to inquire the identification information it is corresponding data cached when, will be automatic
From being obtained in corresponding target data deposit local cache in database, it can guarantee the number in database and local cache in this way
According to being consistent, avoid the occurrence of causes follow-up data operation asking for mistake occur because database and data in local cache are inconsistent
Topic.
It should be noted that in this specification about in the embodiment and this specification of db transaction processing unit about
The embodiment of db transaction processing method based on the same inventive concept, therefore the specific implementation of the embodiment may refer to it is aforementioned
The implementation of corresponding db transaction processing method, overlaps will not be repeated.
Further, method shown in corresponding above-mentioned Fig. 1 to Fig. 4, based on the same technical idea, this specification one or
Multiple embodiments additionally provide a kind of db transaction processing equipment, and the equipment is for executing above-mentioned db transaction processing side
Method, as shown in Figure 6.
Db transaction processing equipment can generate bigger difference because configuration or performance are different, may include one or
More than one processor 601 and memory 602 can store one or more storages in memory 602 using journey
Sequence or data.Wherein, memory 602 can be of short duration storage or persistent storage.The application program for being stored in memory 602 can be with
Including one or more modules (diagram is not shown), each module may include to one in database transaction facility
Family computer executable instruction.Further, processor 601 can be set to communicate with memory 602, in database thing
The series of computation machine executable instruction in memory 602 is executed in processing equipment of being engaged in.Db transaction processing equipment can be with
Including one or more power supplys 603, one or more wired or wireless network interfaces 604, one or more
Input/output interface 605, one or more keyboards 606 etc..
In a specific embodiment, db transaction processing equipment include memory and one or one with
On program, perhaps more than one program is stored in memory and one or more than one program can wrap for one of them
Include one or more modules, and each module may include can to the series of computation machine in database transaction facility
It executes instruction, and is configured to execute this or more than one program by one or more than one processor to include to be used for
Carry out following computer executable instructions:
Target database affairs service code operation when, obtain the target database affairs be related to it is data cached
Mark;
Store the data cached mark that the target database affairs are related to;
If the target database affairs execute completion, it is corresponding data cached to delete the data cached mark.
In this specification one or more embodiment, in db transaction implementation procedure, records the db transaction and relate to
And data cached identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction remember
The data cached identification information of record is corresponding data cached, in this way when needing to inquire the corresponding caching number of the identification information
According to when, will can guarantee database and this so automatically from being obtained in corresponding target data deposit local cache in database
Data in ground caching are consistent, avoid the occurrence of because database with data in local cache are inconsistent that follow-up data is caused to operate
There is the problem of mistake.
Optionally, computer executable instructions also include for carrying out following computer executable instructions when executed:
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains number of targets
According to the service code of library affairs, wherein the target logic code includes: for realizing the first logic generation of caching is intercepted
Code and for realizing intercept affairs submit or rollback the second logical code.
Optionally, when executed, the acquisition target database affairs are related to slow computer executable instructions
Deposit data mark, comprising:
If detecting operation first logical code, the class function for operating caching is intercepted;
Determine the data cached mark for including in the class function for operating caching;
The data cached mark that the data cached mark is related to as the target database affairs.
Optionally, computer executable instructions when executed, the institute that the storage target database affairs are related to
State data cached mark, comprising:
In the data cached mark deposit thread context that the target database affairs are related to.
Optionally, computer executable instructions are when executed, described to utilize dynamic proxy technology in target database thing
In the bytecode of business, it is woven into target logic code and obtains the service code of target database affairs, comprising:
When the source code to target database affairs is compiled to obtain bytecode, using dynamic proxy technology described
Target logic code is added in bytecode, obtains the service code of target database affairs.
Optionally, computer executable instructions are when executed, described to utilize dynamic proxy technology in target database thing
In the bytecode of business, it is woven into target logic code and obtains the service code of target database affairs, comprising:
The source code of target database affairs is compiled, the bytecode of the target database affairs is obtained;
When running the bytecode, target logic code is added in the bytecode using dynamic proxy technology, is obtained
To the service code of target database affairs.
Optionally, computer executable instructions when executed, it is described the target database affairs are related to described in
In data cached mark deposit thread context, comprising:
Determine subject thread corresponding with the class function for operating caching intercepted;
In the thread context that the data cached mark write-in is bound in the subject thread.
Optionally, computer executable instructions are when executed, described to delete the corresponding caching of the data cached mark
Data, comprising:
If detecting operation second logical code, the class function for operating affairs submission or rollback is intercepted;
Determine the db transaction mark for including in the class function for operating affairs submission or rollback;
For each data cached mark corresponding with db transaction mark, searched in local cache with
The data cached mark is corresponding data cached;
It is deleted from the local cache and finds described data cached, and deleted and stored in the thread context
The data cached mark.
Db transaction processing equipment in this specification one or more embodiment, in the business of target database affairs
When code is run, the data cached mark that target database affairs are related to is obtained;The caching that storage target database affairs are related to
Data Identification;If target database affairs execute completion, the data cached mark for deleting storage is corresponding data cached.This theory
In bright book one or more embodiment, in db transaction implementation procedure, record the db transaction be related to it is data cached
Identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction record it is data cached
Identification information it is corresponding data cached, in this way when need to inquire the identification information it is corresponding data cached when, will be automatic
From being obtained in corresponding target data deposit local cache in database, it can guarantee the number in database and local cache in this way
According to being consistent, avoid the occurrence of causes follow-up data operation asking for mistake occur because database and data in local cache are inconsistent
Topic.
Further, method shown in corresponding above-mentioned Fig. 1 to Fig. 4, based on the same technical idea, this specification one or
Multiple embodiments additionally provide a kind of storage medium,, should in a kind of specific embodiment for storing computer executable instructions
Storage medium can be USB flash disk, CD, hard disk etc., and the computer executable instructions of storage medium storage are being executed by processor
When, it is able to achieve following below scheme:
Target database affairs service code operation when, obtain the target database affairs be related to it is data cached
Mark;
Store the data cached mark that the target database affairs are related to;
If the target database affairs execute completion, it is corresponding data cached to delete the data cached mark.
In this specification one or more embodiment, in db transaction implementation procedure, records the db transaction and relate to
And data cached identification information, so as to db transaction submit or rollback after, be automatically deleted for the db transaction remember
The data cached identification information of record is corresponding data cached, in this way when needing to inquire the corresponding caching number of the identification information
According to when, will can guarantee database and this so automatically from being obtained in corresponding target data deposit local cache in database
Data in ground caching are consistent, avoid the occurrence of because database with data in local cache are inconsistent that follow-up data is caused to operate
There is the problem of mistake.
Optionally, the computer executable instructions of storage medium storage are also realized when being executed by processor to flow down
Journey:
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains number of targets
According to the service code of library affairs, wherein the target logic code includes: for realizing the first logic generation of caching is intercepted
Code and for realizing intercept affairs submit or rollback the second logical code.
Optionally, the computer executable instructions of storage medium storage are when being executed by processor, described in the acquisition
The data cached mark that target database affairs are related to, comprising:
If detecting operation first logical code, the class function for operating caching is intercepted;
Determine the data cached mark for including in the class function for operating caching;
The data cached mark that the data cached mark is related to as the target database affairs.
Optionally, the computer executable instructions of storage medium storage are when being executed by processor, described in the storage
The data cached mark that target database affairs are related to, comprising:
In the data cached mark deposit thread context that the target database affairs are related to.
Optionally, the computer executable instructions of storage medium storage are described to utilize dynamic when being executed by processor
Agent skill group is woven into target logic code and obtains the business generation of target database affairs in the bytecode of target database affairs
Code, comprising:
When the source code to target database affairs is compiled to obtain bytecode, using dynamic proxy technology described
Target logic code is added in bytecode, obtains the service code of target database affairs.
Optionally, the computer executable instructions of storage medium storage are described to utilize dynamic when being executed by processor
Agent skill group is woven into target logic code and obtains the business generation of target database affairs in the bytecode of target database affairs
Code, comprising:
The source code of target database affairs is compiled, the bytecode of the target database affairs is obtained;
When running the bytecode, target logic code is added in the bytecode using dynamic proxy technology, is obtained
To the service code of target database affairs.
Optionally, the computer executable instructions of storage medium storage are described by the mesh when being executed by processor
In the data cached mark deposit thread context that mark db transaction is related to, comprising:
Determine subject thread corresponding with the class function for operating caching intercepted;
In the thread context that the data cached mark write-in is bound in the subject thread.
Optionally, the computer executable instructions of storage medium storage are when being executed by processor, described in the deletion
Data cached mark is corresponding data cached, comprising:
If detecting operation second logical code, the class function for operating affairs submission or rollback is intercepted;
Determine the db transaction mark for including in the class function for operating affairs submission or rollback;
For each data cached mark corresponding with db transaction mark, searched in local cache with
The data cached mark is corresponding data cached;
It is deleted from the local cache and finds described data cached, and deleted and stored in the thread context
The data cached mark.
The computer executable instructions of storage medium storage in this specification one or more embodiment are by processor
When execution, in the service code operation of target database affairs, the data cached mark that target database affairs are related to is obtained;
The data cached mark that storage target database affairs are related to;If target database affairs execute completion, the slow of storage is deleted
Deposit data mark is corresponding data cached.In this specification one or more embodiment, in db transaction implementation procedure, note
The data cached identification information that the db transaction is related to is recorded, after db transaction submission or rollback, is automatically deleted needle
It is corresponding data cached to the data cached identification information of db transaction record, in this way when needing to inquire the mark
It, will be automatically from being obtained in database in corresponding target data deposit local cache when information is corresponding data cached, such energy
Enough guarantee that database is consistent with the data in local cache, is avoided the occurrence of because database and data in local cache are inconsistent
Follow-up data operation is caused the problem of mistake occur.
In the 1990s, the improvement of a technology can be distinguished clearly be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (improvement for method flow).So
And with the development of technology, the improvement of current many method flows can be considered as directly improving for hardware circuit.
Designer nearly all obtains corresponding hardware circuit by the way that improved method flow to be programmed into hardware circuit.Cause
This, it cannot be said that the improvement of a method flow cannot be realized with hardware entities module.For example, programmable logic device
(Programmable Logic Device, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, logic function determines device programming by user.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, designs and makes without asking chip maker
Dedicated IC chip.Moreover, nowadays, substitution manually makes IC chip, this programming is also used instead mostly " is patrolled
Volume compiler (logic compiler) " software realizes that software compiler used is similar when it writes with program development,
And the source code before compiling also write by handy specific programming language, this is referred to as hardware description language
(Hardware Description Language, HDL), and HDL is also not only a kind of, but there are many kind, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HD Cal、
JHDL(Java Hardware Description Language)、Lava、Lola、My HDL、PALASM、RHDL(Ruby
Hardware Description Language) etc., VHDL (Very-High-Speed is most generally used at present
Integrated Circuit Hardware Description Language) and Verilog.Those skilled in the art also answer
This understands, it is only necessary to method flow slightly programming in logic and is programmed into integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method process can be readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
The computer for the computer readable program code (such as software or firmware) that device and storage can be executed by (micro-) processor can
Read medium, logic gate, switch, specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and insertion microcontroller, the example of controller includes but is not limited to following microcontroller
Device: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320 are deposited
Memory controller is also implemented as a part of the control logic of memory.It is also known in the art that in addition to
Pure computer readable program code mode is realized other than controller, can be made completely by the way that method and step is carried out programming in logic
Controller is obtained to come in fact in the form of logic gate, switch, specific integrated circuit, programmable logic controller (PLC) and insertion microcontroller etc.
Existing identical function.Therefore this controller is considered a kind of hardware component, and to including for realizing various in it
The device of function can also be considered as the structure in hardware component.Or even, it can will be regarded for realizing the device of various functions
For either the software module of implementation method can be the structure in hardware component again.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit can be realized in the same or multiple software and or hardware when specification one or more.
It should be understood by those skilled in the art that, the embodiment of this specification one or more can provide for method, system,
Or computer program product.Therefore, this specification one or more can be used complete hardware embodiment, complete software embodiment,
Or the form of embodiment combining software and hardware aspects.Moreover, this specification one or more can be used in one or more
It wherein include computer-usable storage medium (the including but not limited to magnetic disk storage, CD- of computer usable program code
ROM, optical memory etc.) on the form of computer program product implemented.
This specification one or more is referring to (being according to method, the equipment of this specification one or more embodiment
System) and the flowchart and/or the block diagram of computer program product describe.It should be understood that can be realized by computer program instructions
The process and/or box in each flow and/or block and flowchart and/or the block diagram in flowchart and/or the block diagram
Combination.Can provide these computer program instructions to general purpose computer, special purpose computer, Embedded Processor or other can compile
The processor of journey data processing equipment is to generate a machine, so that passing through computer or other programmable data processing devices
The instruction that processor executes generates for realizing in one box of one or more flows of the flowchart and/or block diagram or more
The device for the function of being specified in a box.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
It will be understood by those skilled in the art that the embodiment of this specification one or more can provide as method, system or meter
Calculation machine program product.Therefore, complete hardware embodiment, complete software embodiment or combination can be used in this specification one or more
The form of embodiment in terms of software and hardware.It is wherein wrapped moreover, this specification one or more can be used in one or more
Computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optics containing computer usable program code
Memory etc.) on the form of computer program product implemented.
This specification one or more can be in the general context of computer-executable instructions executed by a computer
Description, such as program module.Generally, program module includes the example for executing particular task or realizing particular abstract data type
Journey, programs, objects, component, data structure etc..This specification one or more can also be practiced in a distributed computing environment
It is a, in these distributed computing environments, by executing task by the connected remote processing devices of communication network.Dividing
Cloth calculates in environment, and program module can be located in the local and remote computer storage media including storage equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so being described relatively simple, related place is referring to embodiment of the method
Part explanation.
The foregoing is merely the embodiment of this specification one or more, be not limited to this specification one or
It is multiple.To those skilled in the art, this specification one or more can have various modifications and variations.It is all in this explanation
Any modification, equivalent replacement, improvement and so within book one or more spirit and principle, should be included in this specification
Within one or more scopes of the claims.