+

CN118296044A - Data processing method, device, equipment and medium based on high concurrency point - Google Patents

Data processing method, device, equipment and medium based on high concurrency point Download PDF

Info

Publication number
CN118296044A
CN118296044A CN202410357717.5A CN202410357717A CN118296044A CN 118296044 A CN118296044 A CN 118296044A CN 202410357717 A CN202410357717 A CN 202410357717A CN 118296044 A CN118296044 A CN 118296044A
Authority
CN
China
Prior art keywords
request
cache
account
business
processing
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.)
Pending
Application number
CN202410357717.5A
Other languages
Chinese (zh)
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.)
Beijing Haike Rongtong Payment Service Co ltd
Original Assignee
Beijing Haike Rongtong Payment Service 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 Beijing Haike Rongtong Payment Service Co ltd filed Critical Beijing Haike Rongtong Payment Service Co ltd
Priority to CN202410357717.5A priority Critical patent/CN118296044A/en
Publication of CN118296044A publication Critical patent/CN118296044A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及一种基于高并发热点数据处理方法、装置、设备及介质,属于数据处理的技术领域,其方法包括:获取业务请求,所述业务请求包括业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息;对所述业务请求进行校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中;在所述请求流水表存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;在缓存更新处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库。本申请具有提高高并发热点数据的响应速度和并发处理能力的效果。

The present invention relates to a method, device, equipment and medium for processing data based on high concurrency hotspots, and belongs to the technical field of data processing. The method includes: obtaining a business request, wherein the business request includes a business type, user information, a request account identifier and amount information corresponding to the business type; verifying the business request, and after the business request verification passes, storing the request flow of the business request in a system database; after the request flow table is successfully stored, based on the business type, the request account identifier, the amount information corresponding to the business type and a preset cache data processing rule, performing cache update processing on the account information in the cache database; after the cache update processing is successful, storing the cache operation voucher corresponding to the business request in the system database. The present application has the effect of improving the response speed and concurrent processing capability of high concurrency hotspot data.

Description

基于高并发热点数据处理方法、装置、设备及介质Method, device, equipment and medium for processing data based on high concurrency hotspot

技术领域Technical Field

本发明涉及数据处理技术领域,尤其涉及一种基于高并发热点数据处理方法、装置、设备及介质。The present invention relates to the field of data processing technology, and in particular to a method, device, equipment and medium for processing data based on high-concurrency hot spots.

背景技术Background technique

随着电子支付的普及和交易量的增加,特别是在对公账户或商家收款账户这样的高频交易场景,经常出现大量并发请求集中于某一热点账户的情况。在这种场景下,会出现频繁入出账的情况,对数据操作的压力也会增大,同样面临热点数据的问题。With the popularization of electronic payment and the increase in transaction volume, especially in high-frequency transaction scenarios such as public accounts or merchant payment accounts, a large number of concurrent requests are often concentrated on a hotspot account. In this scenario, there will be frequent entry and exit, and the pressure on data operations will also increase, and the problem of hotspot data will also be faced.

目前,依靠数据库的锁机制在解决并发问题方面具有一定的效果。通过锁规则,MySQL确保了数据的完整性和一致性,保障了数据的安全,提升了系统的稳定性。At present, relying on the lock mechanism of the database has a certain effect in solving concurrency problems. Through the lock rules, MySQL ensures the integrity and consistency of the data, guarantees the security of the data, and improves the stability of the system.

然而,在面临极高的并发请求时,锁竞争和锁等待会导致系统开销增大、性能下降、用户等待时间过长等问题,这使得单一依赖数据库锁机制无法满足业务需求。However, when faced with extremely high concurrent requests, lock contention and lock waiting can lead to increased system overhead, degraded performance, and long user waiting times, making it impossible to meet business needs by relying solely on database lock mechanisms.

发明内容Summary of the invention

本发明所要解决的技术问题是:提高支付场景、高频交易场景等中高并发热点数据的响应速度和并发处理能力。The technical problem to be solved by the present invention is to improve the response speed and concurrent processing capability of high-concurrency hot spot data in payment scenarios, high-frequency transaction scenarios, etc.

第一方面,本申请提供一种基于高并发热点数据处理方法,采用如下技术方案:In a first aspect, the present application provides a method for processing high-concurrency hotspot data, which adopts the following technical solutions:

一种基于高并发热点数据处理方法,包括:A method for processing high-concurrency hotspot data, comprising:

获取针对待交易订单的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;Obtaining a business request for the order to be traded, the business request including a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, the business type being any one of deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze;

对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求的请求时间、业务类型、用户信息和请求账户标识;Performing parameter legitimacy check on the user information of the service request and performing serial number anti-duplicate check on the request serial number. After the service request passes the verification, the request serial number of the service request is stored in the system database. The request serial number is used to record the request time, service type, user information and request account identifier of the service request;

在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;After the request flow is successfully stored, based on the business type, the request account identifier, the amount information corresponding to the business type and the preset cache data processing rules, the account information in the cache database is cached and updated;

在缓存更新处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。After the cache update process is successful, the cache operation credentials corresponding to the business request are stored in the system database, and the operation success result is returned to the user corresponding to the business request.

本发明的有益效果是:通过引入缓存数据库进行缓存处理,能够显著减少直接对系统数据库的读写操作,从而降低了数据库的负担,在处理业务请求时,通过参数合法性校验、流水防重校验、请求流水存储和缓存操作凭证存储等步骤,确保了数据的完整性和一致性。由于缓存处理能够提高数据处理速度,用户发起的业务请求能够得到更快的响应,提高了高并发热点数据的响应速度和并发处理能力。The beneficial effects of the present invention are as follows: by introducing a cache database for cache processing, the direct read and write operations on the system database can be significantly reduced, thereby reducing the burden on the database. When processing business requests, the integrity and consistency of the data are ensured through steps such as parameter legitimacy verification, flow anti-duplicate verification, request flow storage, and cache operation credential storage. Since cache processing can increase the data processing speed, business requests initiated by users can get faster responses, which improves the response speed and concurrent processing capability of high-concurrency hotspot data.

在上述技术方案的基础上,本发明还可以做如下改进。Based on the above technical solution, the present invention can also be improved as follows.

进一步,所述基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理,包括:Further, the cache update processing of the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules includes:

基于所述请求账户标识在缓存数据库中进行账户查询;Performing an account query in a cache database based on the request account identifier;

若在所述缓存数据库中查询到所述请求账户标识的账户信息,则基于所述业务类型和所述业务类型对应的金额信息,对查询到的账户信息进行资金验证;If the account information of the requested account identifier is found in the cache database, then based on the business type and the amount information corresponding to the business type, the found account information is verified for funds;

在所述查询到的账户信息进行资金验证通过之后,对所述缓存数据库进行签名验证;After the queried account information passes the fund verification, performing signature verification on the cache database;

在所述缓存数据库进行签名验证通过之后,基于所述业务类型、所述业务类型对应的金额信息和所述账户信息,计算账户余额,并根据所述账户余额在所述缓存数据库中修改账户信息的缓存数据,得到新的账户信息;After the signature verification is passed in the cache database, the account balance is calculated based on the business type, the amount information corresponding to the business type and the account information, and the cache data of the account information is modified in the cache database according to the account balance to obtain new account information;

基于所述新的账户信息、操作时间、业务类型、业务类型对应的金额信息生成操作流水,并将所述业务请求的操作流水存储至缓存数据库中。An operation flow is generated based on the new account information, operation time, business type, and amount information corresponding to the business type, and the operation flow of the business request is stored in a cache database.

采用上述进一步方案的有益效果是:通过在缓存数据库中直接进行账户查询和资金验证,避免了频繁访问系统数据库,在缓存处理过程中,通过签名验证机制,确保数据的完整性和真实性,防止数据被篡改或伪造;根据业务类型和金额信息,实时计算账户余额,并在缓存数据库中更新账户信息的缓存数据,保证了账户信息的实时性和准确性;通过生成并存储操作流水至缓存数据库,不仅可以为后续的审计和查询提供便利,还可以进一步优化缓存的利用。The beneficial effects of adopting the above further scheme are: by directly performing account queries and fund verification in the cache database, frequent access to the system database is avoided. During the cache processing, the integrity and authenticity of the data are ensured through the signature verification mechanism to prevent the data from being tampered with or forged; the account balance is calculated in real time according to the business type and amount information, and the cache data of the account information is updated in the cache database, ensuring the real-time and accuracy of the account information; by generating and storing operation flow to the cache database, it can not only facilitate subsequent audits and queries, but also further optimize the use of the cache.

进一步,所述基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库的账号信息进行缓存更新处理,还包括:Further, the cache update processing of the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules also includes:

若在所述缓存数据库中未查询到所述请求账户标识的账户信息,则开启异步线程,所述异步线程包括第一线程和第二线程;If the account information of the requesting account identifier is not found in the cache database, an asynchronous thread is started, where the asynchronous thread includes a first thread and a second thread;

所述第一线程,用于执行缓存重建的步骤,所述缓存重建包括:向缓存重建服务器发送进行缓存重建请求,所述缓存重建请求包括请求账号标识,以使所述缓存重建服务器基于所述请求账户标识对应的账户信息进行缓存重建;The first thread is used to perform a cache reconstruction step, wherein the cache reconstruction includes: sending a cache reconstruction request to a cache reconstruction server, wherein the cache reconstruction request includes a request account identifier, so that the cache reconstruction server performs cache reconstruction based on account information corresponding to the request account identifier;

在所述第一线程执行缓存重建的步骤时,第二线程开始等待预设时间,在等待预设时间之后,基于所述请求账户标识在所述缓存数据库中进行账户查询;When the first thread executes the cache rebuilding step, the second thread starts to wait for a preset time, and after waiting for the preset time, performs an account query in the cache database based on the request account identifier;

若查询失败,则重复执行等待预设时间的步骤,若查询次数达到预设次数后,查询失败,向所述业务请求对应的用户返回操作失败结果。If the query fails, the step of waiting for a preset time is repeated. If the query fails after the preset number of times is reached, the operation failure result is returned to the user corresponding to the business request.

采用上述进一步方案的有益效果是:当缓存数据库中未查询到账户信息时,通过开启异步线程,第一线程发送缓存重建请求,第二线程继续处理其他业务请求,避免了主线程的阻塞,从而提高了系统的整体处理效率;通过向缓存重建服务器发送缓存重建请求,缓存重建服务器利用分布锁机制对账户信息进行缓存重建,确保数据的完整性和一致性。缓存重建后的账户信息被存储至缓存数据库中,为后续的业务处理提供了准确的数据基础。在主线程等待预设时间后,再次基于请求账户标识在缓存数据库中进行账户查询。如果查询失败,则继续等待并查询,直至达到预设次数。这种重试机制能够应对网络延迟、缓存同步延迟等临时性问题,提高了系统的可靠性和容错能力。The beneficial effect of adopting the above further scheme is: when the account information is not queried in the cache database, by starting an asynchronous thread, the first thread sends a cache reconstruction request, and the second thread continues to process other business requests, avoiding the blocking of the main thread, thereby improving the overall processing efficiency of the system; by sending a cache reconstruction request to the cache reconstruction server, the cache reconstruction server uses a distributed lock mechanism to reconstruct the cache of the account information to ensure the integrity and consistency of the data. The account information after cache reconstruction is stored in the cache database, providing an accurate data basis for subsequent business processing. After the main thread waits for a preset time, the account query is performed again in the cache database based on the request account identifier. If the query fails, continue to wait and query until the preset number of times is reached. This retry mechanism can deal with temporary problems such as network delays and cache synchronization delays, and improve the reliability and fault tolerance of the system.

进一步,所述请求流水包括请求记录状态,在所述系统数据库中保存所述账号信息对应的缓存操作凭证之后,还包括:Further, the request flow includes a request record status, and after the cache operation credentials corresponding to the account information are saved in the system database, it also includes:

将所述请求流水的请求记录状态记录为处理成功。The request record status of the request pipeline is recorded as successful processing.

采用上述进一步方案的有益效果是:将请求记录状态记录为处理成功,有助于后续的业务追踪和审计。系统可以根据请求流水的状态记录,对业务处理过程进行回溯和分析,以发现潜在的问题或异常。The beneficial effect of adopting the above further solution is that the request record status is recorded as successfully processed, which is helpful for subsequent business tracking and auditing. The system can trace back and analyze the business processing process according to the status record of the request flow to find potential problems or anomalies.

进一步,在缓存处理失败之后,所述方法还包括:Furthermore, after the cache processing fails, the method further includes:

基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测,所述异常内容包括网络中断、数据库连接失败、操作失败、超时,所述操作失败包括余额不足、状态止出和账户不存在中的至少一项。Based on preset timed tasks, abnormal content detection is performed on business requests that fail to be processed by the cache. The abnormal content includes network interruption, database connection failure, operation failure, and timeout. The operation failure includes at least one of insufficient balance, status stop, and account non-existence.

采用上述进一步方案的有益效果是:通过定时任务对缓存处理失败的业务请求进行异常内容检测,可以及时发现可能存在的网络中断、数据库连接失败、操作失败等异常情况,便于系统快速响应并采取相应的处理措施,避免异常情况的进一步扩散和影响。定时任务可以自动执行异常内容检测,无需人工干预。这大大减轻了系统维护人员的工作负担,提高了维护效率。The beneficial effect of adopting the above further scheme is: by using the scheduled task to detect abnormal content of the business request that failed to be processed by the cache, it is possible to timely discover abnormal situations such as network interruption, database connection failure, operation failure, etc., so that the system can respond quickly and take corresponding processing measures to avoid further spread and impact of abnormal situations. Scheduled tasks can automatically perform abnormal content detection without manual intervention. This greatly reduces the workload of system maintenance personnel and improves maintenance efficiency.

进一步,所述请求流水包括请求记录状态,在所述基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测之后,还包括:Further, the request flow includes a request record state, and after performing abnormal content detection on the service request that fails in cache processing based on the preset timed task, it also includes:

获取所述业务请求对应的缓存处理失败的异常内容类型;Obtain the abnormal content type of cache processing failure corresponding to the business request;

判断所述业务请求缓存处理失败的异常内容类型是否为余额不足类型、状态止出类型、账户不存在类型中的任一种;Determine whether the abnormal content type of the failure of the business request cache processing is any one of the insufficient balance type, the status stop type, and the account does not exist type;

若是,则将所述业务请求对应的请求流水的请求记录状态记录为处理失败;If yes, the request record status of the request flow corresponding to the business request is recorded as processing failure;

若否,则将所述业务请求对应的请求流水的请求记录状态记录为处理中。If not, the request record status of the request flow corresponding to the business request is recorded as being processed.

采用上述进一步方案的有益效果是:通过判断缓存处理失败的异常内容类型,系统能够精确地将业务请求的请求流水记录为处理失败或处理中状态。对于余额不足、状态止出和账户不存在等特定类型的异常内容,将请求流水记录为处理失败状态,可以避免无效的后续操作,节省系统资源。同时,对于其他类型的异常内容,将请求流水记录为处理中状态,可以保留一定的处理空间,等待系统进一步的处理或恢复。The beneficial effect of adopting the above further scheme is that by determining the type of abnormal content that failed to be processed by the cache, the system can accurately record the request flow of the business request as a processing failure or processing status. For specific types of abnormal content such as insufficient balance, status stop and account non-existence, recording the request flow as a processing failure status can avoid invalid subsequent operations and save system resources. At the same time, for other types of abnormal content, recording the request flow as a processing status can reserve a certain processing space, waiting for further processing or recovery by the system.

进一步,所述缓存操作凭证包括处理状态和凭证创建时间,所述方法还包括:Further, the cache operation credential includes a processing status and a credential creation time, and the method further includes:

基于第一预设的时间间隔,在所述系统数据库中查询符合预设条件的缓存操作凭证,所述预设条件为所述缓存操作凭证的处理状态为未处理,所述缓存操作凭证的存储时间为在预设时间内的缓存操作凭证,所述预设时间基于当前时间和第二预设的时间间隔计算得出;Based on a first preset time interval, querying the system database for a cache operation credential that meets a preset condition, wherein the preset condition is that the processing status of the cache operation credential is unprocessed, and the storage time of the cache operation credential is the cache operation credential within a preset time, wherein the preset time is calculated based on the current time and a second preset time interval;

若在所述系统数据库中查询到符合预设条件的缓存操作凭证,则按照缓存操作凭证的请求账号,对每个缓存操作凭证进行划分,并采用多线程并行处理每个请求账号对应的至少一个缓存操作凭证;If a cache operation credential that meets the preset conditions is found in the system database, each cache operation credential is divided according to the requesting account of the cache operation credential, and at least one cache operation credential corresponding to each requesting account is processed in parallel using multiple threads;

对于每个线程,基于所述请求账户标识在系统数据库中获取账户信息;For each thread, obtaining account information in a system database based on the request account identifier;

对于每个线程,基于预设的余额计算公式、所述账号信息和所述请求账号对应的至少一个缓存操作凭证,对请求账户标识进行金额汇总,得到所述请求账号的余额信息;For each thread, based on a preset balance calculation formula, the account information and at least one cache operation voucher corresponding to the requesting account, the amount of the requesting account identifier is aggregated to obtain the balance information of the requesting account;

对于每个线程,基于所述账户余额,在所述系统数据库中修改所述请求账户标识对应的账户信息;For each thread, based on the account balance, modify the account information corresponding to the requesting account identifier in the system database;

对于每个线程,在所述请求账户标识对应的账户信息修改成功之后,修改所述请求账户标识对应的至少一个缓存操作凭证的状态为处理成功,并在所述系统数据库中存储所述请求账号对应的变动流水。For each thread, after the account information corresponding to the request account identifier is modified successfully, the status of at least one cache operation credential corresponding to the request account identifier is modified to be processed successfully, and the change flow corresponding to the request account is stored in the system database.

采用上述进一步方案的有益效果是:通过基于预设时间间隔查询未处理的缓存操作凭证,并按请求账号划分并行处理,可以充分利用系统资源,减少等待时间,从而显著提高数据处理效率。在高并发场景下,这种并行处理方式能够极大提升系统的吞吐量和响应速度。对每个请求账号的缓存操作凭证进行金额汇总,并基于汇总结果修改系统数据库中的账户信息,确保了数据的准确性和一致性。同时,修改缓存操作凭证的状态为处理成功,并在系统数据库中存储变动流水,为后续审计和追踪提供了完整的数据记录。通过多线程并行处理缓存操作凭证,可以充分利用多核CPU的计算能力,避免资源的浪费。The beneficial effect of adopting the above further scheme is: by querying the unprocessed cache operation vouchers based on the preset time interval, and dividing the parallel processing by the request account, the system resources can be fully utilized, the waiting time can be reduced, and the data processing efficiency can be significantly improved. In a high concurrency scenario, this parallel processing method can greatly improve the throughput and response speed of the system. The amount of the cache operation vouchers for each request account is summarized, and the account information in the system database is modified based on the summary results, ensuring the accuracy and consistency of the data. At the same time, the status of the cache operation voucher is modified to successful processing, and the change flow is stored in the system database, providing a complete data record for subsequent auditing and tracking. By processing cache operation vouchers in parallel through multiple threads, the computing power of multi-core CPUs can be fully utilized to avoid waste of resources.

第二方面,本申请提供一种基于高并发热点数据处理装置,采用如下技术方案:In a second aspect, the present application provides a high-concurrency hotspot data processing device, which adopts the following technical solution:

一种基于高并发热点数据处理装置,包括:A high-concurrency hotspot data processing device, comprising:

获取模块,用于获取针对待交易订单的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;an acquisition module, used to acquire a business request for a pending transaction order, wherein the business request includes a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, wherein the business type is any one of: deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze;

参数校验模块,用于对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求的请求时间、业务类型、用户信息和请求账户标识;A parameter verification module is used to perform parameter legitimacy verification on the user information of the service request and to perform serial number anti-duplicate verification on the request serial number. After the service request passes the verification, the request serial number of the service request is stored in the system database. The request serial number is used to record the request time, service type, user information and request account identifier of the service request;

缓存处理模块,用于在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;A cache processing module, configured to perform cache update processing on the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and a preset cache data processing rule after the request flow is successfully stored;

存储模块,用于在缓存处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。The storage module is used to store the cache operation credentials corresponding to the business request in the system database after the cache processing is successful, and return the operation success result to the user corresponding to the business request.

本发明的有益效果是:通过引入缓存数据库进行缓存处理,能够显著减少直接对系统数据库的读写操作,从而降低了数据库的负担,在处理业务请求时,通过参数校验、请求流水存储和缓存操作凭证存储等步骤,确保了数据的完整性和一致性。由于缓存处理能够提高数据处理速度,用户发起的业务请求能够得到更快的响应,提高了高并发热点数据的响应速度和并发处理能力。The beneficial effects of the present invention are as follows: by introducing a cache database for cache processing, the direct read and write operations on the system database can be significantly reduced, thereby reducing the burden on the database, and when processing business requests, the integrity and consistency of the data are ensured through steps such as parameter verification, request flow storage, and cache operation credential storage. Since cache processing can increase the data processing speed, business requests initiated by users can receive faster responses, thereby improving the response speed and concurrent processing capability of high-concurrency hotspot data.

第三方面,本申请提供一种电子设备,采用如下技术方案:In a third aspect, the present application provides an electronic device, which adopts the following technical solution:

一种电子设备,包括存储器和处理器,所述存储器上存储有能够被处理器加载并执行第一方面任一项所述的基于高并发热点数据处理方法的计算机程序。An electronic device comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executes the high-concurrency hot spot data processing method according to any one of the first aspects.

第四方面,本申请提供一种计算机可读存储介质,采用如下技术方案:In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution:

一种计算机可读存储介质,存储有能够被处理器加载并执行第一方面任一项所述的基于高并发热点数据处理方法的计算机程序。A computer-readable storage medium stores a computer program that can be loaded by a processor and execute the high-concurrency hot spot data processing method according to any one of the first aspects.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本发明的基于高并发热点数据处理方法的流程示意图;FIG1 is a schematic flow chart of a method for processing high-concurrency hotspot data according to the present invention;

图2为本发明的电子设备向缓存重建服务器发起缓存重建流程的流程示意图。FIG. 2 is a schematic diagram of a process flow of an electronic device of the present invention initiating a cache reconstruction process to a cache reconstruction server.

图3为本发明的电子设备进行缓存入账的流程示意图;FIG3 is a schematic diagram of a process of cache entry by an electronic device of the present invention;

图4为本发明的基于高并发热点数据处理装置的结构图;FIG4 is a structural diagram of a high-concurrency hotspot data processing device according to the present invention;

图5为本发明的一种电子设备的结构框图。FIG5 is a structural block diagram of an electronic device of the present invention.

具体实施方式Detailed ways

以下结合附图对本申请作进一步详细说明。The present application is further described in detail below in conjunction with the accompanying drawings.

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

本申请实施例提供一种基于高并发热点数据处理方法,该高并发热点数据处理方法可由电子设备执行,该电子设备可以为服务器,也可以为移动终端设备,其中服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云计算服务的云服务器;移动终端设备可以是笔记本电脑、台式计算机等,但不局限于此。An embodiment of the present application provides a high-concurrency hot spot data processing method, which can be executed by an electronic device, and the electronic device can be a server or a mobile terminal device, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services; the mobile terminal device can be a laptop computer, a desktop computer, etc., but is not limited to this.

下面结合说明书附图对本申请实施例作进一步详细描述。如图1所示,基于高并发热点数据处理方法,包括步骤S1~S4:The following is a further detailed description of the embodiments of the present application in conjunction with the accompanying drawings. As shown in FIG1 , a method for processing high-concurrency hotspot data includes steps S1 to S4:

步骤S1,获取针对交易场景的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;Step S1, obtaining a business request for a transaction scenario, wherein the business request includes a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, wherein the business type is any one of deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze;

在本申请实施方式中,电子设备获取至少一个业务请求,业务请求由用户通过客户端或者其它系统进去访问,电子设备将获取的至少一个业务请求根据业务请求的时间存储在系统数据库的请求流水表中,之后电子设备根据请求流水表中多个业务请求的顺序依次获取业务请求进行请求处理。其中,用户信息包括用户ID、用户名称等,请求账户标识为涉及操作的账户信息,如账户ID,业务类型对应的金额信息包括转账金额、冻结金额等,请求流水号为唯一标识某一具体业务请求的编号。In the implementation mode of the present application, the electronic device obtains at least one business request, which is accessed by the user through a client or other system, and the electronic device stores the obtained at least one business request in the request flow table of the system database according to the time of the business request, and then the electronic device obtains the business request in sequence according to the order of multiple business requests in the request flow table to process the request. Among them, the user information includes user ID, user name, etc., the request account identifier is the account information involved in the operation, such as account ID, the amount information corresponding to the business type includes transfer amount, frozen amount, etc., and the request serial number is a number that uniquely identifies a specific business request.

步骤S2,对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求的请求时间、业务类型、用户信息和请求账户标识;Step S2, performing parameter legitimacy check on the user information of the service request and performing serial number anti-duplicate check on the request. After the service request passes the check, the request serial number of the service request is stored in the system database. The request serial number is used to record the request time, service type, user information and request account identifier of the service request.

在本申请实施方式中,电子设备对接收到的业务请求进行预处理,预处理包括参数合法性校验(如检查用户信息的有效性、业务类型的正确性、金额信息的合理性等)、请求流水防重校验,以及将请求信息格式化或标准化,以便于后续处理。In an implementation manner of the present application, the electronic device preprocesses the received business request, and the preprocessing includes parameter legitimacy verification (such as checking the validity of user information, the correctness of the business type, the rationality of the amount information, etc.), request flow anti-duplicate verification, and formatting or standardizing the request information for subsequent processing.

如果业务请求未通过参数校验通过,则继续处理请求,如果校验失败,则返回用户的客户端或其它系统响应失败,并终止请求处理。If the business request does not pass the parameter verification, the request will continue to be processed. If the verification fails, the user's client or other system response failure is returned and the request processing is terminated.

需要说明的是,参数合法性校验包括:系统确认业务类型是否属于系统支持的范畴(如入账、出账、冻结、解冻等),并检查是否存在非法的或未定义的业务类型;验证用户信息的完整性和有效性,包括用户名、用户ID等是否符合系统规定的格式,以及是否存在于系统用户列表中;检查请求账户标识是否合法,如账户是否存在、账户状态是否正常等;验证金额信息是否合法,如金额是否大于0、是否超过预设的最大金额限制等。同时,对于批量处理类型的业务请求,还需要校验批量数据的格式和内容是否正确;校验其他特定的参数,如时间戳、签名等。It should be noted that the parameter validity check includes: the system confirms whether the business type belongs to the scope supported by the system (such as deposit, withdrawal, freeze, unfreeze, etc.), and checks whether there are illegal or undefined business types; verifies the integrity and validity of user information, including whether the user name, user ID, etc. conform to the format specified by the system, and whether they exist in the system user list; checks whether the requested account identifier is legal, such as whether the account exists, whether the account status is normal, etc.; verifies whether the amount information is legal, such as whether the amount is greater than 0, whether it exceeds the preset maximum amount limit, etc. At the same time, for batch processing type business requests, it is also necessary to verify whether the format and content of the batch data are correct; and verify other specific parameters, such as timestamps, signatures, etc.

请求流水防重校验包括:系统为业务请求生成一个唯一的请求流水号,该流水号通常基于一定的规则生成,如时间戳、随机数等,以确保其全局唯一性。将生成的请求流水号存储至系统数据库中,作为该业务请求的唯一标识。同时,记录与该流水号相关的请求信息。在接收到新的业务请求时,首先通过查询系统数据库来检查该请求流水号是否已存在。如果查询结果为空,说明该请求流水号不存在,即该请求是新的,可以继续处理。The request serial number anti-duplicate check includes: the system generates a unique request serial number for the business request, which is usually generated based on certain rules, such as timestamp, random number, etc., to ensure its global uniqueness. The generated request serial number is stored in the system database as the unique identifier of the business request. At the same time, the request information related to the serial number is recorded. When a new business request is received, the system database is first queried to check whether the request serial number already exists. If the query result is empty, it means that the request serial number does not exist, that is, the request is new and can continue to be processed.

如果查询结果不为空,说明该请求流水号已存在,即该请求是重复的。此时,返回用户的客户端或其它系统响应失败,并终止请求处理,以避免重复处理相同的请求。If the query result is not empty, it means that the request serial number already exists, that is, the request is repeated. At this time, the user's client or other system responds to failure and terminates the request processing to avoid repeated processing of the same request.

当系统尝试将请求流水存储至系统数据库时,执行插入(INSERT)操作,将业务请求的相关数据(如请求流水号、业务类型、请求账户标识、金额信息等)插入到请求流水表中,数据库操作完成后,系统会返回一个操作结果。这个结果通常是一个状态码或布尔值,用于指示操作是否成功。When the system attempts to store the request flow into the system database, it performs an INSERT operation to insert the relevant data of the business request (such as the request flow number, business type, request account ID, amount information, etc.) into the request flow table. After the database operation is completed, the system returns an operation result. This result is usually a status code or Boolean value to indicate whether the operation is successful.

若系统存储操作成功,则执行步骤S3,若系统存储操作未成功,则返回业务响应失败结果。If the system storage operation is successful, step S3 is executed. If the system storage operation is unsuccessful, a business response failure result is returned.

步骤S3,在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;Step S3, after the request flow is successfully stored, based on the business type, the request account identifier, the amount information corresponding to the business type and the preset cache data processing rules, the account information in the cache database is cached and updated;

在本申请实施方式中,电子设备基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,在缓存数据库中获取请求账号的缓存信息。本申请中,缓存数据库为redis数据库。In the implementation manner of the present application, the electronic device obtains cache information of the requesting account in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules. In the present application, the cache database is a redis database.

基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,在缓存数据库中获取请求账号的缓存信息包括:根据lua脚本进行rides操作,若lua脚本执行成功,则保存redis操作成功流水,若lua脚本执行失败,则脚本返回redis操作结果,失败原因描述,缓存操作时间戳。Based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules, obtaining the cache information of the requesting account in the cache database includes: performing a rides operation according to the Lua script, if the Lua script is executed successfully, saving the redis operation success flow, if the Lua script fails to execute, the script returns the redis operation result, the failure reason description, and the cache operation timestamp.

该脚本包含如下操作:步骤1,声明redis结果返回对象操作;步骤2,查询请求账户标识操作;步骤3,验证请求账户标识是否存在操作;步骤4,账户数据解析操作;步骤5,资金验证操作;步骤6,签名验证;步骤7,余额计算;步骤8,获取redis操作时间;步骤9,账户数据组装;步骤10,账户修改;步骤77,保存redis流水;步骤12,操作结果返回。The script includes the following operations: Step 1, declare the redis result return object operation; Step 2, query the request account identifier operation; Step 3, verify whether the request account identifier exists; Step 4, account data parsing operation; Step 5, fund verification operation; Step 6, signature verification; Step 7, balance calculation; Step 8, obtain redis operation time; Step 9, account data assembly; Step 10, account modification; Step 77, save redis transaction; Step 12, operation result return.

具体的,步骤S3包括如下子步骤:Specifically, step S3 includes the following sub-steps:

步骤S31,基于所述请求账户标识在缓存数据库中进行账户查询;Step S31, performing an account query in a cache database based on the request account identifier;

在本申请实施方式中,系统使用请求账户标识信息作为查询条件,在缓存数据库中进行查询。缓存数据库通常是一个内存数据库或高速缓存系统,用于快速检索账户信息。In the implementation mode of the present application, the system uses the request account identification information as a query condition to query in the cache database. The cache database is usually a memory database or a high-speed cache system for quickly retrieving account information.

如果查询成功,获取与该请求账户标识相关的账户信息,包括账户余额、账户状态、账户限制等。If the query is successful, the account information related to the requested account ID is obtained, including account balance, account status, account restrictions, etc.

步骤S32,若在所述缓存数据库中查询到所述请求账户标识的账户信息,则基于所述业务类型和所述业务类型对应的金额信息,对查询到的账户信息进行资金验证;Step S32, if the account information of the requesting account identifier is found in the cache database, then based on the business type and the amount information corresponding to the business type, the found account information is subjected to fund verification;

在本申请实施方式中,系统根据查询到的账户信息和业务类型对应的金额信息,按照预设的定义规则进行资金验证。预设的定义规则包括检查账户余额是否足够、是否超过预设限制等。In the implementation mode of the present application, the system performs fund verification according to the queried account information and the amount information corresponding to the business type according to the preset definition rules. The preset definition rules include checking whether the account balance is sufficient, whether it exceeds the preset limit, etc.

如果资金验证通过,则继续后续步骤;如果验证失败(例如账户余额不足),则返回错误信息并终止处理。If the funds verification is passed, the subsequent steps will be continued; if the verification fails (for example, the account balance is insufficient), an error message will be returned and the processing will be terminated.

步骤S33,在所述查询到的账户信息进行资金验证通过之后,对所述缓存数据库进行签名验证;Step S33, after the queried account information passes the fund verification, the cache database is signature verified;

步骤S34,在所述缓存数据库进行签名验证通过之后,基于所述业务类型、所述业务类型对应的金额信息和所述账户信息,计算账户余额,并根据所述账户余额在所述缓存数据库中修改账户信息的缓存数据,得到新的账户信息;Step S34, after the signature verification is passed in the cache database, the account balance is calculated based on the business type, the amount information corresponding to the business type and the account information, and the cache data of the account information is modified in the cache database according to the account balance to obtain new account information;

步骤S35,基于所述新的账户信息、操作时间、业务类型、业务类型对应的金额信息生成操作流水,并将所述业务请求的操作流水存储至缓存数据库中。Step S35, generating an operation flow based on the new account information, operation time, business type, and amount information corresponding to the business type, and storing the operation flow of the business request in a cache database.

步骤S36,若在所述缓存数据库中未查询到所述请求账户标识的账户信息,则开启异步线程,所述异步线程包括第一线程和第二线程;Step S36, if the account information of the requesting account identifier is not found in the cache database, an asynchronous thread is started, wherein the asynchronous thread includes a first thread and a second thread;

所述第一线程,用于执行缓存重建的步骤,所述缓存重建包括:向缓存重建服务器发送进行缓存重建请求,所述缓存重建请求包括请求账号标识,以使所述缓存重建服务器基于所述请求账户标识对应的账户信息进行缓存重建,并将缓存重建后的缓存账号信息存储至缓存数据库中;The first thread is used to perform a cache reconstruction step, wherein the cache reconstruction includes: sending a cache reconstruction request to a cache reconstruction server, wherein the cache reconstruction request includes a request account identifier, so that the cache reconstruction server performs cache reconstruction based on account information corresponding to the request account identifier, and stores the cache account information after cache reconstruction in a cache database;

在本申请实施方式中,若lua脚本操作返回账户不存在。进行缓存重建,重建成功则重新执行脚本逻辑。重建失败则返回业务方失败结果。In the implementation mode of the present application, if the Lua script operation returns that the account does not exist, the cache is rebuilt, and if the reconstruction is successful, the script logic is re-executed. If the reconstruction fails, the business side failure result is returned.

步骤S37,在所述第一线程执行缓存重建的步骤时,第二线程开始等待预设时间,在等待预设时间之后,基于所述请求账户标识在所述缓存数据库中进行账户查询;Step S37, when the first thread executes the cache rebuilding step, the second thread starts to wait for a preset time, and after waiting for the preset time, performs an account query in the cache database based on the request account identifier;

步骤S38,若查询失败,则重复执行等待预设时间的步骤,若查询次数达到预设次数后,查询失败,向所述业务请求对应的用户返回操作失败结果。Step S38, if the query fails, the step of waiting for a preset time is repeated. If the query fails after the number of queries reaches the preset number, an operation failure result is returned to the user corresponding to the business request.

步骤S4,在缓存处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。Step S4, after the cache processing is successful, the cache operation credentials corresponding to the business request are stored in the system database, and the operation success result is returned to the user corresponding to the business request.

在本申请实施方式中,脚本执行成功,保存一条缓存操作凭证,缓存操作凭证包括凭证流水号、凭证创建时间,其中,凭证流水号为业务請求流水号;凭证创建时间为脚本执行时间。缓存操作凭证保存成功后,在缓存数据库中删除redis操作成功流水。In the implementation mode of the present application, the script is executed successfully and a cache operation voucher is saved. The cache operation voucher includes a voucher serial number and a voucher creation time, wherein the voucher serial number is the business request serial number; and the voucher creation time is the script execution time. After the cache operation voucher is saved successfully, the redis operation success serial is deleted from the cache database.

图2示出了电子设备向缓存重建服务器发起缓存重建流程的流程示意图。FIG. 2 is a schematic diagram showing a process flow of an electronic device initiating a cache reconstruction process to a cache reconstruction server.

下面结合图1和图2对步骤S36进行如下说明,如图1和图2所示,当系统在所述缓存数据库中未查询到所述请求账户标识的账户信息时,触发异步线程,该异步线程负责构造缓存重建请求,并将该缓存请求发送至缓存重建服务器,缓存重建请求包括请求账户标识。The following description of step S36 is given in conjunction with Figures 1 and 2. As shown in Figures 1 and 2, when the system fails to find the account information of the requested account identifier in the cache database, an asynchronous thread is triggered. The asynchronous thread is responsible for constructing a cache reconstruction request and sending the cache reconstruction request to the cache reconstruction server. The cache reconstruction request includes the requested account identifier.

第一线程执行缓存重建的步骤,缓存重建服务器接收缓存重建请求,获取分布式锁,分布式锁用于确保在重建缓存的过程中,不会有其他操作同时修改该账户的数据,从而防止数据处理冲突。The first thread executes the cache reconstruction step. The cache reconstruction server receives the cache reconstruction request and obtains a distributed lock. The distributed lock is used to ensure that during the cache reconstruction process, no other operations will modify the data of the account at the same time, thereby preventing data processing conflicts.

缓存重建服务器查询系统数据库和缓存数据库中是否存在异常数据,通过比对数据库和缓存中的数据一致性、检查数据状态或日志等方式实现。如果发现异常数据,缓存重建服务器按照预设的数据差错处理流程进行处理,比如清理异常数据、记录错误日志等。The cache reconstruction server queries the system database and cache database for abnormal data by comparing the data consistency between the database and the cache, checking the data status or log, etc. If abnormal data is found, the cache reconstruction server handles it according to the preset data error processing process, such as cleaning up abnormal data and recording error logs.

缓存服务区从系统数据库中查询该账户的延迟余额信息以及缓存中未处理的凭证信息,将查询到的延迟余额信息和缓存未处理凭证信息相加,得到账户的实际金额。之后,根据实际金额、请求账户标识的账户信息、操作时间等,生成新的缓存账户信息,保存到缓存数据库中。The cache service area queries the delayed balance information of the account and the unprocessed voucher information in the cache from the system database, adds the queried delayed balance information and the cached unprocessed voucher information to obtain the actual amount of the account. After that, new cache account information is generated based on the actual amount, the account information of the requesting account identifier, the operation time, etc., and saved in the cache database.

需要说明的是,账户真实金额=缓存金额=凭证未处理金额+数据库延迟金额。It should be noted that the actual amount in the account = cached amount = unprocessed voucher amount + database delayed amount.

第二线程采用盲策略等待缓存重建,系统请求第二线程进入等待状态,设根据定时器或计数器来记录等待时间或查询次数,在等待时间内,第二线程会周期性地尝试查询缓存账户信息,如果查询结果为空,则第二线程继续等待,并重复查询操作,当查询次数达到预设的最大等待次数count时,第二线程将停止等待,并响应业务请求失败。如果查询成功获取到请求账户标识的账户信息,则第二线程退出等待状态,并继续后续的操作缓存的账户信息的缓存处理操作。The second thread adopts a blind strategy to wait for cache reconstruction. The system requests the second thread to enter a waiting state. The waiting time or query number is recorded according to a timer or counter. During the waiting time, the second thread will periodically try to query the cached account information. If the query result is empty, the second thread will continue to wait and repeat the query operation. When the query number reaches the preset maximum waiting number count, the second thread will stop waiting and respond to the failure of the business request. If the query successfully obtains the account information of the requested account identifier, the second thread exits the waiting state and continues the subsequent cache processing operation of the cached account information.

通过向缓存重建服务器发送缓存重建请求,缓存重建服务器利用分布锁机制对账户信息进行缓存重建,确保数据的完整性和一致性。缓存重建后的账户信息被存储至缓存数据库中,为后续的业务处理提供了准确的数据基础。在主线程等待预设时间后,再次基于请求账户标识在缓存数据库中进行账户查询。如果查询失败,则继续等待并查询,直至达到预设次数。这种重试机制能够应对网络延迟、缓存同步延迟等临时性问题,提高了系统的可靠性和容错能力。By sending a cache reconstruction request to the cache reconstruction server, the cache reconstruction server uses the distributed lock mechanism to rebuild the cache of the account information to ensure the integrity and consistency of the data. The account information after cache reconstruction is stored in the cache database, providing an accurate data basis for subsequent business processing. After the main thread waits for a preset time, it performs an account query in the cache database again based on the requested account identifier. If the query fails, it continues to wait and query until the preset number of times is reached. This retry mechanism can cope with temporary problems such as network delays and cache synchronization delays, improving the reliability and fault tolerance of the system.

作为本申请实施方式的另一种可选实施方式,在缓存处理失败之后,所述方法还包括:As another optional implementation of the implementation of the present application, after the cache processing fails, the method further includes:

基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测,所述异常内容包括网络中断、数据库连接失败、操作失败、超时,所述操作失败包括余额不足、状态止出和账户不存在中的至少一种。Based on preset timed tasks, abnormal content detection is performed on business requests that fail to be processed by the cache. The abnormal content includes network interruption, database connection failure, operation failure, and timeout. The operation failure includes at least one of insufficient balance, status stop, and account non-existence.

在一种实施方式中,若lua脚本操作异常,则获取所述业务请求对应的缓存处理失败的异常内容类型;判断所述业务请求缓存处理失败的异常内容类型是否为余额不足类型、状态止出类型、账户不存在类型中的任一种;In one implementation, if the Lua script operation is abnormal, the abnormal content type of the cache processing failure corresponding to the business request is obtained; it is determined whether the abnormal content type of the cache processing failure of the business request is any one of the insufficient balance type, the status stop type, and the account does not exist type;

若是,则将所述业务请求对应的请求流水的请求记录状态记录为处理失败;若否,则将所述业务请求对应的请求流水的请求记录状态记录为处理中。并响应业务方“处理中”一类中间状态返回码。业务方可通过请求查询接口,查询最终处理结果。If yes, the request record status of the request flow corresponding to the business request is recorded as processing failure; if no, the request record status of the request flow corresponding to the business request is recorded as processing. And respond to the business party with an intermediate status return code such as "processing". The business party can query the final processing result through the request query interface.

因redis和mysql无法直接保证原子性,所以遇到异常中断情况无法数据回滚。则依靠定时方案,间歇性处理异常数据。差错处理以redis操作结果为基准(redis操作成功流水是否存在),若redis操作成功,此笔请求最终状态即为成功;若redis执行失败,则视此笔请求最终状态为失败。Since redis and MySQL cannot guarantee atomicity directly, data cannot be rolled back in case of abnormal interruption. We rely on the timing scheme to handle abnormal data intermittently. Error handling is based on the redis operation result (whether the redis operation success flow exists). If the redis operation is successful, the final status of this request is success; if the redis execution fails, the final status of this request is considered failure.

图3示出了电子设备进行缓存入账的流程示意图。FIG. 3 is a schematic diagram showing a process flow of cache entry by an electronic device.

如图3所示,作为本申请实施方式的另一种可选实施方式,所述方法还包括:As shown in FIG3 , as another optional implementation of the implementation of the present application, the method further includes:

步骤S41,电子设备基于第一预设的时间间隔,在所述系统数据库中查询符合预设条件的缓存操作凭证,所述缓存操作凭证包括处理状态和凭证创建时间,所述预设条件为所述缓存操作凭证的处理状态为未处理,所述缓存操作凭证的存储时间为在预设时间内的缓存操作凭证,所述预设时间基于当前时间和第二预设的时间间隔计算得出;Step S41, the electronic device searches the system database for a cache operation credential that meets a preset condition based on a first preset time interval, the cache operation credential including a processing status and a credential creation time, the preset condition being that the processing status of the cache operation credential is unprocessed, and the storage time of the cache operation credential is the cache operation credential within a preset time, and the preset time is calculated based on the current time and a second preset time interval;

步骤S42,若在所述系统数据库中查询到符合预设条件的缓存操作凭证,则按照缓存操作凭证的请求账号,对每个缓存操作凭证进行划分,并采用多线程并行处理每个请求账号对应的至少一个缓存操作凭证;Step S42, if a cache operation credential meeting the preset condition is found in the system database, each cache operation credential is divided according to the requesting account of the cache operation credential, and at least one cache operation credential corresponding to each requesting account is processed in parallel using multiple threads;

步骤S43,对于每个线程,基于所述请求账户标识在系统数据库中获取账户信息;Step S43, for each thread, obtaining account information from a system database based on the request account identifier;

步骤S44,对于每个线程,基于预设的余额计算公式、所述账号信息和所述请求账号对应的至少一个缓存操作凭证,对请求账户标识进行金额汇总,得到所述请求账号的余额信息;Step S44, for each thread, based on a preset balance calculation formula, the account information and at least one cache operation credential corresponding to the requesting account, the amount of the requesting account identifier is aggregated to obtain the balance information of the requesting account;

步骤S45,对于每个线程,基于所述账户余额,在所述系统数据库中修改所述请求账户标识对应的账户信息;Step S45, for each thread, based on the account balance, modifying the account information corresponding to the request account identifier in the system database;

步骤S46,对于每个线程,在所述请求账户标识对应的账户信息修改成功之后,修改所述请求账户标识对应的至少一个缓存操作凭证的状态为处理成功,并在所述系统数据库中存储所述请求账号对应的变动流水,变动流水为记录账户金额发生变动的记录。Step S46, for each thread, after the account information corresponding to the request account identifier is successfully modified, the status of at least one cache operation credential corresponding to the request account identifier is modified to successful processing, and the change flow corresponding to the request account is stored in the system database, and the change flow is a record of changes in the account balance.

在本申请实施方式中,系统每隔五分钟触发一次汇总跑批任务。在每次跑批任务触发时,获取当前时间,并计算前推两分钟的时间点作为查询凭证的时间范围上限,查询缓存中操作凭证的记录,条件为处理状态为“未处理”,且操作时间在当前时间前推两分钟之内。In the implementation mode of the present application, the system triggers a summary batch task every five minutes. Each time the batch task is triggered, the current time is obtained, and the time point two minutes before is calculated as the upper limit of the time range for querying the voucher. The record of the operation voucher in the cache is queried, and the condition is that the processing status is "unprocessed" and the operation time is within two minutes before the current time.

若未查询到任何凭证记录,则本次跑批任务执行结束,等待下一次定时触发。若查询到符合预设条件的缓存操作凭证,则对查询到的凭证记录按照账户号进行分组,为每个账户创建一个独立的线程(或使用线程池),以便并行处理不同账户的缓存操作凭证,每个线程负责处理对应账户的凭证记录,包括数据库查询、金额汇总和账户余额修改等操作。If no voucher record is found, the batch task execution ends and waits for the next scheduled trigger. If cached operation vouchers that meet the preset conditions are found, the queried voucher records are grouped according to the account number, and a separate thread is created for each account (or a thread pool is used) to process cached operation vouchers of different accounts in parallel. Each thread is responsible for processing the voucher records of the corresponding account, including database query, amount aggregation, and account balance modification.

之后,线程查询数据库获取对应账户的账户信息,据凭证记录进行金额汇总,计算出需要调整的账户余额金额,改数系统中的实体账户余额信息,确保多笔redis操作凭证只更新一次账户余额,以减轻数据库操作压力。Afterwards, the thread queries the database to obtain the account information of the corresponding account, summarizes the amount according to the voucher record, calculates the account balance amount that needs to be adjusted, and updates the entity account balance information in the system to ensure that multiple redis operation vouchers only update the account balance once to reduce the pressure on database operations.

在系统数据库账户余额修改成功后,使用分布式锁保护接下来的操作,防止并发冲突。并修改缓存中对应凭证的处理状态为“成功”,表示该凭证已处理完成。After the system database account balance is modified successfully, a distributed lock is used to protect the next operation to prevent concurrent conflicts. The processing status of the corresponding voucher in the cache is changed to "successful", indicating that the voucher has been processed.

在修改账户余额的同时或之后,保存账户资金的变动流水记录。变动流水记录包含变动前的账户余额、变动金额、变动后的账户余额等信息。使用分布式锁进行保护,以确保数据的一致性。When modifying the account balance or after modifying the account balance, save the change record of the account funds. The change record contains information such as the account balance before the change, the change amount, and the account balance after the change. Use distributed locks for protection to ensure data consistency.

若系统在缓存入账流程中发生错误或异常,如数据库操作失败、缓存更新失败等,触发事务回滚机制并记录错误日志。事务回滚确保所有已修改的数据恢复到操作前的状态,保持数据的一致性。错误日志以便后续进行问题排查和修复。If an error or exception occurs in the cache entry process, such as database operation failure, cache update failure, etc., the transaction rollback mechanism is triggered and the error log is recorded. Transaction rollback ensures that all modified data is restored to the state before the operation to maintain data consistency. Error logs are used for subsequent troubleshooting and repair.

本方法通过引入缓存数据库进行缓存处理,能够显著减少直接对系统数据库的读写操作,从而降低了数据库的负担,在处理业务请求时,通过参数校验、请求流水存储和缓存操作凭证存储等步骤,确保了数据的完整性和一致性。由于缓存处理能够提高数据处理速度,用户发起的业务请求能够得到更快的响应,提高了高并发热点数据的响应速度和并发处理能力。This method can significantly reduce the direct read and write operations on the system database by introducing a cache database for cache processing, thereby reducing the burden on the database. When processing business requests, the integrity and consistency of the data are ensured through steps such as parameter verification, request flow storage, and cache operation credential storage. Since cache processing can increase the data processing speed, business requests initiated by users can get faster responses, which improves the response speed and concurrent processing capability of high-concurrency hotspot data.

图4示出了一种基于高并发热点数据处理装置200的结构框图。FIG. 4 shows a structural block diagram of a high-concurrency hotspot data processing device 200 .

如图4所示,一种基于高并发热点数据处理装置200主要包括:As shown in FIG4 , a high-concurrency hotspot data processing device 200 mainly includes:

获取模块201,用于获取针对待交易订单的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;The acquisition module 201 is used to acquire a business request for the pending transaction order, wherein the business request includes a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, wherein the business type is any one of: deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze;

参数校验模块202,用于对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求的请求时间、业务类型、用户信息和请求账户标识;The parameter verification module 202 is used to perform parameter validity verification on the user information of the service request and to perform serial number anti-duplicate verification on the request serial number. After the service request passes the verification, the request serial number of the service request is stored in the system database. The request serial number is used to record the request time, service type, user information and request account identifier of the service request;

缓存处理模块203,用于在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;The cache processing module 203 is used to perform cache update processing on the account information in the cache database based on the business type, the request account identifier, the amount information corresponding to the business type and the preset cache data processing rules after the request flow is successfully stored;

存储模块204,用于在缓存更新处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。The storage module 204 is used to store the cache operation credentials corresponding to the business request in the system database after the cache update process is successful, and return the operation success result to the user corresponding to the business request.

可选地,缓存处理模块203包括:Optionally, the cache processing module 203 includes:

第一查询子模块,用于基于所述请求账户标识在缓存数据库中进行账户查询;A first query submodule, configured to perform an account query in a cache database based on the request account identifier;

资金验证子模块,用于若在所述缓存数据库中查询到所述请求账户标识的账户信息,则基于所述业务类型和所述业务类型对应的金额信息,对查询到的账户信息进行资金验证;A fund verification submodule, configured to perform fund verification on the queried account information based on the business type and the amount information corresponding to the business type if the account information of the request account identifier is queried in the cache database;

签名验证子模块,用于在所述查询到的账户信息进行资金验证通过之后,对所述缓存数据库进行签名验证;A signature verification submodule, used to perform signature verification on the cache database after the queried account information passes the fund verification;

余额计算子模块,用于在所述缓存数据库进行签名验证通过之后,基于所述业务类型、所述业务类型对应的金额信息和所述账户信息,计算账户余额,并根据所述账户余额在所述缓存数据库中修改账户信息的缓存数据,得到新的账户信息;a balance calculation submodule, configured to calculate the account balance based on the business type, the amount information corresponding to the business type and the account information after the signature verification is passed in the cache database, and to modify the cache data of the account information in the cache database according to the account balance to obtain new account information;

入账凭证存储子模块,用于基于所述新的账户信息、操作时间、业务类型、业务类型对应的金额信息生成操作流水,并将所述业务请求的操作流水存储至缓存数据库中。The entry voucher storage submodule is used to generate an operation flow based on the new account information, operation time, business type, and amount information corresponding to the business type, and store the operation flow of the business request in a cache database.

可选地,缓存处理模块203还包括:Optionally, the cache processing module 203 further includes:

缓存重建子模块,用于若在所述缓存数据库中未查询到所述请求账户标识的账户信息,则开启异步线程,所述异步线程包括第一线程和第二线程;a cache reconstruction submodule, configured to start an asynchronous thread if the account information of the requesting account identifier is not found in the cache database, the asynchronous thread comprising a first thread and a second thread;

所述第一线程,用于执行缓存重建的步骤,所述缓存重建包括:向缓存重建服务器发送进行缓存重建请求,所述缓存重建请求包括请求账号标识,以使所述缓存重建服务器基于所述请求账户标识对应的账户信息进行缓存重建;The first thread is used to perform a cache reconstruction step, wherein the cache reconstruction includes: sending a cache reconstruction request to a cache reconstruction server, wherein the cache reconstruction request includes a request account identifier, so that the cache reconstruction server performs cache reconstruction based on account information corresponding to the request account identifier;

第二查询子模块,用于在所述第一线程执行缓存重建的步骤时,第二线程开始等待预设时间,在等待预设时间之后,基于所述请求账户标识在所述缓存数据库中进行账户查询;A second query submodule, configured to, when the first thread executes the cache rebuilding step, cause the second thread to start waiting for a preset time, and after waiting for the preset time, perform an account query in the cache database based on the request account identifier;

若查询失败,则重复执行等待预设时间的步骤,若查询次数达到预设次数后,查询失败,向所述业务请求对应的用户返回操作失败结果。If the query fails, the step of waiting for a preset time is repeated. If the query fails after the preset number of times is reached, the operation failure result is returned to the user corresponding to the business request.

可选地,所述请求流水包括请求记录状态,基于高并发热点数据处理装置200还包括记录模块:Optionally, the request flow includes a request record status, and the high-concurrency hotspot data processing device 200 further includes a recording module:

第一记录模块,用于在所述系统数据库中保存所述账号信息对应的缓存操作凭证之后,还包括:将所述请求流水的请求记录状态记录为处理成功。The first recording module is used for, after saving the cache operation credentials corresponding to the account information in the system database, further comprising: recording the request record status of the request flow as successful processing.

可选地,基于高并发热点数据处理装置200还包括异常检测模块;Optionally, the high-concurrency hotspot data processing device 200 further includes an anomaly detection module;

异常检测模块,用于在缓存处理失败之后,基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测,所述异常内容包括网络中断、数据库连接失败、操作失败、超时,所述操作失败包括余额不足、状态止出和账户不存在中的至少一项。The anomaly detection module is used to perform abnormal content detection on the business request that failed the cache processing based on the preset scheduled task after the cache processing fails. The abnormal content includes network interruption, database connection failure, operation failure, and timeout. The operation failure includes at least one of insufficient balance, status stop, and account non-existence.

可选的,基于高并发热点数据处理装置200还包括第二记录模块;Optionally, the high-concurrency hotspot data processing device 200 further includes a second recording module;

第二记录模块,用于在所述基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测之后,获取所述业务请求对应的缓存处理失败的异常内容类型;A second recording module is used to obtain the abnormal content type of the cache processing failure corresponding to the business request after performing abnormal content detection on the business request that failed to be cached based on the preset timed task;

判断所述业务请求缓存处理失败的异常内容类型是否为余额不足类型、状态止出类型、账户不存在类型中的任一种;Determine whether the abnormal content type of the failure of the business request cache processing is any one of the insufficient balance type, the status stop type, and the account does not exist type;

若是,则将所述业务请求对应的请求流水的请求记录状态记录为处理失败;If yes, the request record status of the request flow corresponding to the business request is recorded as processing failure;

若否,则将所述业务请求对应的请求流水的请求记录状态记录为处理中。If not, the request record status of the request flow corresponding to the business request is recorded as being processed.

可选地,所述缓存操作凭证包括处理状态和凭证创建时间,基于高并发热点数据处理装置200还包括缓冲入账模块;Optionally, the cache operation voucher includes a processing status and a voucher creation time, and the high-concurrency hotspot data processing device 200 further includes a buffer entry module;

缓充入账模块,具体用于:The slow charging module is specifically used for:

基于第一预设的时间间隔,在所述系统数据库中查询符合预设条件的缓存操作凭证,所述预设条件为所述缓存操作凭证的处理状态为未处理,所述缓存操作凭证的存储时间为在预设时间内的缓存操作凭证,所述预设时间基于当前时间和第二预设的时间间隔计算得出;Based on a first preset time interval, querying the system database for a cache operation credential that meets a preset condition, wherein the preset condition is that the processing status of the cache operation credential is unprocessed, and the storage time of the cache operation credential is the cache operation credential within a preset time, wherein the preset time is calculated based on the current time and a second preset time interval;

若在所述系统数据库中查询到符合预设条件的缓存操作凭证,则按照缓存操作凭证的请求账号,对每个缓存操作凭证进行划分,并采用多线程并行处理每个请求账号对应的至少一个缓存操作凭证;If a cache operation credential that meets the preset conditions is found in the system database, each cache operation credential is divided according to the requesting account of the cache operation credential, and at least one cache operation credential corresponding to each requesting account is processed in parallel using multiple threads;

对于每个线程,基于所述请求账户标识在系统数据库中获取账户信息;For each thread, obtaining account information in a system database based on the request account identifier;

对于每个线程,基于预设的余额计算公式、所述账号信息和所述请求账号对应的至少一个缓存操作凭证,对请求账户标识进行金额汇总,得到所述请求账号的余额信息;For each thread, based on a preset balance calculation formula, the account information and at least one cache operation voucher corresponding to the requesting account, the amount of the requesting account identifier is aggregated to obtain the balance information of the requesting account;

对于每个线程,基于所述账户余额,在所述系统数据库中修改所述请求账户标识对应的账户信息;For each thread, based on the account balance, modify the account information corresponding to the requesting account identifier in the system database;

对于每个线程,在所述请求账户标识对应的账户信息修改成功之后,修改所述请求账户标识对应的至少一个缓存操作凭证的状态为处理成功,并在所述系统数据库中存储所述请求账号对应的变动流水。For each thread, after the account information corresponding to the request account identifier is modified successfully, the status of at least one cache operation credential corresponding to the request account identifier is modified to be processed successfully, and the change flow corresponding to the request account is stored in the system database.

在一个例子中,以上任一装置中的模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个专用集成电路(application specificintegratedcircuit,ASIC),或,一个或多个数字信号处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA),或这些集成电路形式中至少两种的组合。In one example, the module in any of the above devices can be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASICs), or, one or more digital signal processors (DSPs), or, one or more field programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms.

再如,当装置中的模块可以通过处理元件调度程序的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。For another example, when the modules in the device can be implemented in the form of a processing element scheduling program, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call a program. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).

在本申请中可能出现的对各种消息/信息/设备/网元/系统/装置/动作/操作/流程/概念等各类客体进行了赋名,可以理解的是,这些具体的名称并不构成对相关客体的限定,所赋名称可随着场景,语境或者使用习惯等因素而变更,对本申请中技术术语的技术含义的理解,应主要从其在技术方案中所体现/执行的功能和技术效果来确定。Various objects such as various messages/information/equipment/network elements/systems/devices/actions/operations/processes/concepts that may appear in this application are named. It can be understood that these specific names do not constitute a limitation on the relevant objects. The names assigned may change with factors such as scenarios, contexts or usage habits. The understanding of the technical meaning of the technical terms in this application should be mainly determined from the functions and technical effects embodied/executed in the technical scheme.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的模块及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

图5为本申请实施例一种电子设备300的结构框图。FIG5 is a structural block diagram of an electronic device 300 according to an embodiment of the present application.

如图5所示,电子设备300包括处理器301和存储器302,还可以进一步包括信息输入/信息输出(I/O)接口303以及通信组件304中的一种或多种。As shown in FIG. 5 , the electronic device 300 includes a processor 301 and a memory 302 , and may further include one or more of an information input/information output (I/O) interface 303 and a communication component 304 .

其中,处理器301用于控制电子设备300的整体操作,以完成上述的基于高并发热点数据处理方法中的全部或部分步骤;存储器302用于存储各种类型的数据以支持在电子设备300的操作,这些数据例如可以包括用于在该电子设备300上操作的任何应用程序或方法的指令,以及应用程序相关的数据。该存储器302可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(Static Random Access Memory,SRAM)、电可擦除可编程只读存储器(Electrically Erasable Programmable Read-OnlyMemory,EEPROM)、可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM)、可编程只读存储器(Programmable Read-Only Memory,PROM)、只读存储器(Read-OnlyMemory,ROM)、磁存储器、快闪存储器、磁盘或光盘中的一种或多种。The processor 301 is used to control the overall operation of the electronic device 300 to complete all or part of the steps in the above-mentioned high-concurrency hot spot data processing method; the memory 302 is used to store various types of data to support the operation of the electronic device 300, and these data may include, for example, instructions for any application or method used to operate on the electronic device 300, and application-related data. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), programmable read-only memory (Programmable Read-Only Memory, PROM), read-only memory (Read-Only Memory, ROM), magnetic memory, flash memory, magnetic disk or optical disk.

I/O接口303为处理器301和其他接口模块之间提供接口,上述其他接口模块可以是键盘,鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件304用于测试电子设备300与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(NearField Communication,简称NFC),2G、3G或4G,或它们中的一种或几种的组合,因此相应的该通信组件304可以包括:Wi-Fi部件,蓝牙部件,NFC部件。The I/O interface 303 provides an interface between the processor 301 and other interface modules, and the above-mentioned other interface modules can be keyboards, mice, buttons, etc. These buttons can be virtual buttons or physical buttons. The communication component 304 is used to test the wired or wireless communication between the electronic device 300 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 304 can include: Wi-Fi components, Bluetooth components, NFC components.

通信总线305可包括一通路,在上述组件之间传送信息。通信总线305可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(ExtendedIndustry Standard Architecture,扩展工业标准结构)总线等。通信总线305可以分为地址总线、数据总线、控制总线等。The communication bus 305 may include a path to transmit information between the above components. The communication bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus 305 may be divided into an address bus, a data bus, a control bus, etc.

电子设备300可以被一个或多个应用专用集成电路(Application SpecificIntegrated Circuit,简称ASIC)、数字信号处理器(Digital Signal Processor,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field ProgrammableGate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述实施例给出的基于高并发热点数据处理方法。The electronic device 300 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the high-concurrency hot spot data processing method given in the above embodiment.

电子设备300可以包括但不限于数字广播接收器、PDA(个人数字助理)、PMP(便携式多媒体播放器)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端,还可以为服务器等。The electronic device 300 may include but is not limited to mobile terminals such as digital broadcast receivers, PDAs (personal digital assistants), PMPs (portable multimedia players), etc., and fixed terminals such as digital TVs, desktop computers, etc., and may also be servers, etc.

下面对本申请实施例提供的计算机可读存储介质进行介绍,下文描述的计算机可读存储介质与上文描述的基于高并发热点数据处理方法可相互对应参照。The computer-readable storage medium provided in the embodiment of the present application is introduced below. The computer-readable storage medium described below and the high-concurrency hot spot data processing method described above can correspond to each other.

本申请还提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述的基于高并发热点数据处理方法的步骤。The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned high-concurrency hot spot data processing method are implemented.

该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。The terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed, or also includes elements inherent to such process, method, article, or apparatus.

以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的申请范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离前述申请构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中申请的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of application involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned application concept. For example, the above features are replaced with (but not limited to) technical features with similar functions applied in the present application.

Claims (10)

1.一种基于高并发热点数据处理方法,其特征在于,所述方法包括:1. A method for processing high-concurrency hotspot data, characterized in that the method comprises: 获取针对待交易订单的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;Obtaining a business request for the order to be traded, the business request including a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, the business type being any one of deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze; 对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求处理过程中的信息;Performing parameter validity check on the user information of the service request and performing serial number anti-duplicate check on the request serial number. After the service request passes the verification, the request serial number of the service request is stored in the system database. The request serial number is used to record information during the service request processing; 在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;After the request flow is successfully stored, based on the business type, the request account identifier, the amount information corresponding to the business type and the preset cache data processing rules, the account information in the cache database is cached and updated; 在缓存更新处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。After the cache update process is successful, the cache operation credentials corresponding to the business request are stored in the system database, and the operation success result is returned to the user corresponding to the business request. 2.根据权利要求1所述的一种基于高并发热点数据处理方法,其特征在于,所述基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理,包括:2. A method for processing data based on a high-concurrency hotspot according to claim 1, characterized in that the cache update processing of the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules comprises: 基于所述请求账户标识在缓存数据库中进行账户查询;Performing an account query in a cache database based on the request account identifier; 若在所述缓存数据库中查询到所述请求账户标识的账户信息,则基于所述业务类型和所述业务类型对应的金额信息,对查询到的账户信息进行资金验证;If the account information of the requested account identifier is found in the cache database, then based on the business type and the amount information corresponding to the business type, the found account information is verified for funds; 在所述查询到的账户信息进行资金验证通过之后,对所述缓存数据库进行签名验证;After the queried account information passes the fund verification, performing signature verification on the cache database; 在所述缓存数据库进行签名验证通过之后,基于所述业务类型、所述业务类型对应的金额信息和所述账户信息,计算账户余额,并根据所述账户余额在所述缓存数据库中修改账户信息的缓存数据,得到新的账户信息;After the signature verification is passed in the cache database, the account balance is calculated based on the business type, the amount information corresponding to the business type and the account information, and the cache data of the account information is modified in the cache database according to the account balance to obtain new account information; 基于所述新的账户信息、操作时间、业务类型、业务类型对应的金额信息生成操作流水,并将所述业务请求的操作流水存储至缓存数据库中。An operation flow is generated based on the new account information, operation time, business type, and amount information corresponding to the business type, and the operation flow of the business request is stored in a cache database. 3.根据权利要求2所述的一种基于高并发热点数据处理方法,其特征在于,所述基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理,还包括:3. A method for processing data based on high-concurrency hotspots according to claim 2, characterized in that the cache update processing of the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and the preset cache data processing rules further comprises: 若在所述缓存数据库中未查询到所述请求账户标识的账户信息,则开启异步线程,所述异步线程包括第一线程和第二线程;If the account information of the requesting account identifier is not found in the cache database, an asynchronous thread is started, where the asynchronous thread includes a first thread and a second thread; 所述第一线程,用于执行缓存重建的步骤,所述缓存重建包括:向缓存重建服务器发送进行缓存重建请求,所述缓存重建请求包括请求账号标识,以使所述缓存重建服务器基于所述请求账户标识对应的账户信息进行缓存重建;The first thread is used to perform a cache reconstruction step, wherein the cache reconstruction includes: sending a cache reconstruction request to a cache reconstruction server, wherein the cache reconstruction request includes a request account identifier, so that the cache reconstruction server performs cache reconstruction based on account information corresponding to the request account identifier; 在所述第一线程执行缓存重建的步骤时,第二线程开始等待预设时间,在等待预设时间之后,基于所述请求账户标识在所述缓存数据库中进行账户查询;When the first thread executes the cache rebuilding step, the second thread starts to wait for a preset time, and after waiting for the preset time, performs an account query in the cache database based on the request account identifier; 若查询失败,则重复执行等待预设时间的步骤,若查询次数达到预设次数后,查询失败,向所述业务请求对应的用户返回操作失败结果。If the query fails, the step of waiting for a preset time is repeated. If the query fails after the preset number of times is reached, the operation failure result is returned to the user corresponding to the business request. 4.根据权利要求1所述的一种基于高并发热点数据处理方法,其特征在于,所述请求流水包括请求记录状态,在所述系统数据库中保存所述账号信息对应的缓存操作凭证之后,还包括:4. A method for processing data based on high-concurrency hotspots according to claim 1, characterized in that the request flow includes a request record status, and after the cache operation credentials corresponding to the account information are saved in the system database, it also includes: 将所述请求流水的请求记录状态记录为处理成功。The request record status of the request pipeline is recorded as successful processing. 5.根据权利要求1所述的一种基于高并发热点数据处理方法,其特征在于,在缓存处理失败之后,所述方法还包括:5. The method for processing data based on high-concurrency hotspots according to claim 1, characterized in that after cache processing fails, the method further comprises: 基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测,所述异常内容包括网络中断、数据库连接失败、操作失败、超时,所述操作失败包括余额不足、状态止出和账户不存在中的至少一项。Based on preset timed tasks, abnormal content detection is performed on business requests that fail to be processed by the cache. The abnormal content includes network interruption, database connection failure, operation failure, and timeout. The operation failure includes at least one of insufficient balance, status stop, and account non-existence. 6.根据权利要求5所述的一种基于高并发热点数据处理方法,其特征在于,所述请求流水包括请求记录状态,在所述基于预设的定时任务,对缓存处理失败的业务请求进行异常内容检测之后,还包括:6. A method for processing data based on high-concurrency hotspots according to claim 5, characterized in that the request flow includes a request record status, and after performing abnormal content detection on the business request that failed to be processed by the cache based on the preset timed task, it also includes: 获取所述业务请求对应的缓存处理失败的异常内容类型;Obtain the abnormal content type of cache processing failure corresponding to the business request; 判断所述业务请求缓存处理失败的异常内容类型是否为余额不足类型、状态止出类型、账户不存在类型中的任一种;Determine whether the abnormal content type of the failure of the business request cache processing is any one of the insufficient balance type, the status stop type, and the account does not exist type; 若是,则将所述业务请求对应的请求流水的请求记录状态记录为处理失败;If yes, the request record status of the request flow corresponding to the business request is recorded as processing failure; 若否,则将所述业务请求对应的请求流水的请求记录状态记录为处理中。If not, the request record status of the request flow corresponding to the business request is recorded as being processed. 7.根据权利要求1所述的一种基于高并发热点数据处理方法,其特征在于,所述缓存操作凭证包括处理状态和凭证创建时间,所述方法还包括:7. A method for processing data based on high-concurrency hotspots according to claim 1, characterized in that the cache operation credential includes a processing status and a credential creation time, and the method further comprises: 基于第一预设的时间间隔,在所述系统数据库中查询符合预设条件的缓存操作凭证,所述预设条件为所述缓存操作凭证的处理状态为未处理,所述缓存操作凭证的存储时间为在预设时间内的缓存操作凭证,所述预设时间基于当前时间和第二预设的时间间隔计算得出;Based on a first preset time interval, querying the system database for a cache operation credential that meets a preset condition, wherein the preset condition is that the processing status of the cache operation credential is unprocessed, and the storage time of the cache operation credential is the cache operation credential within a preset time, wherein the preset time is calculated based on the current time and a second preset time interval; 若在所述系统数据库中查询到符合预设条件的缓存操作凭证,则按照缓存操作凭证的请求账号,对每个缓存操作凭证进行划分,并采用多线程并行处理每个请求账号对应的至少一个缓存操作凭证;If a cache operation credential that meets the preset conditions is found in the system database, each cache operation credential is divided according to the requesting account of the cache operation credential, and at least one cache operation credential corresponding to each requesting account is processed in parallel using multiple threads; 对于每个线程,基于所述请求账户标识在系统数据库中获取账户信息;For each thread, obtaining account information in a system database based on the request account identifier; 对于每个线程,基于预设的余额计算公式、所述账号信息和所述请求账号对应的至少一个缓存操作凭证,对请求账户标识进行金额汇总,得到所述请求账号的余额信息;For each thread, based on a preset balance calculation formula, the account information and at least one cache operation voucher corresponding to the requesting account, the amount of the requesting account identifier is aggregated to obtain the balance information of the requesting account; 对于每个线程,基于所述账户余额,在所述系统数据库中修改所述请求账户标识对应的账户信息;For each thread, based on the account balance, modify the account information corresponding to the requesting account identifier in the system database; 对于每个线程,在所述请求账户标识对应的账户信息修改成功之后,修改所述请求账户标识对应的至少一个缓存操作凭证的状态为处理成功,并在所述系统数据库中存储所述请求账号对应的变动流水。For each thread, after the account information corresponding to the request account identifier is modified successfully, the status of at least one cache operation credential corresponding to the request account identifier is modified to be processed successfully, and the change flow corresponding to the request account is stored in the system database. 8.根据权利要求1所述的一种基于高并发热点数据处理装置,其特征在于,包括:8. The high-concurrency hotspot data processing device according to claim 1, characterized in that it comprises: 获取模块,用于获取针对待交易订单的业务请求,所述业务请求包括请求流水号、业务类型、用户信息、请求账户标识和所述业务类型对应的金额信息,所述业务类型为入账、出账、冻结、解冻、批量入账、批量出账、批量冻结和批量解冻中的任一种;an acquisition module, used to acquire a business request for a pending transaction order, wherein the business request includes a request serial number, a business type, user information, a request account identifier, and amount information corresponding to the business type, wherein the business type is any one of: deposit, withdrawal, freeze, unfreeze, batch deposit, batch withdrawal, batch freeze, and batch unfreeze; 参数校验模块,用于对所述业务请求的用户信息进行参数合法性校验以及对请求流水号进行流水防重校验,在所述业务请求校验通过之后,将所述业务请求的请求流水存储至系统数据库中,所述请求流水用于记录所述业务请求的请求时间、业务类型、用户信息和请求账户标识;A parameter verification module is used to perform parameter legitimacy verification on the user information of the service request and to perform serial number anti-duplicate verification on the request serial number. After the service request passes the verification, the request serial number of the service request is stored in the system database. The request serial number is used to record the request time, service type, user information and request account identifier of the service request; 缓存处理模块,用于在所述请求流水存储成功之后,基于所述业务类型、请求账户标识、所述业务类型对应的金额信息和预设的缓存数据处理规则,对缓存数据库中的账户信息进行缓存更新处理;A cache processing module, configured to perform cache update processing on the account information in the cache database based on the business type, the requesting account identifier, the amount information corresponding to the business type and a preset cache data processing rule after the request flow is successfully stored; 存储模块,用于在缓存处理成功之后,存储所述业务请求对应的缓存操作凭证至系统数据库,并向所述业务请求对应的用户返回操作成功结果。The storage module is used to store the cache operation credentials corresponding to the business request in the system database after the cache processing is successful, and return the operation success result to the user corresponding to the business request. 9.一种电子设备,其特征在于,包括处理器,所述处理器与存储器耦合;9. An electronic device, comprising a processor, wherein the processor is coupled to a memory; 所述处理器用于执行所述存储器中存储的计算机程序,以使得所述电子设备执行如权利要求1至7任一项所述的方法。The processor is configured to execute a computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 7. 10.一种计算机可读存储介质,其特征在于,包括计算机程序或指令,当所述计算机程序或指令在计算机上运行时,使得所述计算机执行如权利要求1-7任一项所述的方法。10. A computer-readable storage medium, characterized in that it comprises a computer program or an instruction, and when the computer program or the instruction is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 7.
CN202410357717.5A 2024-03-27 2024-03-27 Data processing method, device, equipment and medium based on high concurrency point Pending CN118296044A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410357717.5A CN118296044A (en) 2024-03-27 2024-03-27 Data processing method, device, equipment and medium based on high concurrency point

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410357717.5A CN118296044A (en) 2024-03-27 2024-03-27 Data processing method, device, equipment and medium based on high concurrency point

Publications (1)

Publication Number Publication Date
CN118296044A true CN118296044A (en) 2024-07-05

Family

ID=91673700

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410357717.5A Pending CN118296044A (en) 2024-03-27 2024-03-27 Data processing method, device, equipment and medium based on high concurrency point

Country Status (1)

Country Link
CN (1) CN118296044A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105389209A (en) * 2015-12-25 2016-03-09 中国建设银行股份有限公司 Asynchronous batch task processing method and system
US20170147638A1 (en) * 2015-11-24 2017-05-25 Sap Se Atomic visibility switch for transactional cache invalidation
CN112052264A (en) * 2020-08-05 2020-12-08 北京五八信息技术有限公司 Business data query method and device, electronic equipment and readable storage medium
CN112347111A (en) * 2019-12-05 2021-02-09 北京沃东天骏信息技术有限公司 Data updating method and device
WO2022022105A1 (en) * 2020-07-28 2022-02-03 苏宁易购集团股份有限公司 Data acquisition method based on local cache and distributed cache, and application server
CN114782184A (en) * 2022-04-24 2022-07-22 中国工商银行股份有限公司 Method and device for real-time decentralized processing of hot accounts
CN116703388A (en) * 2023-05-29 2023-09-05 中国银行股份有限公司 Data processing method and device of hot spot account, storage medium and electronic equipment
CN117390112A (en) * 2022-07-04 2024-01-12 腾讯科技(深圳)有限公司 Data synchronization method, device, storage medium and computer equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170147638A1 (en) * 2015-11-24 2017-05-25 Sap Se Atomic visibility switch for transactional cache invalidation
CN105389209A (en) * 2015-12-25 2016-03-09 中国建设银行股份有限公司 Asynchronous batch task processing method and system
CN112347111A (en) * 2019-12-05 2021-02-09 北京沃东天骏信息技术有限公司 Data updating method and device
WO2022022105A1 (en) * 2020-07-28 2022-02-03 苏宁易购集团股份有限公司 Data acquisition method based on local cache and distributed cache, and application server
CN112052264A (en) * 2020-08-05 2020-12-08 北京五八信息技术有限公司 Business data query method and device, electronic equipment and readable storage medium
CN114782184A (en) * 2022-04-24 2022-07-22 中国工商银行股份有限公司 Method and device for real-time decentralized processing of hot accounts
CN117390112A (en) * 2022-07-04 2024-01-12 腾讯科技(深圳)有限公司 Data synchronization method, device, storage medium and computer equipment
CN116703388A (en) * 2023-05-29 2023-09-05 中国银行股份有限公司 Data processing method and device of hot spot account, storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CATT: "R2-081669 "Multi Layer interaction modeling for connection"", 3GPP TSG_RAN\\WG2_RL2, no. 2, 25 March 2008 (2008-03-25) *

Similar Documents

Publication Publication Date Title
Nathan et al. Blockchain meets database: Design and implementation of a blockchain relational database
CA3147339C (en) Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof
CN112685391B (en) Service data migration method and device, computer equipment and storage medium
CN114742630A (en) Method for processing business documents and corresponding systems, devices and media
CN115271694A (en) Order payment method and system
CN113835780A (en) Incident response method and device
US11483158B2 (en) Distributed ledger device, distributed ledger system, and distributed ledger management method
CN112559300A (en) Fault reason determining system, method and device
CN114579260B (en) A transaction processing method and system
CN112035495A (en) Data synchronization method, device, server and storage medium
CN112099934A (en) Batch processing method, system, computer equipment and storage medium
CN114969077A (en) A business data processing method and device
CN112434050B (en) Data synchronization method and device of power grid business processing system and business processing system
US20220131704A1 (en) Blockchain machine compute acceleration engine
CN118296044A (en) Data processing method, device, equipment and medium based on high concurrency point
CN113592645B (en) Data verification methods and devices
US20230069165A1 (en) Byzantine fault tolerant pre-preprocessing for state machine replication
CN116128658A (en) Blockchain-based data storage insurance method, device, equipment and storage medium
CN114971903A (en) Batch task processing method and device
CN119863303A (en) Bank system online account concurrent transaction method based on summary accounting
CN110750550A (en) Data verification method, data verification device, storage medium and electronic equipment
CN106372178A (en) Transaction file processing method and device as well as server
CN117149745A (en) Report form checking method, device, equipment and storage medium of new and old systems
CN117891794A (en) Log generation method and device, terminal equipment and storage medium
CN117294722A (en) Cross-chain transaction method and related products

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
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载