CN-121981729-A - Transaction quota management and control method and device based on hash table
Abstract
The invention provides a transaction quota management and control method and device based on a hash table, and relates to the technical field of data processing, wherein the method comprises the steps of determining a transaction quota rule table, wherein each transaction quota rule in the transaction quota rule table comprises multi-dimensional scene information and quota information corresponding to the multi-dimensional scene information, and the multi-dimensional scene information comprises a payment channel, a payment mechanism code, a service type code and an account type; the method comprises the steps of creating a hash table based on a transaction limit rule table, storing multidimensional scene information and corresponding limit information in a key value pair mode, responding to a received user transaction request, analyzing the user transaction request to obtain target multidimensional scene information, inquiring the hash table based on the target multidimensional scene information to obtain target limit information corresponding to the user transaction request, checking whether transaction amount exceeds limit or not based on the target limit information, and rejecting or allowing execution of the user transaction request according to a check result.
Inventors
- HUANG LITING
- YANG MIAO
- YU GUANGHUA
Assignees
- 中国建设银行股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251215
Claims (12)
- 1. A hash table-based transaction quota management method, comprising: Determining a transaction quota rule table, wherein each transaction quota rule in the transaction quota rule table comprises multi-dimensional scene information and quota information corresponding to the multi-dimensional scene information, and the multi-dimensional scene information comprises a payment channel, a payment mechanism code, a service type code and an account type; creating a hash table based on the transaction quota rule table, wherein the hash table is used for storing the multi-dimensional scene information and the corresponding quota information in the form of key value pairs; Responding to a received user transaction request, analyzing the user transaction request to obtain target multi-dimensional scene information, and inquiring the hash table based on the target multi-dimensional scene information to obtain target quota information corresponding to the user transaction request; And checking whether the transaction amount exceeds the limit or not based on the target limit information, and refusing or allowing the user transaction request to be executed according to the checking result.
- 2. The method of claim 1, wherein creating a hash table based on the transaction limit rule table comprises: Extracting multidimensional scene information contained in the transaction limit rule as a compound key aiming at each transaction limit rule in the transaction limit rule table, and carrying out hash calculation on the compound key to obtain a hash value corresponding to the compound key; performing modular operation based on the hash value and the array length of the hash table to obtain an index value corresponding to the transaction quota rule, wherein the array length is the total number of slots of the hash table for storing key value pairs; Based on the index value, the compound key and corresponding quota information are stored in the hash table in the form of key value pairs.
- 3. The method of claim 2, wherein storing the compound key and corresponding quota information in the hash table in key-value pairs based on the index value comprises: checking whether the corresponding slot of the index value in the hash table is occupied or not; If not occupied, storing the compound key and corresponding quota information in the slot in the form of key value pairs; If the key is occupied, sequentially checking the subsequent slots based on a linear detection method, searching the first unoccupied slot, and storing the compound key and the corresponding quota information in the first unoccupied slot in the form of key value pairs.
- 4. The method of claim 3, wherein the querying the hash table based on the target multi-dimensional scene information to obtain target quota information corresponding to the user transaction request comprises: Taking the target multi-dimensional scene information as a target compound key, and carrying out hash calculation on the target compound key to obtain a target hash value; performing modular operation based on the target hash value and the array length of the hash table to obtain a target index value corresponding to the user transaction request; and inquiring the hash table based on the target index value to obtain target quota information corresponding to the user transaction request.
- 5. The method of claim 4, wherein the transaction limit rule table and the hash table are both stored in a memory, and the querying the hash table based on the target index value to obtain the target limit information corresponding to the user transaction request comprises: Locating a target slot in the hash table based on the target index value; if the target slot position is empty, determining that the user transaction request is unlimited; If the target slot is occupied and the composite key stored in the target slot is consistent with the target composite key, taking the quota information stored in the target slot as target quota information; if the target slot is occupied and the composite key stored in the target slot is inconsistent with the target composite key, traversing the subsequent slots in sequence based on a linear detection method with the step length of 1 until the consistent composite key is found and corresponding quota information is obtained as target quota information.
- 6. The method according to any one of claims 1-5, further comprising: If an updating request for the transaction limit rule table is monitored, acquiring an updated transaction limit rule table, and regenerating a complete new hash table based on the updated transaction limit rule table; After the generation of the new hash table is completed, the currently effective hash table pointer is pointed to the new hash table through the atomic operation, and the subsequently received user transaction requests are all queried based on the new hash table.
- 7. The method of claim 6, wherein if an update request for the transaction limit rule table is detected, obtaining an updated transaction limit rule table, and regenerating a complete new hash table based on the updated transaction limit rule table, comprises: If an update request for the transaction quota rule table is monitored, adding the update request to a single-thread asynchronous update queue according to a submitting sequence; and regenerating a complete new hash table according to the sequence of each update request in the single-thread asynchronous update queue sequentially based on the updated transaction quota rule table corresponding to the update request.
- 8. A method according to claim 3, characterized in that the method further comprises: monitoring a load factor of the hash table in real time, wherein the load factor is used for representing the load state of the hash table; And if the load factor is greater than a preset load factor threshold, expanding the hash table, and based on the expanded new array length, recalculating hash values and index values of all rules in the current transaction limit rule table to generate a new hash table and replacing the original hash table.
- 9. A hash table-based transaction quota management and control device, comprising: The system comprises a determining module, a transaction quota rule table, a transaction processing module and a transaction processing module, wherein each transaction quota rule in the transaction quota rule table comprises multi-dimensional scene information and quota information corresponding to the multi-dimensional scene information, and the multi-dimensional scene information comprises a payment channel, a payment mechanism code, a business type code and an account type; The creating module is used for creating a hash table based on the transaction quota rule table, and the hash table is used for storing the multi-dimensional scene information and the corresponding quota information in the form of key value pairs; The inquiry module is used for responding to the received user transaction request, analyzing the user transaction request to obtain target multi-dimensional scene information, inquiring the hash table based on the target multi-dimensional scene information, and obtaining target quota information corresponding to the user transaction request; and the execution module is used for checking whether the transaction amount exceeds the limit or not based on the target quota information, and refusing or allowing to execute the user transaction request according to the checking result.
- 10. An electronic device, comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
- 11. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-8.
- 12. A computer program product comprising a computer program which, when executed by a processor, implements the steps of the method according to any of claims 1-8.
Description
Transaction quota management and control method and device based on hash table Technical Field The present application relates to the field of data processing technologies, and in particular, to a transaction quota management and control method and apparatus based on a hash table. Background Under the background of the rapid development of the mobile payment and electronic commerce industry, the scale of the quick payment transaction is increased in a explosive manner, and the quick payment transaction becomes one of core transaction modes in the field of financial payment. Most of the dependency relationship type database storage limit rules of the conventional quick payment transaction limit management and control system are optimized and inquired through constructing a compound index, but when the management and control dimension is expanded to multiple dimensions, the multiple dimensions combined inquiry is realized by relying on a complex structured inquiry language (Structured Query Language, SQL) statement, the inquiry time complexity is maintained at O (logn), the efficiency is difficult to improve, on the other hand, under a high concurrency scene, the problems of database connection pool competition, SQL analysis cost, disk I/O delay, index lock conflict and the like are superposed and revealed, so that limit verification response time is obviously beyond a service budget threshold, the severe requirement of quick payment on timeliness cannot be met, transaction congestion is more likely to be caused due to system performance bottleneck, and the user payment experience is directly influenced. Disclosure of Invention The present application aims to solve at least one of the technical problems in the related art to some extent. The application provides a transaction limit management and control method based on a hash table, which comprises the steps of determining a transaction limit rule table, wherein each transaction limit rule in the transaction limit rule table comprises multi-dimensional scene information and limit information corresponding to the multi-dimensional scene information, the multi-dimensional scene information comprises a payment channel, a payment mechanism code, a service type code and an account type, creating the hash table based on the transaction limit rule table, storing the multi-dimensional scene information and the corresponding limit information in a key value pair mode based on the transaction limit rule table, analyzing a user transaction request to obtain target multi-dimensional scene information in response to the user transaction request, inquiring the hash table based on the target multi-dimensional scene information to obtain target limit information corresponding to the user transaction request, checking whether the transaction amount exceeds the limit or not based on the target limit information, and rejecting or allowing the user transaction request to be executed according to a checking result. According to the application, the quota rule query is realized by constructing the hash table based on the multi-dimensional scene information, the time complexity of the conventional relational database dependence compound index query is reduced from O (logn) to O (1) of the hash table query, namely, the time consumption of single quota rule matching is always kept constant no matter how the rule number (namely rule base capacity) stored in the transaction quota rule table is increased, the problem that the query performance is continuously reduced along with the increase of the rule data amount in the conventional scheme is solved, and the hash table of the scheme takes the four-dimensional compound scene information of 'payment channel, payment mechanism code, service type code and account type' as key storage quota rule, so that the quota management and control requirements (such as different payment channels, different mechanisms and different service types) under different dimension combinations can be accurately matched, and the limitation of the conventional single-dimension quota management and control mode is broken through. A second object of the present application is to provide a transaction quota management device based on a hash table. A third object of the present application is to propose an electronic device. A fourth object of the present application is to propose a non-transitory computer readable storage medium. A fifth object of the application is to propose a computer programme product. In order to achieve the above purpose, an embodiment of the first aspect of the present application provides a transaction quota management and control method based on a hash table, which includes determining a transaction quota rule table, wherein each transaction quota rule in the transaction quota rule table includes multi-dimensional scene information and quota information corresponding to the multi-dimensional scene information, the multi-dimensional scene i