CN106934025B - Account data management method and device and server - Google Patents

Account data management method and device and server Download PDF

Info

Publication number
CN106934025B
CN106934025B CN201710148682.4A CN201710148682A CN106934025B CN 106934025 B CN106934025 B CN 106934025B CN 201710148682 A CN201710148682 A CN 201710148682A CN 106934025 B CN106934025 B CN 106934025B
Authority
CN
China
Prior art keywords
transaction
data
cache
updating
account
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
Application number
CN201710148682.4A
Other languages
Chinese (zh)
Other versions
CN106934025A (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.)
Alibaba China Co Ltd
Original Assignee
Alibaba China Co 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 China Co Ltd filed Critical Alibaba China Co Ltd
Priority to CN201710148682.4A priority Critical patent/CN106934025B/en
Publication of CN106934025A publication Critical patent/CN106934025A/en
Application granted granted Critical
Publication of CN106934025B publication Critical patent/CN106934025B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/08Payment architectures
    • G06Q20/085Payment architectures involving remote charge determination or related payment systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Finance (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides an account data management method, an account data management device and a server. Specifically, the method comprises the following steps: synchronously updating first balance data of the account recorded in the cache according to the transaction data, and then inserting transaction flow information containing the transaction data into a management database; and when the set updating period of the management database is reached, asynchronously updating the second balance data of the account recorded in the management database according to the transaction running information inserted in the management database in the period. According to the method, a mode of combining the cache and the database is adopted, the database row lock operation is converted into the cache atomic subtraction operation and the database sequential insertion operation, the transaction efficiency is obviously improved, and the problem of low transaction efficiency caused by long time consumption of the database row lock is solved.

Description

Account data management method and device and server
Technical Field
The invention relates to the technical field of internet communication, in particular to an account data management method, an account data management device and a server.
Background
In the prior art, data of a virtual account is mostly managed through a database. When one account needs to perform transaction operation with a plurality of other accounts, because the data of the same account in the database is written, in order to ensure the accuracy of data update, a database row lock is adopted to perform serial transaction, that is, each write operation updates the service data of the account recorded in the database only according to the transaction data between the account and the other accounts. However, the slow access speed of the database and the long time consumption of the database row lock lead to low efficiency of transaction operation between accounts. For example, transaction efficiency can only reach 200 times per second, calculated as 5 milliseconds for each database row lock. Therefore, there is a need for an efficient and reliable account data management mechanism to improve the efficiency of transactions between accounts.
Disclosure of Invention
The invention aims to provide an account data management method, an account data management device and a server, so as to solve the problems.
The preferred embodiment of the invention provides an account data management method, which comprises the following steps:
updating first balance data of a first account recorded in a cache according to transaction data of the first account and a second account;
inserting transaction flow information containing the transaction data into a management database, wherein second balance data of the first account are recorded in the management database;
and when the set updating period of the management database is reached, updating the second balance data according to the transaction flow information inserted in the management database in the period.
Another preferred embodiment of the present invention provides an account data management apparatus, including:
the cache updating module is used for updating the first balance data of the first account recorded in a cache according to the transaction data of the first account and the second account;
the data insertion module is used for inserting transaction flow information containing the transaction data into a management database, and second balance data of the first account are recorded in the management database;
and the database updating module is used for updating the second balance data according to the transaction flow information inserted in the management database in the set updating period of the management database.
Another preferred embodiment of the present invention provides a server, including:
a memory;
a processor; and
an account data management apparatus comprising one or more modules stored in the memory and executed by the processor, the account data management apparatus comprising:
the cache updating module is used for updating the first balance data of the first account recorded in a cache according to the transaction data of the first account and the second account;
the data insertion module is used for inserting transaction flow information containing the transaction data into a management database, and second balance data of the first account are recorded in the management database;
and the database updating module is used for updating the second balance data according to the transaction flow information inserted in the management database in the set updating period of the management database.
In the account data management method, the device and the server provided by the preferred embodiment of the invention, the first balance data of the first account is recorded by adopting the cache, and the second balance data of the first account is recorded by adopting the management database. The initial value of the first balance data is the same as the initial value of the second balance data. Then, when the transaction operation is performed between the first account and another account (the second account), the first balance data in the cache is synchronously updated in real time according to the transaction data. And updating every pair of caches once, and inserting transaction flow information containing the transaction data corresponding to the updating in the management database. And when a set updating period is reached (for example, the number of times of inserting transaction running information reaches a preset threshold), performing one-time asynchronous updating on the second balance data of the first account recorded in the management database, calculating and recording new second balance data of the first account after asynchronous updating. And when the next asynchronous update is carried out, calculating and updating according to the new second balance data obtained after the update and the transaction running information inserted in the management database in an update period.
The preferred embodiment of the invention adopts a mode of combining the cache and the management database, converts the database row lock operation into the read-write operation of the cache and the sequential insertion operation of the database, and solves the problem of low transaction efficiency caused by long time consumption of the database row lock. And after the cache is updated successfully, the management database is inserted into the transaction flow information in sequence. And when the set updating period is reached, triggering an asynchronous updating operation, calculating the total amount of the transaction and updating the second balance data in the management database. In other words, the real-time balance of the first account is recorded in the cache, the final balance of the first account is stored in the management database, and the mode of cache synchronous updating and asynchronous updating of the management database can realize higher account transaction efficiency.
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 embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic block diagram of a first application server according to an embodiment of the present invention;
fig. 2 is an interaction diagram of a server cluster according to an embodiment of the present invention;
fig. 3 is a schematic block diagram of a second application server in the server cluster according to an embodiment of the present invention;
fig. 4 is a flowchart of an account data management method according to an embodiment of the present invention;
FIG. 5 is a flowchart of another account data management method according to an embodiment of the present invention;
fig. 6 is a functional block diagram of an account data management apparatus according to an embodiment of the present invention;
fig. 7 is a functional block diagram of another account data management apparatus according to an embodiment of the present invention.
Reference numerals: 100-a first application server; 110 — an internal memory; 120-external memory; 130-a first processor; 140-account data management means; 112-a first cache; 122-a first management database; 200-a second application server; 300-a database server; 400-a cache server; 302-a second management database; 402-a second cache; 210-a memory; 220-a second processor; 1402-cache update module; 1404-a data insertion module; 1406-an insertion detection module; 1408-a balance recovery module; 1410-period detection module; 1412-database update module; 1414-cache lock detection module; 1416-balance detection module; 1418-cache lock setting module; 1420-balance correction module; 1422-cache lock release module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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, but not all, embodiments of the present invention.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the 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.
Fig. 1 is a block diagram illustrating a first application server 100 of an application account data management method according to an embodiment of the present invention. The first application server 100 may be, but is not limited to, a web server, a database server, and the like. As shown in fig. 1, the first application server 100 includes an internal memory 110, an external memory 120, a first processor 130, and an account data management device 140.
A buffer (hereinafter, referred to as a first buffer 112) for temporarily storing account service data is opened in the internal memory 110. The first cache 112 may be, but is not limited to, a memory space located in a main memory (a memory bank) or a cache memory or even a register. The external memory 120 stores therein a first management database 122 for permanently storing account transaction data. The external memory 120 may be, but is not limited to, an SSD solid state disk, a floppy disk, an optical disk, and the like. The first management database 122 may be, but is not limited to, a redis database, a mysql database, an oracle database, and the like.
The internal memory 110, the external memory 120 and the first processor 130 are directly or indirectly electrically connected to each other to realize data transmission or interaction, for example, the first processor 130 may selectively access the first cache 112 or the first management database 122. The account data management device 140 includes at least one software function module which can be stored in the internal memory 110 or the external memory 120 in the form of software or firmware, or solidified in the operating system of the first application server 100. The first processor 130 is configured to execute an executable module stored in the internal memory 110 or the external memory 120, such as a software functional module or a computer program included in the account data management apparatus 140.
Please refer to fig. 2, which is an interaction diagram of a server cluster applying the account data management method according to an embodiment of the present invention. The server cluster includes a second application server 200 and a database server 300 and a cache server 400 interacting with the second application server 200 over a network.
Wherein, the database server 300 includes a second management database 302 for permanently storing account service data. The cache server 400 includes a second cache 402 for temporarily storing account service data. The cache server 400 may be, but is not limited to, a memory object based distributed cache system, such as a Memcached server. The second application server 200 is communicatively coupled to a database server 300 for accessing the second management database 302. The second application server 200 is communicatively coupled to a cache server 400 for accessing the second cache 402.
Fig. 3 is a block diagram of the second application server 200 according to an embodiment of the present invention. The second application server 200 includes a memory 210, a second processor 220, and the account data management device 140. The memory 210 is used for storing software functional modules included in the account data management device 140. The second processor 220 is used for executing executable modules stored in the memory 210, such as software functional modules or computer programs included in the account data management device 140.
Of course, it is understood that the application scenarios provided above are only exemplary and do not specifically limit the application scope of the account data management method. For example, in other embodiments, the server cluster may also include only the second application server 200 and the distributed cache server 400. Wherein, the memory 210 of the second application server 200 carries a database which can be used for permanently recording account service data.
Referring to fig. 4, a schematic flowchart of an account data management method according to an embodiment of the present invention is shown, and is applied to the first application server 100 shown in fig. 1 or the second application server 200 shown in fig. 2. It should be noted that the method provided by the present invention is not limited by the specific sequence shown in fig. 4 and described below. The steps shown in fig. 4 are explained in detail below.
Step S101: and updating the first balance data of the first account recorded in the cache according to the transaction data of the first account and the second account.
In this embodiment, the management database described below may be the first management database 122 shown in fig. 1 or the second management database 302 shown in fig. 2. The cache described below may be the first cache 112 shown in fig. 1 or the second cache 402 shown in fig. 2. The management database and the cache are both recorded with business data related to the first account. In detail, the first balance data of the first account is recorded in the cache, and is updated synchronously in real time along with the transaction operation between the first account and other accounts (collectively referred to as a second account different from the first account in the embodiment). And the second balance data of the first account is recorded in the management database, and is in an asynchronous updating mode, namely asynchronous updating is carried out every other set updating period. The set update period may be, but is not limited to, a preset number of times (e.g., 100 times) that the first account and the second account are transacted each other is an update period, or a set duration (e.g., 24 hours) is an update period.
It will be appreciated that, in general, the initial value of the first balance data recorded in the cache is the same as the initial value of the second balance data recorded in the management database. Then, when the application server (the first application server 100 or the second application server 200, the same below) receives a transaction request between the first account and the second account, the first balance data in the cache is updated synchronously according to the transaction data corresponding to the request. The transaction data includes, but is not limited to, a transaction amount. During a period of time after the first balance data is updated, the second balance data currently recorded in the management database may be different from the first balance data of the cache record because the management database has not been updated.
It should be noted that, in this embodiment, the transaction operation may refer to a deduction operation or an addition operation on the first account. Specifically, the deduction operation may refer to subtracting a certain transaction amount from the first balance data of the first account and adding a corresponding transaction amount to the second account. The adding operation may refer to adding a certain transaction amount to the first balance data of the first account and deducting the corresponding transaction amount from the second account.
Step S103, transaction flow information containing the transaction data is inserted into the management database.
In this embodiment, each time a transaction is performed between the first account and a second account, corresponding transaction flow information may be sequentially inserted into the management database, so as to be used for performing subsequent asynchronous update on the second balance data of the first account recorded in the management database. The transaction flow information may include a flow number, the transaction amount, transaction time, information of the first account, information of the second account, and the like.
Step S105, detecting whether the transaction flow information is inserted successfully.
In this embodiment, in order to ensure the reliability and accuracy of data update, the whole transaction operation is considered to be successful only after the transaction flow information is successfully inserted.
If the insertion fails, the following step S107 is executed. If the insertion is successful, the following step S109 is executed.
And step S107, restoring the first balance data recorded in the cache to the value before the updating.
In this embodiment, as an implementation manner, when the cache is a buffer area opened in a memory or a cache system (e.g., Memcached) based on a memory object, the atomicity operation of the cache may be used to update the first balance data recorded in the cache.
Of course, it is understood that in other embodiments, if the accuracy of data execution can be ensured, the steps S105 and S107 may be omitted in other embodiments, i.e., the step S103 may directly proceed to the step S109 described below. In other words, these two steps are preferred, but not necessary.
Step S109, detecting whether the set update period is reached, if so, executing step S111, otherwise, ending the process.
In this embodiment, the update period may be set in various manners, for example, different period criteria may be set based on one or more of transaction times, transaction duration, or total transaction amount.
In one embodiment, the update period is exemplified as a number of transactions between the first account and the second account reaching a preset threshold (e.g. 100). The manner of detecting whether the set update period is reached may be: and judging whether the total times of inserting transaction running water information in the time period from the latest asynchronous updating of the management database to the current time period is equal to the preset threshold value or not, and if so, judging that the set updating period is reached. Particularly, when the second balance data of the first account recorded in the management database is not asynchronously updated (before the first update), it may be directly determined whether the total number of times of inserting transaction flow information in the period from the first time of inserting transaction flow information into the management database to the current time is equal to the preset threshold, and if so, it is determined that the set update period has been reached. In more detail, in implementation, a cache counter (e.g., a record entry stored in a cache for counting) may be used to count the number of transactions. The initial value of the buffer counter is a preset threshold value, and the numerical value of the buffer counter is reduced by one when one piece of transaction running water information is inserted into the management database. The data inserted into the management database (including the inserted transaction running information and the record entry inserted after asynchronous update for recording the current second balance data of the first account) may correspond to a unique ID added in the order of insertion into the management database. And when the numerical value of the cache counter is zero, acquiring the ID of the record entry inserted after the last asynchronous update, and then inquiring transaction flow information corresponding to the ID larger than the acquired ID to asynchronously update the first account.
As another embodiment, the update period is exemplified by every preset time period (e.g., 24 hours or 12 hours). The manner of detecting whether the set update period is reached may be: and judging whether the time interval from the current time to the latest asynchronous updating reaches a preset time length, and if so, judging that the set updating period is reached. Particularly, when the second balance data of the first account recorded in the management database is not asynchronously updated (before the first update), whether a time interval from the current time to the time when the second balance data of the first account is recorded in the management database for the first time reaches a preset time length is judged, and if so, a set update period is judged to have reached. The set form of the update period is generally suitable for a management database with sparse transaction, and is equivalent to that the data of the account is periodically updated in a passive asynchronous update mode.
Step S111, updating the second balance data recorded in the management database according to the transaction running information inserted in the management database in the period, and obtaining and recording the updated second balance data of the first account.
In detail, in an embodiment, the specific process of asynchronously updating the second balance data recorded in the management database every other update period is as follows: firstly, calculating the sum of transaction amounts contained in all transaction flow information inserted in a management database in the updating period to obtain the total transaction amount; then, subtracting the calculated total transaction amount from the second balance data of the first account recorded in the management database to obtain updated second balance data; and finally, recording the updated second balance data in the management database.
It will be appreciated that in other embodiments, the second balance data may also be recorded after each update. In this way, when the management database is asynchronously updated, the calculated total transaction amount may be "subtracted" from the second balance data of the first account recorded in the management database last time, so as to obtain and record the updated second balance data.
It should be noted that, in order to update the second balance data by using the "subtraction" operation when the second balance data is asynchronously updated, in this embodiment, when the subtraction operation is performed on the first account, the transaction amount included in the corresponding transaction flow information should be a positive value, and when the addition operation is performed on the first account, the transaction amount included in the corresponding transaction flow information should be a negative value.
Please refer to fig. 5, which is a flowchart illustrating another account data management method according to an embodiment of the present invention. Different from the above, the method further comprises the following steps:
step S201: this step may be performed before step S101, and specifically, the step is to detect whether a cache lock set for the cache exists. If yes, the deduction process is directly ended, and if not, the following step S203 is executed.
In this embodiment, in order to ensure the reliability and accuracy of updating the cache data, a cache lock needs to be set when the data in the cache is maintained, so as to prevent the cache data from being distorted due to transaction operation during the cache maintenance. Therefore, when the first account and the second account perform a transaction operation, it is first detected whether the cache lock is set in the cache, and if not, the subsequent transaction operation can be performed.
In this embodiment, the maintaining of the cached data may refer to a process of correcting the data in the management database according to the data in the management database when the data in the cache is distorted due to a power failure, a restart, and the like, but is not limited thereto.
Step S203, detecting whether the first balance data recorded in the cache is smaller than the transaction amount included in the transaction data.
This step is applicable to the process of deducting the first account. Before deduction is performed on the first balance data of the first account recorded in the cache, whether the first balance data is smaller than the transaction amount needs to be detected. If the value is less than the predetermined value, it indicates that there may be distortion in the data in the buffer, and the following steps S205 to S209 may be performed to try to correct the distortion. If the transaction data is greater than or equal to the transaction data, the step S101 is directly executed.
Step S205, setting a cache lock for the cache, and updating the second balance data of the first account recorded in the management database according to the transaction flow information inserted in the management database in an interval from the time when the management database is asynchronously updated last time to the current time.
Step S207, the first balance data recorded in the cache is corrected by the second balance data of the first account obtained after asynchronous updating in step S205.
In this embodiment, the "rectification" may be understood as updating the distorted first balance data recorded in the cache to the asynchronously updated second balance data obtained in step S205.
Step S209, release the cache lock. And after the step, updating the corrected first balance data according to the transaction data.
It should be emphasized that the situation that the first balance data in the cache is not enough to reduce the non-data distortion is not the key point considered by the embodiment of the present invention, but does not exist, and when the situation occurs, a cache lock is set for the cache and a corresponding cache data maintenance measure is taken.
The account data management method provided by the present embodiment is further described below with a specific example.
One core function of the currently online running gold coin system is to issue gold coins to the C-side account before or during the activity, i.e. deducting the gold coins of the B-side account and adding the gold coins to a plurality of C-side accounts. The terminal B account is a department budget account and corresponds to the first account. The account number of the C terminal is a common user account and corresponds to the second account. The existing implementation mode is to adopt a database row lock to carry out deduction operation of the B-side account so as to ensure the reliability and accuracy of account data updating. However, the database row lock takes a long time, and the deduction efficiency can only reach 200 times per second at most according to 5 milliseconds of the time taken by each database row lock, so that the gold coin issuing performance of the B-side account in the gold coin system is low.
By adopting the account data management method provided by the embodiment, the gold coin issuing performance of the account at the B end of the gold coin system can be effectively improved. Without loss of generality, based on the application scenario shown in fig. 2, a single B-side account is taken as an example for explanation. The second application server 200 is a background server of the gold coin system, and the cache server 400 is a Memcached server. The second management database 302 stores the second balance data of the B-side account. The second cache 402 stores therein first balance data of the B-side account in the form of a key-value pair. Initially, the second balance data recorded in the second management database 302 is the same as the first balance data recorded in the second cache 402.
In addition, a counter is created in the second cache 402 in the form of a key-value pair, and the initial value of the counter is a preset threshold (e.g. 100), and the counter is decreased by one every time the B-side account transacts with the C-side account. When the counter is zeroed, an asynchronous update operation to the second management database 302 is triggered. Then, the counter is reinitialized to the preset threshold.
Assuming that the B-side account starts to issue coins to a certain C-side account, the specific implementation flow is as follows. First, whether a cache lock exists is detected, and if so, it indicates that the second cache 402 is in maintenance, and this deduction cannot be completed, and the process is ended directly. If the cache lock does not exist, whether the first balance data in the second cache 402 is larger than or equal to the deduction limit (the limit of the gold coin issued to the C-terminal account) is detected. If the current deduction limit is larger than or equal to the current deduction limit, executing deduction operation, namely updating the first balance data in the second cache 402 according to the deduction limit, inserting corresponding transaction flow information into the second management database 302, and subtracting one from the counter. If the balance is smaller than the deduction limit, setting a cache lock and correcting the first balance data in the second cache 402 according to the service data recorded in the second management database 302. A specific correction manner may be to check whether transaction flow information is inserted in the second management database 302 from the latest asynchronous update to the current time interval. If so, the current accurate first balance data is calculated by asynchronous updating so as to correct the data in the second cache 402 according to the current accurate first balance data. If not, the first balance data in the second cache 402 is corrected directly according to the second balance data of the B-side account recorded last time. And after the correction is finished, executing deduction operation.
After the deduction operation is executed, whether the counter returns to zero or not is detected, if the counter returns to zero, the counter is reset to the preset threshold value, and asynchronous updating operation on the second management database 302 is triggered to obtain new second balance data of the updated first account.
It should be noted that in this example, the transaction flow information inserted into the second management database 302 may include, in addition to the flow identifying the transaction amount subtracted from the B-side account, a flow identifying the transaction amount added to the C-side account and a flow after the C-side account updates the balance.
In this example, the second management database 302 may be supported by an SSD hard disk. Thus, it allows sequential insertions at a rate of up to 20000 times/second. And the atomic subtraction operation of the Memcached cache can reach 20 ten thousand times/second. Therefore, if 3 serial records are inserted into the second management database 302 in sequence according to the requirement of each transaction operation, the gold currency issuing performance of the B-side account can reach at least 6000 pens/second.
Please refer to fig. 6, which is a functional block diagram of an account data management apparatus 140 according to an embodiment of the present invention. The account data management apparatus 140 includes a cache update module 1402, a data insertion module 1404, an insertion detection module 1406, a balance recovery module 1408, a period detection module 1410, and a database update module 1412.
The cache updating module 1402 is configured to update the first balance data of the first account recorded in the cache according to the transaction data of the first account and the second account.
The data inserting module 1404 is configured to insert transaction flow information including the transaction data into the management database.
The insertion detection module 1406 is configured to detect whether the transaction flow information is inserted successfully.
The balance recovery module 1408 is configured to, when it is determined that the transaction running information insertion fails, recover the first balance data recorded in the cache to the value before the current update.
The period detection module 1410 is configured to detect whether a set update period is reached when it is determined that the transaction flow information is successfully inserted.
The database updating module 1412 is configured to update the second balance data of the first account according to the transaction flow information inserted in the management database in the set update period when the set update period is reached.
The detailed description of the corresponding steps in the above method embodiments can be referred to for the specific operation method of each functional module in this embodiment, and is not repeated here.
Please refer to fig. 7, which is a functional block diagram of another account data management apparatus 140 according to the present embodiment. Different from the above, the apparatus further includes a cache lock detection module 1414, a balance detection module 1416, a cache lock setting module 1418, a balance remediation module 1420, and a cache lock release module 1422.
The cache lock detection module 1414, executed before the cache update module 1402, is configured to detect whether a cache lock exists; if not, the balance detection module 1416 is executed.
The balance detection module 1416 is configured to detect whether the first balance data recorded in the cache is smaller than a transaction amount included in the transaction data.
The cache lock setting module 1418 is configured to set a cache lock on the cache when the first balance data is less than the transaction amount.
The balance correction module 1420 is configured to, after the database updating module 1412 updates the second balance data in the management database, correct the first balance data recorded in the cache according to the obtained updated second balance data.
The cache lock releasing module 1422 is configured to release the cache lock after the correction is completed.
The detailed description of the corresponding steps in the above method embodiments can be referred to for the specific operation method of each functional module in this embodiment, and is not repeated here.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other.
In addition, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the modules is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: u disk, removable hard disk, read only memory, random access memory, magnetic or optical disk, etc. for storing program codes.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.

Claims (17)

1. A method for managing account data, the method comprising:
updating first balance data of a first account recorded in a cache according to transaction data of the first account and a second account, wherein the transaction data comprises a transaction amount;
inserting transaction flow information containing the transaction data into a management database, wherein second balance data of the first account are recorded in the management database;
when the set updating period of the management database is reached, updating the second balance data according to the transaction flow information inserted in the management database in the period;
the step of updating the second balance data according to the transaction flow information inserted in the management database in the period comprises:
calculating the sum of the transaction amounts contained in all transaction flow information inserted in the management database in the period to obtain the total transaction amount in the period;
subtracting the calculated total transaction amount from the second balance data of the first account recorded in the management database to obtain updated second balance data.
2. The method of claim 1, wherein after the step of inserting transaction flow information containing the transaction data in the management database, the method further comprises:
detecting whether the transaction flow information is inserted successfully;
if the insertion fails, restoring the first balance data to a value before the updating;
if the insertion is successful, whether the set update period of the management database is reached is detected.
3. The method of claim 2, wherein the step of detecting whether the set update period of the management database is reached comprises:
and judging whether the number of times of inserting transaction flow information in an interval from the latest updating time of the second balance data to the current time is equal to a preset threshold value or not, and if so, judging that the updating period is reached.
4. The method of claim 2, wherein the step of detecting whether the set update period of the management database is reached comprises:
and judging whether the interval from the latest updating time of the second balance data to the current time is equal to a preset time length or not, and if so, judging that the updating period is reached.
5. The method of claim 1, wherein prior to the step of updating the first balance data of the first account recorded in a cache based on transaction data of the first account and the second account, the method further comprises:
detecting whether first balance data recorded in the cache is smaller than a transaction amount included in the transaction data;
if the first balance data is larger than or equal to the transaction amount, updating the first balance data according to the transaction amount;
if the first balance data is smaller than the transaction data, setting a cache lock for the cache, and updating the second balance data recorded in the management database according to transaction flow information inserted in the management database in an interval from the latest updating time of the second balance data to the current time;
correcting the first balance data recorded in the cache through the updated second balance data;
and releasing the cache lock after the correction is finished, and updating the corrected first balance data according to the transaction data.
6. The method of claim 5, further comprising:
detecting whether a cache lock set for the cache exists;
if not, whether the first balance data recorded in the cache is smaller than the transaction amount included in the transaction data is detected.
7. An account data management apparatus, characterized in that the apparatus comprises:
the cache updating module is used for updating the first balance data of the first account recorded in a cache according to the transaction data of the first account and the second account;
the data insertion module is used for inserting transaction flow information containing the transaction data into a management database, and second balance data of the first account are recorded in the management database;
the database updating module is used for updating the second balance data according to the transaction flow information inserted in the management database in a set updating period of the management database;
the mode that the database updating module updates the second balance data according to the transaction flow information inserted in the management database in the period comprises the following steps:
calculating the sum of the transaction amounts contained in all transaction flow information inserted in the management database in the period to obtain the total transaction amount in the period;
subtracting the calculated total transaction amount from the second balance data of the first account recorded in the management database to obtain updated second balance data.
8. The apparatus of claim 7, further comprising:
the insertion detection module is used for detecting whether the transaction flow information is inserted successfully or not;
the balance recovery module is used for recovering the first balance data to a value before the updating when the transaction running information is judged to be inserted unsuccessfully;
and the period detection module is used for detecting whether the set updating period of the management database is reached or not when the transaction flow information is judged to be successfully inserted.
9. The apparatus of claim 8, wherein the means for detecting whether the set update period of the management database is reached comprises:
and judging whether the number of times of inserting transaction flow information in an interval from the latest updating time of the second balance data to the current time is equal to a preset threshold value or not, and if so, judging that the updating period is reached.
10. The apparatus of claim 8, wherein the means for detecting whether the set update period is reached comprises:
and judging whether the interval from the latest updating time of the second balance data to the current time is equal to a preset time length or not, and if so, judging that the updating period is reached.
11. The apparatus of claim 7, further comprising:
the balance detection module is used for detecting whether the first balance data recorded in the cache is smaller than the transaction amount included in the transaction data;
the cache updating module is further configured to update the first balance data of the first account according to the transaction amount when the first balance data is greater than or equal to the transaction amount;
the cache lock setting module is used for setting a cache lock for the cache when the first balance data is smaller than the transaction amount;
the database updating module is further configured to update the second balance data recorded in the management database according to transaction flow information inserted in the management database in an interval from a time when the second balance data is updated last to a current time after a cache lock is set for the cache;
the balance correction module is used for correcting the first balance data recorded in the cache through the updated second balance data;
the cache lock releasing module is used for releasing the cache lock after the correction is finished;
the cache updating module is further configured to update the corrected first balance data according to the transaction data after the cache lock is released.
12. The apparatus of claim 11, further comprising:
the cache lock detection module is used for detecting whether a cache lock set for the cache exists or not; and if the balance is not present, executing the balance detection module.
13. A server, comprising:
a memory;
a processor; and
an account data management apparatus comprising one or more modules stored in the memory and executed by the processor, the account data management apparatus comprising:
the cache updating module is used for updating the first balance data of the first account recorded in a cache according to the transaction data of the first account and the second account;
the data insertion module is used for inserting transaction flow information containing the transaction data into a management database, and second balance data of the first account are recorded in the management database;
the database updating module is used for updating the second balance data according to the transaction flow information inserted in the management database in a set updating period of the management database;
the mode that the database updating module updates the second balance data according to the transaction flow information inserted in the management database in the period comprises the following steps:
calculating the sum of the transaction amounts contained in all transaction flow information inserted in the management database in the period to obtain the total transaction amount in the period;
subtracting the calculated total transaction amount from the second balance data of the first account recorded in the management database to obtain updated second balance data.
14. The server according to claim 13, wherein the account data management means further comprises:
the insertion detection module is used for detecting whether the transaction flow information is inserted successfully or not;
the balance recovery module is used for recovering the first balance data to a value before the updating when the transaction running information is judged to be inserted unsuccessfully;
and the period detection module is used for detecting whether the set updating period of the management database is reached or not when the transaction flow information is judged to be successfully inserted.
15. The server according to claim 14, wherein the manner of the cycle detection module detecting whether the set update cycle of the management database is reached comprises:
judging whether the number of times of inserting transaction flow information in an interval from the time when the second balance data is updated last to the current time is equal to a preset threshold value or not, and if the number of times of inserting the transaction flow information in the interval is equal to the preset threshold value, judging that the updating period is reached; or
And judging whether the interval from the latest updating time of the second balance data to the current time is equal to a preset time length or not, and if so, judging that the updating period is reached.
16. The server according to claim 13, wherein the account data management means further comprises:
the balance detection module is used for detecting whether the first balance data recorded in the cache is smaller than the transaction amount included in the transaction data;
the cache updating module is further configured to update the first balance data of the first account according to the transaction amount when the first balance data is greater than or equal to the transaction amount;
the cache lock setting module is used for setting a cache lock for the cache when the first balance data is smaller than the transaction amount;
the database updating module is further configured to update the second balance data recorded in the management database according to transaction flow information inserted in the management database in an interval from a time when the second balance data is updated last to a current time after a cache lock is set for the cache;
the balance correction module is used for correcting the first balance data recorded in the cache through the updated second balance data;
the cache lock releasing module is used for releasing the cache lock after the correction is finished;
the cache updating module is further configured to update the corrected first balance data according to the transaction data after the cache lock is released.
17. The server according to claim 16, wherein the account data management means further comprises:
the cache lock detection module is used for detecting whether a cache lock set for the cache exists or not; and if the cache lock does not exist, executing the balance detection module.
CN201710148682.4A 2017-03-13 2017-03-13 Account data management method and device and server Active CN106934025B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710148682.4A CN106934025B (en) 2017-03-13 2017-03-13 Account data management method and device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710148682.4A CN106934025B (en) 2017-03-13 2017-03-13 Account data management method and device and server

Publications (2)

Publication Number Publication Date
CN106934025A CN106934025A (en) 2017-07-07
CN106934025B true CN106934025B (en) 2020-06-16

Family

ID=59433116

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710148682.4A Active CN106934025B (en) 2017-03-13 2017-03-13 Account data management method and device and server

Country Status (1)

Country Link
CN (1) CN106934025B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107798057B (en) * 2017-09-05 2019-02-01 平安科技(深圳)有限公司 Transaction data processing method, device, storage medium and computer equipment
CN108897783A (en) * 2018-06-08 2018-11-27 阿里巴巴集团控股有限公司 Accounting mode determines method, account status prediction technique, device and electronic equipment
CN109447777B (en) * 2018-11-01 2021-06-29 北京京东金融科技控股有限公司 Financial data processing method and device, electronic equipment and readable medium
CN109615514A (en) * 2018-11-27 2019-04-12 宝付网络科技(上海)有限公司 Hot spot account trading system and method
CN109670957A (en) * 2018-12-24 2019-04-23 恒生电子股份有限公司 The processing method and processing device of fictitious assets data
CN109949144A (en) * 2019-03-22 2019-06-28 深圳前海微众银行股份有限公司 Keep accounts processing method, device, equipment and computer readable storage medium
CN110175900B (en) * 2019-04-30 2023-07-11 创新先进技术有限公司 Buffer account supplementing method and device
CN112000675B (en) * 2019-05-27 2023-12-01 招商证券股份有限公司 Quotation data updating method and device, terminal equipment and storage medium
CN110942393B (en) * 2019-11-11 2023-08-15 支付宝(杭州)信息技术有限公司 Transaction processing method and device based on main account and sub account, and electronic equipment
CN113535740B (en) * 2020-04-14 2023-09-26 北京京东振世信息技术有限公司 Inventory management method and device
CN112035503B (en) * 2020-09-17 2023-09-19 中国银行股份有限公司 Transaction data updating method and device
CN113781034B (en) * 2021-09-29 2024-04-30 上海瀚之友信息技术服务有限公司 Billing and checking method based on cache

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1553393A (en) * 2003-12-29 2004-12-08 兴业银行股份有限公司 Data processing method and system for realizing bank uninterrupted service
CN101477667A (en) * 2009-01-19 2009-07-08 阿里巴巴集团控股有限公司 Transaction data processing method and system
CN102043859A (en) * 2010-12-27 2011-05-04 用友软件股份有限公司 Data updating method and device
CN105205717A (en) * 2015-11-10 2015-12-30 中国建设银行股份有限公司 Bank system transaction information management method, system and general account transfer system
CN106210021A (en) * 2016-07-05 2016-12-07 中国银行股份有限公司 The method for real-time monitoring of financial application system online business and supervising device
CN106327220A (en) * 2016-08-31 2017-01-11 无锡雅座在线科技发展有限公司 Abnormal account determination method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1553393A (en) * 2003-12-29 2004-12-08 兴业银行股份有限公司 Data processing method and system for realizing bank uninterrupted service
CN101477667A (en) * 2009-01-19 2009-07-08 阿里巴巴集团控股有限公司 Transaction data processing method and system
CN102043859A (en) * 2010-12-27 2011-05-04 用友软件股份有限公司 Data updating method and device
CN105205717A (en) * 2015-11-10 2015-12-30 中国建设银行股份有限公司 Bank system transaction information management method, system and general account transfer system
CN106210021A (en) * 2016-07-05 2016-12-07 中国银行股份有限公司 The method for real-time monitoring of financial application system online business and supervising device
CN106327220A (en) * 2016-08-31 2017-01-11 无锡雅座在线科技发展有限公司 Abnormal account determination method and device

Also Published As

Publication number Publication date
CN106934025A (en) 2017-07-07

Similar Documents

Publication Publication Date Title
CN106934025B (en) Account data management method and device and server
CN106462594B (en) System and method for massively parallel processing of database
JP2021512519A5 (en)
CN111314238B (en) Token management method and device, storage medium and electronic device
CN111260465A (en) Business processing method, device, server and storage medium
CN111966538B (en) Block chain data recovery method and device
CN102057358A (en) Systems and methods for tracking changes to a volume
CN107092628B (en) Time series data processing method and device
CN106529962A (en) Method and device used for enhancing hotspot account processing ability in trading system
CN108269184B (en) Bank institution change management method and system supporting uninterrupted service
JP2016224921A (en) Database rollback using WAL
CN111639967B (en) Product potential customer mining method and system
CN111813609A (en) Data recovery method in storage medium, data recovery system and related equipment
US11144536B2 (en) Systems and methods for real-time analytics detection for a transaction utilizing synchronously updated statistical aggregation data
CN106716369B (en) Variable timing schedule to accommodate randomly occurring event delays
CN111768205A (en) Attack transaction identification method and system
CN111339158A (en) Method and device for processing information, electronic equipment and storage medium
CN113112344B (en) Service processing method, device, storage medium and computer program product
CN111291022A (en) Data storage system based on block chain
CN113486036A (en) Virtual resource management method and device, electronic equipment and storage medium
CN106528322A (en) Methods and systems to detect silent corruption of data
JP2011158966A (en) Apparatus, method and program for processing information
CN111681008B (en) Risk control method, apparatus, device and storage medium
CN111339105B (en) Data storage method, device and server
CN113568949A (en) Test data generation method and device

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
TA01 Transfer of patent application right

Effective date of registration: 20200526

Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Alibaba (China) Co.,Ltd.

Address before: 510627 Guangdong city of Guangzhou province Whampoa Tianhe District Road No. 163 Xiping Yun Lu Yun Ping radio square B tower 13 floor 02 unit self

Applicant before: GUANGZHOU UCWEB COMPUTER TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant