CN110008224A - A kind of db transaction processing method and processing device - Google Patents

A kind of db transaction processing method and processing device Download PDF

Info

Publication number
CN110008224A
CN110008224A CN201910176345.5A CN201910176345A CN110008224A CN 110008224 A CN110008224 A CN 110008224A CN 201910176345 A CN201910176345 A CN 201910176345A CN 110008224 A CN110008224 A CN 110008224A
Authority
CN
China
Prior art keywords
data cached
affairs
target database
mark
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910176345.5A
Other languages
Chinese (zh)
Other versions
CN110008224B (en
Inventor
雷毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910176345.5A priority Critical patent/CN110008224B/en
Publication of CN110008224A publication Critical patent/CN110008224A/en
Application granted granted Critical
Publication of CN110008224B publication Critical patent/CN110008224B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Abstract

This specification one or more embodiment provides a kind of db transaction processing method and processing device, this method comprises: obtaining and storing the data cached mark that target database affairs are related in the service code operation of target database affairs;If target database affairs execute completion, the data cached mark for deleting storage is corresponding data cached.In db transaction implementation procedure, record the data cached identification information that the db transaction is related to, after db transaction submission or rollback, it is corresponding data cached to be automatically deleted the data cached identification information recorded for the db transaction, in this way when need to inquire the identification information it is corresponding data cached when, it will be automatically from being obtained in database in corresponding target data deposit local cache, it can guarantee that database is consistent with the data in local cache in this way, avoid the occurrence of causes follow-up data operation the problem of mistake occur because data are inconsistent in database and local cache.

Description

A kind of db transaction processing method and processing device
Technical field
This specification one or more be related to field of computer technology more particularly to a kind of db transaction processing method and Device.
Background technique
Currently, in order to quick obtaining to common and stable business datum, and reduce the access time to database Number, usually can using caching technology will be common and stable business datum store into local cache, in this way need using When the business datum, the business datum can be directly obtained from local cache, without obtaining the industry to database request repeatedly Business data.
It, otherwise will not be permanent since issued transaction may insure all to successfully complete except all operations in non-transactional unit Update the resource of data-oriented.By the way that one group of relevant operation group is combined into either all a success or all list unsuccessfully Member can simplify Fault recovery and keep application program relatively reliable.Therefore, to the number in database by the way of issued transaction Change according to progress additions and deletions and look into operation, to guarantee the stationarity and predictability of database data.That is db transaction (Database Transaction) refer to the sequence of operations executed in database as single logical unit of work or be completely executed, It does not execute fully.
However, not only needing to carry out corresponding operation to the data in database, if thing when executing db transaction Database data operated by business treatment process has used caching, i.e., carries out affairs to the business datum in the database for having caching When operation, also operation will be updated to the data in caching based on the data variation in database, for high concurrent situation or The case where person's data rewind, database will occurs and the data in caching is inconsistent, so as to cause subsequent data manipulation appearance It is abnormal, for example, it is directed to data query operation, it is inconsistent from the data in the data and database inquired in caching, cause most The data for showing user eventually are wrong data.
It can thus be appreciated that, it is desirable to provide a kind of data processing method for improving database and the data consistency in caching.
Summary of the invention
The purpose of this specification one or more embodiment is to provide a kind of db transaction processing method and processing device, in number According to the data cached identification information that the db transaction is related in the affairs implementation procedure of library, is recorded, so that db transaction mentions After friendship or rollback, it is automatically deleted the corresponding caching number of data cached identification information for db transaction record According to, in this way when need to inquire the identification information it is corresponding data cached when, corresponding number of targets will be obtained from database automatically According in deposit local cache, it can guarantee that database is consistent with the data in local cache, is avoided the occurrence of because of data in this way Data are inconsistent in library and local cache causes follow-up data operation the problem of mistake occur.
In order to solve the above technical problems, this specification one or more embodiment is achieved in that
This specification one or more embodiment provides a kind of db transaction processing method, comprising:
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.
This specification one or more embodiment provides a kind of db transaction processing unit, comprising:
Cashing indication obtains module, for obtaining the number of targets in the service code operation of target database affairs The data cached mark being related to according to library affairs;
Cashing indication memory module, the data cached mark being related to for storing the target database affairs;
Data cached removing module is deleted described data cached if executing completion for the target database affairs It identifies corresponding data cached.
This specification one or more embodiment provides a kind of db transaction processing equipment, comprising: processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the place when executed Manage device:
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.
This specification one or more embodiment provides a kind of storage medium, for storing computer executable instructions, The executable instruction realizes following below scheme when executed:
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.
Db transaction processing method and processing device in this specification one or more embodiment, in target database affairs Service code operation when, obtain the data cached mark that is related to of target database affairs;Storage target database affairs are related to Data cached mark;If target database affairs execute completion, the corresponding caching number of data cached mark of storage is deleted According to.In this specification one or more embodiment, in db transaction implementation procedure, record that the db transaction is related to is slow The identification information of deposit data is automatically deleted after db transaction submission or rollback for the slow of db transaction record The identification information of deposit data is corresponding data cached, in this way when need to inquire the identification information it is corresponding data cached when, Automatically it will can guarantee database and local cache in this way from being obtained in corresponding target data deposit local cache in database In data be consistent, avoid the occurrence of because inconsistent to cause follow-up data operation to occur wrong for data in database and local cache Accidentally the problem of.
Detailed description of the invention
In order to illustrate more clearly of this specification one or more embodiment or technical solution in the prior art, below will A brief introduction will be made to the drawings that need to be used in the embodiment or the description of the prior art, it should be apparent that, it is described below Attached drawing is only some embodiments recorded in this specification one or more, for those of ordinary skill in the art, Not under the premise of making the creative labor property, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is the first process signal for the db transaction processing method that this specification one or more embodiment provides Figure;
Fig. 2 is second of process signal for the db transaction processing method that this specification one or more embodiment provides Figure;
Fig. 3 is the third process signal for the db transaction processing method that this specification one or more embodiment provides Figure;
Fig. 4 is the realization principle signal for the db transaction processing method that this specification one or more embodiment provides Figure;
Fig. 5 is the module composition signal for the db transaction processing unit that this specification one or more embodiment provides Figure;
Fig. 6 is the structural schematic diagram for the db transaction processing equipment that this specification one or more embodiment provides.
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.

Claims (18)

1. a kind of db transaction processing method, comprising:
In the service code operation of target database affairs, the data cached mark that the target database affairs are related to is obtained Know;
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.
2. according to the method described in claim 1, wherein, further includes:
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains target database The service code of affairs, wherein the target logic code include: for realizing intercept caching the first logical code and For realizing the second logical code for intercepting affairs submission or rollback.
3. according to the method described in claim 2, wherein, the data cached mark for obtaining the target database affairs and being related to Know, 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.
4. according to the method described in claim 3, wherein, the caching number that the storage target database affairs are related to According to mark, comprising:
In the data cached mark deposit thread context that the target database affairs are related to.
5. according to the method described in claim 2, wherein, it is described using dynamic proxy technology target database affairs byte In code, 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 in the byte Target logic code is added in code, obtains the service code of target database affairs.
6. according to the method described in claim 2, wherein, it is described using dynamic proxy technology target database affairs byte In code, 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, obtains mesh Mark the service code of db transaction.
7. according to the method described in claim 4, wherein, it is described the target database affairs are related to it is described data cached In 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.
8. according to the method described in claim 4, wherein, the deletion data cached mark is corresponding data cached, packet It includes:
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 slow with this Deposit data mark is corresponding data cached;
It is deleted from the local cache and finds institute that is described data cached, and storing in the deletion thread context State data cached mark.
9. a kind of db transaction processing unit, comprising:
Cashing indication obtains module, for obtaining the target database in the service code operation of target database affairs The data cached mark that affairs are related to;
Cashing indication memory module, the data cached mark being related to for storing the target database affairs;
Data cached removing module deletes the data cached mark if executing completion for the target database affairs It is corresponding data cached.
10. device according to claim 9, wherein further include service code generation module, be used for:
Using dynamic proxy technology in the bytecode of target database affairs, it is woven into target logic code and obtains target database The service code of affairs, wherein the target logic code include: for realizing intercept caching the first logical code and For realizing the second logical code for intercepting affairs submission or rollback.
11. device according to claim 10, wherein the cashing indication obtains module, 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.
12. device according to claim 11, wherein the cashing indication memory module is specifically used for:
In the data cached mark deposit thread context that the target database affairs are related to.
13. device according to claim 10, wherein 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 in the byte Target logic code is added in code, obtains the service code of target database affairs.
14. device according to claim 10, wherein 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, obtains mesh Mark the service code of db transaction.
15. device according to claim 12, wherein the cashing indication memory module 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.
16. device according to claim 12, wherein the data cached removing module 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 slow with this Deposit data mark is corresponding data cached;
It is deleted from the local cache and finds institute that is described data cached, and storing in the deletion thread context State data cached mark.
17. a kind of db transaction processing equipment, comprising:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the processing when executed Device:
In the service code operation of target database affairs, the data cached mark that the target database affairs are related to is obtained Know;
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.
18. a kind of storage medium, for storing computer executable instructions, the executable instruction is realized following when executed Process:
In the service code operation of target database affairs, the data cached mark that the target database affairs are related to is obtained Know;
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.
CN201910176345.5A 2019-03-08 2019-03-08 Database transaction processing method and device Active CN110008224B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910176345.5A CN110008224B (en) 2019-03-08 2019-03-08 Database transaction processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910176345.5A CN110008224B (en) 2019-03-08 2019-03-08 Database transaction processing method and device

Publications (2)

Publication Number Publication Date
CN110008224A true CN110008224A (en) 2019-07-12
CN110008224B CN110008224B (en) 2023-08-11

Family

ID=67166683

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910176345.5A Active CN110008224B (en) 2019-03-08 2019-03-08 Database transaction processing method and device

Country Status (1)

Country Link
CN (1) CN110008224B (en)

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955539A (en) * 2019-11-26 2020-04-03 杭州迪普信息技术有限公司 Process quitting method and device, electronic equipment and machine-readable storage medium
CN111062684A (en) * 2019-11-29 2020-04-24 普元信息技术股份有限公司 System and method for realizing consistent processing of business data and process data under cloud process platform
CN111177197A (en) * 2019-12-26 2020-05-19 北京仁科互动网络技术有限公司 Cache processing method and system
CN111367718A (en) * 2020-02-26 2020-07-03 上海达梦数据库有限公司 Database starting method, device, equipment and storage medium
CN111526184A (en) * 2020-04-07 2020-08-11 中国建设银行股份有限公司 Business auditing method and device
CN111737331A (en) * 2020-06-22 2020-10-02 中国银行股份有限公司 Transaction consistency processing method and system for database and object storage
CN111797015A (en) * 2020-06-30 2020-10-20 中国工商银行股份有限公司 Testing method and device based on dynamic byte codes
CN111930478A (en) * 2020-06-08 2020-11-13 北京每日优鲜电子商务有限公司 Service calling method and device based on dynamic bytecode
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium
CN112463810A (en) * 2020-12-08 2021-03-09 佳讯飞鸿(北京)智能科技研究院有限公司 Data processing method, device, equipment and storage medium based on distributed transaction
CN112540834A (en) * 2020-12-18 2021-03-23 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN112559570A (en) * 2020-12-16 2021-03-26 中国平安财产保险股份有限公司 Cache data acquisition method, device, equipment and storage medium
CN113010495A (en) * 2021-03-19 2021-06-22 北京三快在线科技有限公司 Database optimization method and device
CN113094430A (en) * 2021-03-25 2021-07-09 北京达佳互联信息技术有限公司 Data processing method, device, equipment and storage medium
CN113254425A (en) * 2021-06-24 2021-08-13 阿里云计算有限公司 Method, apparatus, system, program and storage medium for database transaction retention
CN113761077A (en) * 2021-01-04 2021-12-07 北京京东振世信息技术有限公司 Method and device for processing document task
CN117193670A (en) * 2023-11-06 2023-12-08 之江实验室 Method and device for clearing cache, storage medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6272602B1 (en) * 1999-03-08 2001-08-07 Sun Microsystems, Inc. Multiprocessing system employing pending tags to maintain cache coherence
CN106294607A (en) * 2016-07-29 2017-01-04 北京奇虎科技有限公司 Data cached update method and updating device
CN106815329A (en) * 2016-12-29 2017-06-09 网易无尾熊(杭州)科技有限公司 A kind of data cached update method and device
CN108958955A (en) * 2018-07-06 2018-12-07 美利车(北京)网络技术有限公司 A kind of transaction methods and device based on message-driven

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6272602B1 (en) * 1999-03-08 2001-08-07 Sun Microsystems, Inc. Multiprocessing system employing pending tags to maintain cache coherence
CN106294607A (en) * 2016-07-29 2017-01-04 北京奇虎科技有限公司 Data cached update method and updating device
CN106815329A (en) * 2016-12-29 2017-06-09 网易无尾熊(杭州)科技有限公司 A kind of data cached update method and device
CN108958955A (en) * 2018-07-06 2018-12-07 美利车(北京)网络技术有限公司 A kind of transaction methods and device based on message-driven

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110955539A (en) * 2019-11-26 2020-04-03 杭州迪普信息技术有限公司 Process quitting method and device, electronic equipment and machine-readable storage medium
CN111062684A (en) * 2019-11-29 2020-04-24 普元信息技术股份有限公司 System and method for realizing consistent processing of business data and process data under cloud process platform
CN111062684B (en) * 2019-11-29 2023-10-20 普元信息技术股份有限公司 System and method for realizing consistency processing of business data and process data under cloud process platform
CN111177197A (en) * 2019-12-26 2020-05-19 北京仁科互动网络技术有限公司 Cache processing method and system
CN111177197B (en) * 2019-12-26 2023-03-14 北京仁科互动网络技术有限公司 Cache processing method and system
CN111367718A (en) * 2020-02-26 2020-07-03 上海达梦数据库有限公司 Database starting method, device, equipment and storage medium
CN111367718B (en) * 2020-02-26 2023-05-02 上海达梦数据库有限公司 Database starting method, device, equipment and storage medium
CN111526184B (en) * 2020-04-07 2022-07-29 中国建设银行股份有限公司 Business auditing method and device
CN111526184A (en) * 2020-04-07 2020-08-11 中国建设银行股份有限公司 Business auditing method and device
CN111930478A (en) * 2020-06-08 2020-11-13 北京每日优鲜电子商务有限公司 Service calling method and device based on dynamic bytecode
CN111737331B (en) * 2020-06-22 2023-08-18 中国银行股份有限公司 Transaction consistency processing method and system for database and object storage
CN111737331A (en) * 2020-06-22 2020-10-02 中国银行股份有限公司 Transaction consistency processing method and system for database and object storage
CN111797015B (en) * 2020-06-30 2024-02-09 中国工商银行股份有限公司 Dynamic byte code based test method and device
CN111797015A (en) * 2020-06-30 2020-10-20 中国工商银行股份有限公司 Testing method and device based on dynamic byte codes
CN112199391B (en) * 2020-09-30 2024-02-23 深圳前海微众银行股份有限公司 Data locking detection method, equipment and computer readable storage medium
CN112199391A (en) * 2020-09-30 2021-01-08 深圳前海微众银行股份有限公司 Data locking detection method and device and computer readable storage medium
CN112463810A (en) * 2020-12-08 2021-03-09 佳讯飞鸿(北京)智能科技研究院有限公司 Data processing method, device, equipment and storage medium based on distributed transaction
CN112559570A (en) * 2020-12-16 2021-03-26 中国平安财产保险股份有限公司 Cache data acquisition method, device, equipment and storage medium
CN112540834B (en) * 2020-12-18 2023-04-14 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN112540834A (en) * 2020-12-18 2021-03-23 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN113761077A (en) * 2021-01-04 2021-12-07 北京京东振世信息技术有限公司 Method and device for processing document task
CN113761077B (en) * 2021-01-04 2023-11-03 北京京东振世信息技术有限公司 Method and device for processing bill task
CN113010495B (en) * 2021-03-19 2023-01-06 北京三快在线科技有限公司 Database optimization method and device
CN113010495A (en) * 2021-03-19 2021-06-22 北京三快在线科技有限公司 Database optimization method and device
CN113094430B (en) * 2021-03-25 2023-10-03 北京达佳互联信息技术有限公司 Data processing method, device, equipment and storage medium
CN113094430A (en) * 2021-03-25 2021-07-09 北京达佳互联信息技术有限公司 Data processing method, device, equipment and storage medium
CN113254425A (en) * 2021-06-24 2021-08-13 阿里云计算有限公司 Method, apparatus, system, program and storage medium for database transaction retention
CN117193670A (en) * 2023-11-06 2023-12-08 之江实验室 Method and device for clearing cache, storage medium and electronic equipment
CN117193670B (en) * 2023-11-06 2024-01-30 之江实验室 Method and device for clearing cache, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN110008224B (en) 2023-08-11

Similar Documents

Publication Publication Date Title
CN110008224A (en) A kind of db transaction processing method and processing device
CN107894953A (en) A kind of generation method and device of Bank application test data
CN109615495B (en) Data reconciliation method, device, equipment and system
CN106030533B (en) It is executed by split process and retries affairs automatically
CN106844682B (en) Method for interchanging data, apparatus and system
CN104391787B (en) Monitoring method aiming at target method as well as thermal cutting-in method and device
CN106021017A (en) Method and system for clone file backup and restore
CN110648138A (en) Transaction query and transaction data processing method, device and equipment based on block chain
CN107679700A (en) Business flow processing method, apparatus and server
CN109582485A (en) A kind of configuration change method for detecting abnormality and device
CN109299222A (en) Verification of data method and device
CN110058958A (en) For managing the method, equipment and computer program product of data backup
CN109598407A (en) A kind of execution method and device of operation flow
CN108733546A (en) A kind of log collection method, device and equipment
CN108537012A (en) Source code based on variable and code execution sequence obscures method and device
CN109922142A (en) A kind of document down loading method, apparatus and system
CN108615184A (en) A kind of method and device of book keeping operation
CN109993646A (en) Accounting entry information determines method and device, accounting data recording method and device
CN110262998A (en) A kind of reconciliation data processing method and device
CN107451868A (en) A kind of method and device of article appraisal
CN109166021A (en) Bookkeeping methods, device and business finance integral system
CN109886804B (en) Task processing method and device
CN108830705A (en) A kind of method of summary of transaction data, device and equipment
Gottschlich et al. Visualizing transactional memory
CN110264213A (en) A kind of processing method of information, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20200923

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

Effective date of registration: 20200923

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant before: Advanced innovation technology Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant