CN110659971B - Transaction data processing method and device - Google Patents
Transaction data processing method and device Download PDFInfo
- Publication number
- CN110659971B CN110659971B CN201810697278.7A CN201810697278A CN110659971B CN 110659971 B CN110659971 B CN 110659971B CN 201810697278 A CN201810697278 A CN 201810697278A CN 110659971 B CN110659971 B CN 110659971B
- Authority
- CN
- China
- Prior art keywords
- account
- information
- database
- transaction
- accounting
- 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.)
- Active
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 22
- 238000000034 method Methods 0.000 claims abstract description 32
- 230000003139 buffering effect Effects 0.000 claims abstract description 18
- 238000004590 computer program Methods 0.000 claims description 20
- 238000010586 diagram Methods 0.000 description 8
- 230000000694 effects Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- WVCHIGAIXREVNS-UHFFFAOYSA-N 2-hydroxy-1,4-naphthoquinone Chemical compound C1=CC=C2C(O)=CC(=O)C(=O)C2=C1 WVCHIGAIXREVNS-UHFFFAOYSA-N 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/12—Accounting
- G06Q40/125—Finance or payroll
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Engineering & Computer Science (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a transaction data processing method and a device, wherein the method comprises the following steps: caching account information of an account stored in a service database into a memory database; executing transaction processing according to the account information of the first account cached in the memory database; and carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing. The transaction data processing method provided by the invention can not only improve the real-time performance of transaction processing, but also reduce the operation frequency of the business database.
Description
Technical Field
The invention relates to the field of data processing, in particular to a transaction data processing method and device.
Background
In accounting systems, accounts where funds transfer occurs typically require accounting processes. In the process of accounting processing, in order to avoid that a large amount of service database resources are forced to compete due to frequent operation on hot accounts (for example, accounts with a large operation frequency), so that a service database is deadlocked and an accounting system is unavailable, a related technology adopts a buffering accounting method to realize accounting processing on accounts, namely after each transaction request is received, the request details are recorded in the service database, the record number is added by 1, and when the record number reaches a certain value or a time span reaches a certain value, all the request details are collected and account entry is carried out. Therefore, the existing buffer accounting processing mode has poor real-time performance.
Disclosure of Invention
The embodiment of the invention provides a transaction data processing method and device, aiming at solving the problem of poor real-time performance of the existing buffering accounting processing mode.
In order to solve the technical problem, the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides a transaction data processing method. The method comprises the following steps:
caching account information of an account stored in a service database into a memory database;
executing transaction processing according to the account information of the first account cached in the memory database;
and carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
In a second aspect, an embodiment of the present invention further provides a transaction data processing apparatus. The transaction data processing apparatus includes:
the cache module is used for caching the account information of the account stored in the service database into the memory database;
the transaction processing module is used for executing transaction processing according to the account information of the first account cached in the memory database;
and the accounting module is used for carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
In a third aspect, an embodiment of the present invention further provides a transaction data processing apparatus, including a processor, a memory, and a computer program stored on the memory and executable on the processor, where the computer program, when executed by the processor, implements the steps of the transaction data processing method described above.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the transaction data processing method described above.
In the embodiment of the invention, the account information of the account stored in the service database is cached in the memory database; executing transaction processing according to the account information of the first account cached in the memory database; and carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing, so that the real-time performance of the transaction processing can be improved, and the operation frequency of the service database can be reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a flow chart of a transaction data processing method provided by an embodiment of the invention;
FIG. 2 is a flow chart of a transaction data processing method according to yet another embodiment of the invention;
FIG. 3 is a block diagram of a transaction data processing device provided by an embodiment of the present invention;
FIG. 4 is a block diagram of a transaction data processing device according to yet another embodiment of the present invention;
FIG. 5 is a block diagram of a transaction data processing device according to yet another embodiment of the present invention;
FIG. 6 is a block diagram of a transaction data processing device according to yet another embodiment of the present invention;
FIG. 7 is a block diagram of a transaction data processing device according to yet another embodiment of the present invention;
fig. 8 is a block diagram of a transaction data processing device according to still another embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a transaction data processing method. Referring to fig. 1, fig. 1 is a flowchart of a transaction data processing method according to an embodiment of the present invention, as shown in fig. 1, including the following steps:
In this embodiment of the present invention, the service database may be a database for storing account-related information, where the account-related information may include information such as an account name, an account balance, an account status (e.g., a sales status, a normal status, or a lock status), and an account transaction flow. The memory database may be a database in which data is cached in a memory and directly operated, for example, a Redis database, an SAP HANA database, a FastDB database, an SQLite database, a Berkeley DB database, a GigaBase database, and the like.
In this step, the account information of the account stored in the service database may be cached in the memory database, where the account information may include all or part of the information of the account stored in the service database. For example, the account information may include an account name, an account balance, and an account status of the account.
It should be noted that the account status may include a account status, a normal status, a locked status, and the like, and is used to indicate whether the account is currently available, for example, the account in the normal status is available, and the account in the account status or the locked status is not available.
It can be understood that, in the embodiment of the present invention, the account information of all the accounts stored in the service database may be cached in the memory database, or only the account information of a part of the accounts stored in the service database may be cached in the memory database. The service database and the memory database may be located in the same server, or may be located in different servers respectively.
It should be noted that, in the embodiment of the present invention, the account information of the account stored in the service database may be cached in the memory database immediately after the server where the service database is located is started, or the account information of the account stored in the service database may be cached in the memory database after the transaction request is received, which is not limited in the embodiment of the present invention.
And 102, executing transaction processing according to the account information of the first account cached in the memory database.
In the embodiment of the present invention, when a transaction request for a first account is received, transaction processing may be performed according to account information of the first account cached in the memory database.
It should be noted that, the receiving of the transaction request for the first account may be performed before step 101, that is, after the transaction request for the first account is received, the account information of the account stored in the service database is cached in the memory database; the receiving of the transaction request for the first account may be performed after step 101 and before step 102, that is, after the account information of the account stored in the service database is cached in the memory database, if the transaction request for the first account is received, the transaction processing is performed according to the account information of the first account cached in the memory database.
Specifically, because the account information of the account stored in the service database is cached in the memory database, the transaction processing may be executed according to the account information of the first account cached in the memory database, where the first account may be any one of the accounts cached in the memory database. In practical applications, the executing the transaction processing according to the account information of the first account cached in the memory database may be reading the account information of the first account from the memory database, and executing the transaction processing in the system memory according to the account information of the first account.
For example, when a transaction request for a first account is received, account information of the first account may be read from the memory database, an account balance of the first account is calculated in the system memory according to the account information of the first account and the transaction request, the account balance of the first account cached in the memory database is updated according to the calculated account balance of the first account, the updated account balance of the first account is returned to a sending end of the transaction request, and accounting information such as an accounting voucher table and accounting details information may be recorded, where the accounting information may be stored in the system memory, the memory database, or the service database.
And 103, carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
In an embodiment of the present invention, the accounting information of the transaction processing may include account balance after the transaction processing and/or accounting detail information, where the accounting detail information may include, but is not limited to, information such as an account name, a transaction time, a transaction amount, and an accounting direction, where the accounting direction may include an account entry (e.g., income) or an account exit (e.g., expenditure). It should be noted that the accounting information of the transaction processing may be stored in a system memory, a memory database, a service database, or the like.
In this step, according to the accounting information of the transaction processing, the first account in the service database may be buffered and accounted. It is understood that the above buffering accounting process may refer to not separately performing accounting process on the first account in the service database for each received transaction request, but performing batch accounting process in the service database according to the accounting information of the transaction process corresponding to each transaction request. For example, batch accounting processing is performed on the first account in the service database according to the accounting information of the transaction processing at preset time intervals.
In the embodiment of the invention, the transaction processing can be carried out in the system memory in real time according to the account information of the account cached in the memory database, so that the real-time performance of the transaction processing can be improved. In addition, because the first account in the service database is buffered and booked according to the bookkeeping information of the transaction processing, the operation frequency of the service database can be reduced, so that the condition that the resources of the service database are occupied by competition is reduced, the deadlock of the service database caused by the resource competition is avoided, and the use efficiency of the service database is improved.
Referring to fig. 2, fig. 2 is a flowchart of a transaction data processing method according to another embodiment of the present invention. The difference between the embodiment of the present invention and the previous embodiment is mainly that the execution of transaction processing according to the account information of the first account cached in the in-memory database is further limited. In an embodiment of the present invention, the executing transaction processing according to the account information of the first account cached in the in-memory database includes: if a transaction request aiming at a first account in the accounts is received, judging whether a transaction processing condition is met according to the account information of the first account cached in the memory database; if the transaction processing condition is determined to be met, updating the account balance of the first account cached in the memory database, and returning the updated account balance of the first account to the sending end of the transaction request.
As shown in fig. 2, the transaction data processing method provided by the embodiment of the present invention includes the following steps:
This step is the same as the step 101, and is not described herein again to avoid repetition.
In an embodiment of the present invention, the transaction processing condition may include whether the account is available and/or whether the account balance is sufficient. Specifically, whether the account is available or not may be determined according to the account status, for example, if the account status is a sales status or a lock status, it is determined that the account is not available. Whether the account balance is sufficient or not can be judged based on the transaction amount and the account balance, for example, in the case that the transaction request is a cash withdrawal request, if the cash withdrawal amount is less than or equal to the account balance, the account balance can be determined to be sufficient, and if the cash withdrawal amount is greater than the account balance, the account balance can be determined to be insufficient.
For example, when a transaction request for a first account of the accounts is received, the account information of the first account may be read from the memory database, and whether a transaction processing condition is satisfied may be determined in the system memory based on the read account information of the first account cached in the memory database.
It should be noted that the sending end of the transaction request may be a client or a server, which is not limited in the embodiment of the present invention.
In this step, in the case that it is determined that the transaction processing condition is satisfied, the account balance of the first account cached in the memory database may be updated, for example, the account balance of the first account may be updated based on the billing direction, the transaction amount, and the account balance of the first account cached in the memory database.
After the account balance of the first account cached in the memory database is updated, the updated account balance of the first account may be returned to the sending end of the transaction request, so that the sending end may check the transaction result, or continue to perform subsequent processing according to the transaction result, and the like.
In addition, in the case that it is determined that the transaction processing condition is satisfied, the embodiment of the present invention may further record the accounting information of the transaction processing, where the accounting information may include an account balance after the transaction processing and/or accounting detail information, where the accounting detail information may include, but is not limited to, information such as an account name, a transaction time, a transaction amount, and an accounting direction, where the accounting direction may include an income (e.g., income) or an expenditure (e.g., expenditure), and the like. It should be noted that the accounting information of the transaction processing may be stored in a system memory, a memory database, a service database, or the like.
Optionally, in a case that it is determined that the transaction processing condition is not satisfied, a prompt message may be returned to a sending end of the transaction request, or a flow may be ended.
And 204, performing buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
This step is the same as step 103, and is not described herein again to avoid repetition.
According to the transaction data processing method provided by the embodiment of the invention, if a transaction request aiming at a first account in the accounts is received, whether a transaction processing condition is met is judged according to the account information of the first account cached in the memory database, and if the transaction processing condition is determined to be met, the account balance of the first account cached in the memory database is updated, and the updated account balance of the first account is returned to the sending end of the transaction request, so that the success rate and real-time performance of the transaction can be improved, and the pressure of subsequent service processing of the sending end of the transaction request can be reduced. In addition, according to the accounting information of the transaction processing, the first account in the service database is subjected to buffering accounting processing, so that the operation frequency of the service database can be reduced, the deadlock of the service database caused by resource competition is avoided, and the service efficiency of the service database is improved.
Optionally, the accounting information of the transaction processing includes an account balance after the first account is updated and cached in the memory database;
in step 103 or step 204, that is, performing buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing may include:
if the time length from the previous time of updating the account balance of the first account in the service database reaches a first preset time length, reading the updated account balance of the first account cached in the memory database;
and updating the account balance of the first account in the service database according to the updated account balance of the first account cached in the memory database.
In the embodiment of the present invention, the first preset time period may be reasonably set according to actual requirements, for example, 5 seconds, 10 seconds, and the like.
The embodiment of the invention updates the account balance of the first account in the service database by reading the updated account balance of the first account cached in the memory database, is relatively simple and convenient to realize, and can ensure that the account balance of the account cached in the memory database is consistent with the account balance of the account stored in the service database.
Optionally, the transaction processing accounting information includes the transaction processing accounting detail information;
in step 103 or step 204, that is, performing buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing may include:
if the recorded accounting detail information reaches a preset amount, or the time from the previous updating of the account balance of the first account in the service database reaches a second preset time, summarizing the recorded accounting detail information;
and updating the account balance of the first account in the service database based on the summarized accounting detail information.
In an embodiment of the present invention, the aforementioned accounting detail information may include, but is not limited to, information such as an account name, a transaction time, a transaction amount, and an accounting direction, where the accounting direction may include an income (e.g., income) or an expense (e.g., expenditure), and the like. It should be noted that, the aforementioned accounting detail information may be recorded immediately after receiving the transaction request, or may be recorded after performing transaction processing, which is not limited in the embodiment of the present invention. The preset number and the second preset duration can be reasonably set according to actual requirements, for example, the preset number is 10, 15 or the like, and the second preset duration can be 5 seconds, 10 seconds or the like.
Specifically, one piece of accounting detail information may be recorded for each transaction request, so that the recorded accounting detail information for the first account may be summarized under the condition that the number of the recorded accounting detail information reaches a preset number, or a time length from a previous update of the account balance of the first account in the service database reaches a second preset time length, for example, the summarized accounting direction and transaction amount may be obtained based on the accounting direction and transaction amount in each piece of accounting detail information, and the account balance of the first account in the service database may be updated based on the summarized accounting direction and transaction amount.
For example, the accounting detail information a is 500 yuan, the accounting detail information b is 100 yuan, the accounting detail information c is 300 yuan, the accounting detail information d is 100 yuan, and the accounting detail information e is 200 yuan, and by summarizing the above 5 items of accounting detail information, the direction of the summarized accounting is taken as a withdrawal (i.e., a charge), and the transaction amount after the summary is 400 yuan.
It should be noted that the collected billing detail information in the embodiment of the present invention is the billing detail information that has not participated in the account balance update of the service database, for example, the billing detail information recorded after the service database updates the account balance last time.
The account balance of the first account in the service database is updated based on the accounting detail information, so that the accuracy of the account balance of the first account in the service database can be ensured.
Optionally, in step 101 or step 201, that is, caching the account information of the account stored in the service database into the memory database, the caching may include:
and caching account information of the hot account stored in the service database into a memory database, wherein the hot account is an account with the operation frequency more than or equal to the preset times.
In the embodiment of the present invention, the preset times may also be set reasonably according to actual requirements, for example, 500, 1000, and so on.
In practical application, the problem that resources are forced to compete easily occurs in hot account stored in the service database, and therefore, in order to reduce the amount of cached data, only account information of the hot account stored in the service database may be cached in the memory database.
In the embodiment of the present invention, for the transaction request for the hotspot account, transaction processing may be performed according to the account information of the hotspot account cached in the memory database, and for the transaction request of other accounts (accounts other than the hotspot account), transaction processing may be performed according to the account information of the account stored in the service database.
Optionally, after receiving the transaction request, the embodiment of the present invention may query the account information of the account to which the transaction request is directed by querying the memory database first, and if the account information of the account to which the transaction request is directed is not stored in the memory database, may query the account information of the account to which the transaction request is directed from the business database; the hot account list may also be stored in advance, the in-memory database may be queried to query the account information of the account to which the transaction request is directed when the account to which the transaction request is directed is located in the hot account list, and the service database may be queried to query the account information of the account to which the transaction request is directed when the account to which the transaction request is directed is not located in the hot account list.
According to the embodiment of the invention, only the account information of the hot account stored in the service database is cached in the memory database, so that the cached data volume and data processing volume of the memory database can be reduced.
Optionally, after step 101 or step 201, that is, after the account information of the account stored in the service database is cached in the memory database, the method further includes:
and if a query request aiming at a second account is received, querying the account balance of the second account from the memory database, and returning the queried account balance of the second account to a sending end of the query request.
In this embodiment of the present invention, the second account may be any one of accounts cached in the memory database.
In practical applications, since the service database performs the buffering accounting process, if the account balance of an account is queried from the service database, if the account balance of the account in the service database is not updated, the query result may be inaccurate. Therefore, in the embodiment of the present invention, when a query request for a second account is received, the account balance of the second account can be queried from the memory database and returned to the sending end of the query request, so that the accuracy of the returned account balance can be ensured.
Optionally, the memory database includes a Redis database.
In the embodiment of the present invention, the Redis database is a Key-Value-based memory database, which supports more types of data to be stored, and includes a String (i.e., String), a linked List (i.e., List), a Set (i.e., Set), an ordered Set (i.e., Sorted Set), a Hash (i.e., Hash), and the like. These data types all support Push (i.e., Push), Pop (i.e., Pop), Add (i.e., Add), Remove (i.e., Remove), intersect, merge, and difference operations, which are all atomic. Additionally, the Redis database supports a variety of different manners of sorting. To ensure efficiency, data is cached in memory.
According to the embodiment of the invention, the account information of the account stored in the service database is cached in the Redis database, and the Redis database has the characteristics of high concurrency, atomic operation and the like, so that the transaction processing is executed based on the account information of the account cached in the Redis database, the processing pressure and the bottleneck of the service database can be greatly reduced, and the efficiency and the real-time performance of the transaction processing can be improved.
The following describes a transaction data processing method provided by an embodiment of the present invention with reference to an example:
step a1, caching the account balance into the Redis database when the system is started.
In the embodiment of the present invention, the system may be an accounting system storing a business database.
Step a2, receiving the transaction request, and judging whether the account is available and the account balance is sufficient through the account information cached in the Redis database.
And step a3, if the account is available and the account balance is enough, performing transaction warehousing, and simultaneously updating the account balance stored in the Redis database.
And step a4, returning the processing result and the account balance to the caller.
The caller, that is, the sender of the transaction request, may be a client or a server.
Step a5, the system initiates summary posting every preset time (for example, 10 seconds).
In the embodiment of the present invention, the system may collect the accounting detail information that does not participate in updating the account balance of the service database every preset time (for example, 10 seconds), and update the account balance of the service database based on the collected accounting detail information.
The transaction data processing method provided by the embodiment of the invention can not directly operate the records of the service database, the account balance is loaded to the Redis cache when the system is started, the balance is updated by utilizing the characteristics of high concurrency, atomic operation and the like of the Redis, and the service database is operated when the batch accounting is pending, so that the pressure and the bottleneck of the service database can be greatly reduced. In addition, the timing summary detail is posted, so that the operation condition of the database can be greatly reduced, the deadlock of the resource competition database is avoided, and the use efficiency of the database is improved. In addition, the transaction can be processed in real time, the result and the account balance can be returned, the subsequent processing pressure of the calling party can be reduced, the calling party does not need to wait and request for inquiring the result for multiple times, the transaction processing time can be saved, and the transaction processing efficiency is improved.
Referring to fig. 3, fig. 3 is a block diagram of a transaction data processing apparatus according to an embodiment of the present invention. As shown in fig. 3, the transaction data processing apparatus 300 includes: a caching module 301, a transaction processing module 302, and a billing module 303, wherein:
the caching module 301 is configured to cache account information of an account stored in the service database into the memory database;
a transaction processing module 302, configured to execute transaction processing according to the account information of the first account cached in the memory database;
and the accounting module 303 is configured to perform buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
Optionally, the accounting information of the transaction processing includes an account balance after the first account is updated and cached in the memory database;
referring to fig. 4, the accounting module 303 includes:
a reading unit 3031, configured to read, if a time length for updating the account balance of the first account in the service database at the previous time reaches a first preset time length, the updated account balance of the first account cached in the memory database;
a first updating unit 3032, configured to update the account balance of the first account in the service database according to the updated account balance of the first account cached in the in-memory database.
Optionally, the transaction processing accounting information includes the transaction processing accounting detail information;
referring to fig. 5, the accounting module 303 includes:
a summarizing unit 3033, configured to summarize the recorded accounting detail information if the number of the recorded accounting detail information reaches a preset number, or a time length from a previous time of updating the account balance of the first account in the service database reaches a second preset time length;
a second updating unit 3034, configured to update the account balance of the first account in the service database based on the summarized billing detail information.
Optionally, referring to fig. 6, the transaction processing module 302 includes:
a determining unit 3021, configured to determine, if a transaction request for a first account of the accounts is received, whether a transaction processing condition is satisfied according to account information of the first account cached in the memory database;
a third updating unit 3022, configured to update the account balance of the first account cached in the memory database and record accounting information of transaction processing if it is determined that the transaction processing condition is met, and return the updated account balance of the first account to the sending end of the transaction request.
Optionally, the cache module is specifically configured to:
and caching account information of the hot account stored in the service database into a memory database, wherein the hot account is an account with the operation frequency more than or equal to the preset times.
Optionally, referring to fig. 7, the apparatus further includes:
the query module 304 is configured to, after the account information of the account stored in the service database is cached in the memory database, query the account balance of the second account from the memory database if a query request for the second account is received, and return the queried account balance of the second account to the sending end of the query request.
Optionally, the memory database includes a Redis database.
The transaction data processing apparatus 300 provided in the embodiment of the present invention can implement each process in the method embodiments of fig. 1 to fig. 2, and is not described herein again to avoid repetition.
The transaction data processing device 300 of the embodiment of the present invention includes a cache module 301, configured to cache account information of an account stored in a service database into a memory database; a transaction processing module 302, configured to execute transaction processing according to the account information of the first account cached in the memory database; and the accounting module 303 is configured to perform buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing. The real-time performance of transaction processing can be improved, and the operation frequency of the service database can be reduced.
Referring to fig. 8, fig. 8 is a block diagram of a transaction data processing device according to another embodiment of the present invention, and as shown in fig. 8, the transaction data processing device 800 includes: a processor 801, a memory 802 and a computer program stored on the memory 802 and executable on the processor, the various components in the transaction data processing device 800 being coupled together by a bus interface 803, the computer program when executed by the processor 801 implementing the steps of:
caching account information of an account stored in a service database into a memory database;
executing transaction processing according to the account information of the first account cached in the memory database;
and carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing.
Optionally, the accounting information of the transaction processing includes an account balance after the first account is updated and cached in the memory database;
the computer program is further adapted to realize the following steps when executed by the processor 801:
if the time length from the previous time of updating the account balance of the first account in the service database reaches a first preset time length, reading the updated account balance of the first account cached in the memory database;
and updating the account balance of the first account in the service database according to the updated account balance of the first account cached in the memory database.
Optionally, the transaction processing accounting information includes the transaction processing accounting detail information;
the computer program is further adapted to realize the following steps when executed by the processor 801:
if the recorded accounting detail information reaches a preset amount, or the time from the previous updating of the account balance of the first account in the service database reaches a second preset time, summarizing the recorded accounting detail information;
and updating the account balance of the first account in the service database based on the summarized accounting detail information.
Optionally, the computer program is further configured to, when executed by the processor 801, implement the following steps:
if a transaction request aiming at a first account in the accounts is received, judging whether a transaction processing condition is met according to the account information of the first account cached in the memory database;
if the transaction processing condition is determined to be met, updating the account balance of the first account cached in the memory database and recording accounting information of transaction processing, and returning the updated account balance of the first account to the sending end of the transaction request.
Optionally, the computer program is further configured to, when executed by the processor 801, implement the following steps:
and caching account information of the hot account stored in the service database into a memory database, wherein the hot account is an account with the operation frequency more than or equal to the preset times.
The optional computer program, when executed by the processor 801, is further adapted to implement the steps of:
after the account information of the account stored in the service database is cached in the memory database, if a query request for a second account is received, the account balance of the second account is queried from the memory database, and the queried account balance of the second account is returned to a sending end of the query request.
Optionally, the memory database includes a Redis database.
Optionally, an embodiment of the present invention further provides a transaction data processing apparatus, including a processor 801, a memory 802, and a computer program stored in the memory 802 and capable of running on the processor 801, where the computer program, when executed by the processor 801, implements each process of the foregoing transaction data processing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above transaction data processing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.
Claims (10)
1. A method of transaction data processing, the method comprising:
caching account information of an account stored in a service database into a memory database, wherein the account information comprises an account name, an account balance and an account state of the account;
executing transaction processing according to the account information of the first account cached in the memory database;
according to the accounting information of the transaction processing, carrying out buffering accounting processing on the first account in the service database;
the executing transaction processing according to the account information of the first account cached in the memory database includes: under the condition of receiving a transaction request aiming at a first account, reading account information of the first account from a memory database, calculating the account balance of the first account in a system memory according to the account information of the first account and the transaction request, and updating the account balance of the first account cached in the memory database through the calculated account balance of the first account.
2. The method of claim 1, wherein the accounting information for the transaction processing includes an updated account balance of the first account cached in the in-memory database;
the buffer accounting processing is performed on the first account in the service database according to the accounting information of the transaction processing, and the buffer accounting processing comprises the following steps:
if the time length from the previous time of updating the account balance of the first account in the service database reaches a first preset time length, reading the updated account balance of the first account cached in the memory database;
and updating the account balance of the first account in the service database according to the updated account balance of the first account cached in the memory database.
3. The method of claim 1, wherein the billing information for the transaction processing includes billing details for the transaction processing;
the buffer accounting processing is performed on the first account in the service database according to the accounting information of the transaction processing, and the buffer accounting processing comprises the following steps:
if the recorded accounting detail information reaches a preset amount, or the time from the previous updating of the account balance of the first account in the service database reaches a second preset time, summarizing the recorded accounting detail information;
and updating the account balance of the first account in the service database based on the summarized accounting detail information.
4. The method of claim 1, wherein performing transaction processing based on the account information of the first account cached in the in-memory database comprises:
if a transaction request aiming at a first account in the accounts is received, judging whether a transaction processing condition is met according to the account information of the first account cached in the memory database;
if the transaction processing condition is determined to be met, updating the account balance of the first account cached in the memory database and recording accounting information of transaction processing, and returning the updated account balance of the first account to the sending end of the transaction request.
5. The method according to any one of claims 1 to 4, wherein caching the account information of the account stored in the service database into the in-memory database comprises:
and caching account information of the hot account stored in the service database into a memory database, wherein the hot account is an account with the operation frequency more than or equal to the preset times.
6. The method according to any one of claims 1 to 4, wherein after the account information of the account stored in the service database is cached in the in-memory database, the method further comprises:
and if a query request aiming at a second account is received, querying the account balance of the second account from the memory database, and returning the queried account balance of the second account to a sending end of the query request.
7. The method of any of claims 1 to 4, wherein the in-memory database comprises a Redis database.
8. A transaction data processing apparatus, characterized in that the apparatus comprises:
the cache module is used for caching account information of the account stored in the service database into a memory database, wherein the account information comprises an account name, an account balance and an account state of the account;
the transaction processing module is used for executing transaction processing according to the account information of the first account cached in the memory database;
the accounting module is used for carrying out buffering accounting processing on the first account in the service database according to the accounting information of the transaction processing;
the transaction processing module is specifically configured to: under the condition of receiving a transaction request aiming at a first account, reading account information of the first account from a memory database, calculating the account balance of the first account in a system memory according to the account information of the first account and the transaction request, and updating the account balance of the first account cached in the memory database through the calculated account balance of the first account.
9. A transaction data processing arrangement comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the transaction data processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the transaction data processing method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810697278.7A CN110659971B (en) | 2018-06-29 | 2018-06-29 | Transaction data processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810697278.7A CN110659971B (en) | 2018-06-29 | 2018-06-29 | Transaction data processing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110659971A CN110659971A (en) | 2020-01-07 |
CN110659971B true CN110659971B (en) | 2021-04-27 |
Family
ID=69027641
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810697278.7A Active CN110659971B (en) | 2018-06-29 | 2018-06-29 | Transaction data processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110659971B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113535374A (en) * | 2020-04-15 | 2021-10-22 | 马上消费金融股份有限公司 | Service index processing method and device |
CN113220730B (en) * | 2021-05-28 | 2024-03-26 | 中国农业银行股份有限公司 | Service data processing system |
CN113781034B (en) * | 2021-09-29 | 2024-04-30 | 上海瀚之友信息技术服务有限公司 | Billing and checking method based on cache |
CN114820206A (en) * | 2022-06-07 | 2022-07-29 | 未鲲(上海)科技服务有限公司 | Data updating method, device, equipment and storage medium |
CN116051117A (en) * | 2023-03-07 | 2023-05-02 | 天津金城银行股份有限公司 | Control method and device for balance of hot spot account and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101620703A (en) * | 2008-07-04 | 2010-01-06 | 阿里巴巴集团控股有限公司 | Buffer bookkeeping method and device |
CN106303428A (en) * | 2016-08-18 | 2017-01-04 | 杭州蛮牛科技有限公司 | A kind of security protection cloud platform |
CN106952158A (en) * | 2017-03-17 | 2017-07-14 | 证通股份有限公司 | Solve the problems, such as the bookkeeping methods and equipment of focus account |
CN107016604A (en) * | 2017-02-22 | 2017-08-04 | 阿里巴巴集团控股有限公司 | Buffer method, device and the equipment of book keeping operation |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140075026A1 (en) * | 2012-09-13 | 2014-03-13 | Lung Cheng Technology Ltd. | Cloud database management method |
CN105808905B (en) * | 2014-12-30 | 2019-04-02 | 金蝶软件(中国)有限公司 | Remaining sum calculation method and device |
-
2018
- 2018-06-29 CN CN201810697278.7A patent/CN110659971B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101620703A (en) * | 2008-07-04 | 2010-01-06 | 阿里巴巴集团控股有限公司 | Buffer bookkeeping method and device |
CN106303428A (en) * | 2016-08-18 | 2017-01-04 | 杭州蛮牛科技有限公司 | A kind of security protection cloud platform |
CN107016604A (en) * | 2017-02-22 | 2017-08-04 | 阿里巴巴集团控股有限公司 | Buffer method, device and the equipment of book keeping operation |
CN106952158A (en) * | 2017-03-17 | 2017-07-14 | 证通股份有限公司 | Solve the problems, such as the bookkeeping methods and equipment of focus account |
Also Published As
Publication number | Publication date |
---|---|
CN110659971A (en) | 2020-01-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110659971B (en) | Transaction data processing method and device | |
CN105827706B (en) | Message pushing device and method | |
CN111798296A (en) | Automatic account checking method, automatic account checking device and computer readable storage medium | |
CN108984553B (en) | Caching method and device | |
CN102780603B (en) | Web traffic control method and device | |
CN112637305B (en) | Data storage and query method, device, equipment and medium based on cache | |
CN109842621B (en) | Method and terminal for reducing token storage quantity | |
CN111159219B (en) | Data management method, device, server and storage medium | |
CN110737857A (en) | back-end paging acceleration method, system, terminal and storage medium | |
CN112988812B (en) | Inventory data processing method, device, equipment and storage medium | |
CN114358923A (en) | Business data processing method and device, storage medium and electronic equipment | |
CN106709805B (en) | User income data acquisition method and system | |
CN110233843B (en) | User request processing method and device | |
CN110992116A (en) | Electronic invoice generation method, device, equipment and storage medium based on ETC system | |
CN114218471A (en) | Data query method, device, system, electronic equipment and storage medium | |
CN111143365B (en) | Data sub-table method, device, computer equipment and storage medium | |
CN111242621B (en) | Transaction data storage method, device, equipment and storage medium | |
CN113360210A (en) | Data reconciliation method and device, computer equipment and storage medium | |
CN110782310B (en) | Method, device and system for asynchronously acquiring user attribute information from third-party platform | |
CN111259053A (en) | Bill inquiry method and device | |
CN107896246A (en) | Message dissemination system based on XBRL | |
CN111274203B (en) | System and method for storing telephone bill | |
CN107025266B (en) | Service data processing method and device | |
CN114385267B (en) | Data pushing method for cash transaction service | |
CN112860739A (en) | Hotspot data processing method and device, service processing system and storage medium |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |