Data integrity processing method and system based on advertisement putting
By using the Canal data migration tool and message queue mechanism between the cache and the database, the problem of data inconsistency under high concurrency is solved, data consistency and system self-healing capabilities are achieved, and operation and maintenance costs are reduced.
Patent Information
- Application Number
- CN202410795410.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-01
AI Technical Summary
The existing technology cannot ensure data consistency between the cache and the database under high concurrency conditions, resulting in data inconsistency problems.
By using the Canal data migration tool to subscribe to the binlog log of the database, the target data and .key data that need to be deleted are obtained in real time, and the cached data is parsed and tried to be deleted in the cache deletion system. If it fails, the message is sent to the message queue and periodically re-deleted. Message Queuing gets and re-performs the delete operation until it succeeds.
It achieves the consistency of cache and database data, improves the fault tolerance and reliability of the system, and reduces operation and maintenance costs and the need for manual intervention.
Smart Images

Figure CN118733629A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, system, intelligent terminal and storage medium based on advertising data integrity processing. Background Art
[0002] Advertising involves a lot of data processing. In order to improve the efficiency of data processing, cache is used to store data that users access frequently, and then a copy is saved to a search engine-type database. However, cache and database are different types of data storage engines, and transactions cannot be used in one method to ensure data consistency and integrity. Especially in the case of high concurrency, data inconsistency will occur, and data inconsistency between cache (Redis) and database (MySQL) is prone to occur.
[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method, system, intelligent terminal and storage medium based on the integrity processing of advertising data in view of the above-mentioned defects of the prior art. The present invention can ensure the consistency and integrity of data by using transactions.
[0005] The technical solution adopted by the present invention to solve the problem is as follows:
[0006] A method for processing advertisement delivery data integrity, comprising the following steps:
[0007] Acquire the advertisement data to be updated, and update the advertisement data into the database;
[0008] The control database records the data update operation information in the binlog log;
[0009] Use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache;
[0010] The cache deletion system obtains the target data and .key data that need to be deleted from the cache of the canal data migration tool, parses the target .key data, and attempts to delete the cache;
[0011] If the deletion fails, the deletion failure message is sent to the message queue;
[0012] Control the cache deletion system to re-obtain the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again;
[0013] When the cache data is deleted successfully, the advertisement data is updated to the cache.
[0014] In the method for processing data integrity based on advertising delivery, the target data and .key data to be deleted are the data in the redis cache and the .key data in the redis cache to be deleted.
[0015] In the method for processing advertisement delivery data integrity, the step of obtaining advertisement data to be updated and updating the advertisement data into a database comprises:
[0016] Get the advertisement data to be updated, and update the advertisement data into the MySQL database.
[0017] In the method for processing data integrity based on advertising delivery, the step of controlling the database to update and record the operation information of data update in the binlog log includes:
[0018] Enable the binary log function in the database configuration to write update operation information into the binary log file;
[0019] Monitor data update operations in the database and record detailed information of each update operation in the binary log, including operation type, execution time, and affected data;
[0020] Select the appropriate binary log format based on your needs to ensure that the recorded operation information can meet subsequent needs.
[0021] The method for processing data integrity based on advertising delivery, wherein the step of using the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data to be deleted in the cache includes:
[0022] Use the Canal data migration tool to obtain real-time update operation information in the database, including insert, update, and delete operations, by subscribing to the database's binlog logs.
[0023] Identify the target data and .key data to be deleted in the cache through Canal, and obtain the target data and .key data to be deleted in the cache;
[0024] Subscribe to binlog logs through the Canal tool to achieve data synchronization and migration between the database and cache.
[0025] The method for processing the integrity of advertising data, wherein the cache deletion system obtains the target data and .key data to be deleted from the cache of the canal data migration tool, parses the target .key data, and attempts to delete the cache, comprises the following steps:
[0026] A cache deletion system is pre-set to manage cache data, and deletes the data in the cache by receiving information transmitted from the outside that the data needs to be deleted;
[0027] By subscribing to the data stream provided by the Canal tool, the cache deletion system is controlled to obtain the target data and .key data to be deleted from the Canal data migration tool;
[0028] The cache deletion system parses the received target .key data, determines the unique identifier of the cache data item to be deleted, and locates the specified data to be deleted;
[0029] Based on the parsed target .key data, the cache deletion system is controlled to try to delete the corresponding data item in the cache.
[0030] The method for processing data integrity based on advertisement delivery, wherein the control cache deletion system re-acquires the target data and .key data to be deleted from the cache from the message queue, parses the target .key data, and performs the deletion operation again includes the following steps:
[0031] The cache deletion system periodically checks the message queue to obtain messages that failed to be deleted before, including the target data to be deleted and the corresponding .key data;
[0032] Parse the target .key data to determine the cache data items that need to be deleted, and ensure that the specified data is deleted accurately;
[0033] Re-execute the deletion operation, control the execution of the deletion operation again, and try to delete the corresponding data in the cache to ensure data consistency.
[0034] A system for processing advertisement delivery data integrity, wherein the system comprises:
[0035] An acquisition and update module, used for acquiring advertisement data to be updated, and updating the advertisement data into a database;
[0036] The log update module is used to control the database to update and record the operation information of data update in the binlog log;
[0037] Delete the data subscription acquisition module, which is used to use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache;
[0038] The first parsing and deletion module is used to control the cache deletion system to obtain the target data and .key data in the cache to be deleted in the canal data migration tool, parse the target .key data, and try to delete the cache;
[0039] A message sending control module, used for sending the message of failed deletion to the message queue when the deletion fails;
[0040] The second parsing and deleting module is used to control the cache deletion system to re-acquire the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again;
[0041] The cache update control module is used to update the advertisement data into the cache when the cache data is deleted successfully.
[0042] An intelligent terminal includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, including the method for executing any one of the methods described above.
[0043] A non-transitory computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described above.
[0044] Beneficial effects of the present invention: The present invention provides a method, system, intelligent terminal and storage medium based on advertising delivery data integrity processing. The present invention can ensure that the data in the cache is consistent with the data in the database by obtaining the target data to be deleted in real time and deleting the cache, thereby avoiding problems caused by data inconsistency and providing convenience for users.
[0045] And it has the following advantages: 1) Re-acquire and process the data that failed to be deleted from the message queue, so that the system has the ability to self-repair, improving the fault tolerance and reliability of the system. 2) By re-executing the deletion operation, the consistency of cache data and database data is guaranteed, avoiding the problems caused by data inconsistency. 3) It can automatically process the data that failed to be deleted, reducing the operation and maintenance costs and the need for manual intervention. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 It is a schematic diagram of the data processing architecture structure of the prior art.
[0048] Figure 2It is a processing flow diagram of the data processing architecture of the prior art.
[0049] Figure 3 It is a flow chart of a method for processing advertisement delivery data integrity provided by an embodiment of the present invention.
[0050] Figure 4 It is a flowchart of a method for processing advertisement delivery data integrity provided in specific application embodiment 1 of the present invention.
[0051] Figure 5 It is a flow chart of a method for processing advertisement delivery data integrity provided in specific application embodiment 2 of the present invention.
[0052] Figure 6 It is a principle block diagram of an embodiment of an advertisement delivery data integrity processing system provided by the present invention.
[0053] Figure 7 It is a block diagram of the internal structure principle of the intelligent terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0055] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0056] The data processing architecture of the existing technology, such as Figure 1 As shown in the figure, when a user requests data, he first checks the cache (Redis) to see if there is data. If there is no data in the cache (Redis), he then checks the MySQL database to see if there is data for the crowd. When the MySQL database is empty, the hit result is returned directly; when the MySQL database is not empty, the crowd data is written into the MySQL database and the hit result is fed back. In the previous example, when the cache (Redis) is checked first, the hit result is returned directly.
[0057] like Figure 1As shown in the figure, through multiple tests, it is found that this data processing architecture cannot guarantee the integrity of the data, especially in the case of high concurrency, which will lead to data inconsistency. In high-concurrency business scenarios, the database is the weakest link in user concurrent access in most cases. Therefore, it is necessary to use redis (cache database) as a buffer operation to allow the request to access redis first, rather than directly accessing databases such as MySQL; there is generally no problem with the cache reading step, but once it involves data update, database and cache update, data consistency problems between cache (Redis) and database (MySQL) are likely to occur.
[0058] The problem with this data processing structure is Figure 2 As shown, user A updates the crowd tag value T041605 in the MySQL database to 1, and user B subsequently updates the crowd tag value T041605 in the MySQL database to 2. Then user B updates the crowd tag in redis (cache) to T041605=2. User A fails to update the crowd tag in redis (cache) at the beginning. After user B completes the update, he wakes up from the freeze and updates the value of T041605 in redis to 1. The value of T041605 in redis (cache) should be 2, but now it is updated to 1, which is inconsistent with the value in the database, causing the user holding the tag to be unable to hit, which makes it easy for users to make mistakes when using data.
[0059] Among them, MySQL is an open source relational database that is widely used for back-end data storage and management of Web applications. It supports the SQL language and provides a reliable, high-performance data storage engine. MySQL can be used for a variety of different types of applications, from small websites to large enterprise applications.
[0060] In order to achieve the integrity of advertising data and solve the problem of data consistency between cache (Redis) and database (MySQL) in the embodiment of the present invention, the specific implementation is as follows: Figure 3 As shown, a method for processing advertisement delivery data integrity according to Embodiment 1 of the present invention includes the following steps:
[0061] Step S100: Acquire advertisement data to be updated, and update the advertisement data into a database;
[0062] In the embodiment of this step, obtaining the advertisement data to be updated and updating the advertisement data into the database refers to the process of obtaining the advertisement contents to be updated in the advertisement management system and updating the contents into the MySQL database for storage and management.
[0063] Specifically, the advertising data that needs to be updated can be determined based on strategies and needs. For example, based on the company's marketing strategy and demand analysis, it can be determined which advertisements need to be updated or changed. This may involve operations such as changing pictures, modifying copy, and updating links.
[0064] Then, the advertisement data that needs to be updated is extracted, for example, the advertisement data that needs to be updated is extracted from the advertisement management system, including information such as advertisement title, content, link, target audience, etc.
[0065] The data is then reviewed and modified, such as reviewing the extracted advertising data to ensure that the information is accurate. If necessary, the advertising content is modified or adjusted.
[0066] Then update the data to the database, for example, update the reviewed and modified advertising data to the database for real-time display and management.
[0067] The benefit of this step is that the advertising content can be updated in a timely manner: keeping the advertising content fresh and effective, and attracting more user clicks and conversions.
[0068] Step S200, the control database updates and records the operation information of data update in the binlog log;
[0069] In this step embodiment, controlling the database to record the operation information of data update in the binary log (binlog) is an important operation of database management, which is used to record the update operations in the database, including insert, update and delete operations. The specific implementation includes the following steps:
[0070] S201. Enable binary logging: Enable the binary logging function in the database configuration to ensure that the database can write update operation information into the binary log file.
[0071] S202, data update operation record: monitor the data update operation in the database, and record the detailed information of each update operation in the binary log, including the operation type, execution time, affected data, etc.
[0072] S203, log format selection: select an appropriate binary log format according to requirements, such as statement-based format or row-based format, to ensure that the recorded operation information can meet subsequent requirements.
[0073] S204. Log management and maintenance: Regularly manage and maintain binary logs, including regularly cleaning up old logs and monitoring log file size, to ensure the normal operation of the database.
[0074] This step embodiment has the following advantages:
[0075] 1) Recording update operation information can help with database data recovery and backup, ensuring data security and integrity. 2) Through binary log records, data synchronization and replication between databases can be achieved, ensuring data consistency between multiple databases. 3) Recording update operation information helps with troubleshooting and data auditing, tracking operation records, and ensuring the traceability and security of data operations.
[0076] Step S300: Use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache;
[0077] In this step, the Canal data migration tool is used to subscribe to the binary log (binlog) to obtain the target data and .key data to be deleted in the cache. The data synchronization and migration method mainly includes the following contents:
[0078] The Canal data migration tool is used in the embodiment of the present invention, wherein Canal is an open source database synchronization tool that can subscribe to the binlog log of the database and obtain the update operation information of the database in real time for data synchronization and migration.
[0079] Regarding binlog subscriptions, the Canal tool can obtain real-time update operation information occurring in the database, including insert, update, and delete operations, by subscribing to the database's binlog.
[0080] Regarding obtaining the target data and .key data that need to be deleted in the cache: In the embodiment of the present invention, Canal is used to identify the target data and .key data that need to be deleted in the cache, and the target data and .key data that need to be deleted in the cache are obtained, so that these data can be cleared from the cache in subsequent steps to ensure that the data in the cache is consistent with the data in the database.
[0081] Data synchronization and migration: By subscribing to binlog logs through the Canal tool, data synchronization and migration between the database and cache can be achieved to ensure data consistency and integrity.
[0082] In the embodiment of the present invention, the target data to be deleted is the data in the redis cache to be deleted. The .key data to be deleted is the .key data in the redis cache to be deleted.
[0083] For example, when an e-commerce platform uses Redis cache to speed up the reading of product information, they want to maintain the consistency of product information in the database and cache. By using the Canal data migration tool to subscribe to the database binlog log, you can obtain the update operation of product information in real time, identify the target data and .key data that need to be deleted, and clear the corresponding data in the cache in time to ensure that the product information in the database and cache is consistent. In this way, users can obtain the latest data when accessing product information, which improves the performance and user experience of the platform.
[0084] The benefits of this step embodiment are: 1) Using the Canal tool to subscribe to binlog logs can achieve real-time data synchronization, ensuring that the data in the database and cache remain consistent. 2) The target data and .key data that need to be deleted in the cache can be cleared in time to ensure data consistency and avoid problems caused by data inconsistency. 3) Data migration through the Canal tool can improve the efficiency and accuracy of data migration and save manpower and time costs.
[0085] Step S400: The cache deletion system obtains the target data and .key data in the cache to be deleted in the canal data migration tool, parses the target .key data, and attempts to delete the cache;
[0086] In this step, the cache deletion system obtains the target data and .key data in the cache that need to be deleted from the Canal data migration tool, parses the target .key data, and tries to delete the corresponding data item in the cache. The specific steps include:
[0087] The cache deletion system of the embodiment of the present invention is a system responsible for managing cache data, and performs a deletion operation on the data in the cache by receiving information transmitted from the outside that the data needs to be deleted.
[0088] Among them, by obtaining the data transmitted by the Canal data migration tool, specifically the cache deletion system obtains the target data and .key data to be deleted from the Canal data migration tool, which can be achieved by subscribing to the data stream provided by the Canal tool.
[0089] Then the target .key data is parsed. Specifically, the cache deletion system parses the received target .key data to determine the unique identifier of the cache data item to be deleted, ensuring accurate deletion of the specified data.
[0090] The cached data is then deleted. Specifically, based on the parsed target .key data, the cache deletion system attempts to delete the corresponding data item in the cache to maintain the consistency of the cache and the data in the database.
[0091] For example, an online video platform uses Redis cache to store video information. To improve the user experience, it is necessary to ensure that the video information in the cache is consistent with the information in the database. While the Canal data migration tool transmits the video information to be deleted, the cache deletion system obtains the target data and parses the target .key data to determine the cache key of the video information to be deleted. Subsequently, the cache deletion system attempts to delete the corresponding video information data item in the cache to maintain data consistency. In this way, users can obtain the latest information when accessing videos, which improves the performance of the platform and enhances the user experience.
[0092] In the embodiment of this step, by obtaining the target data to be deleted in real time and deleting the cache, it is possible to ensure that the data in the cache is consistent with the data in the database, avoiding problems caused by data inconsistency. And regularly deleting unnecessary cache data can free up storage space, improve cache efficiency, and ensure the normal operation of the cache system. By parsing the target .key data, it is possible to ensure accurate deletion of specified data items, avoid accidental or missed deletion of data, and ensure the accuracy of data operations.
[0093] Step S500: When the deletion fails, the message of the deletion failure is sent to the message queue;
[0094] In the embodiment of the present invention, in this step, when the cache deletion system fails to delete the cache data, a message indicating the deletion failure is sent to the message queue. The specific implementation includes the following steps:
[0095] S501: When the cache deletion system attempts to delete cache data, if the deletion fails due to network failure, cache service failure or other reasons, the system will perform error processing.
[0096] S502: When the deletion fails, the deletion failure message is sent to the message queue. The message queue, as a middleware, can save these failed deletion requests for subsequent remedial processing.
[0097] S503, sending the deletion failure message to the message queue is an asynchronous processing method, so that the cache deletion system can respond quickly and continue to process the next request without being blocked on the deletion failure request.
[0098] In the embodiment of this step, by sending the failed deletion message to the message queue, asynchronous processing can be achieved to ensure the efficient operation of the cache deletion system, and the system will not be blocked due to the failed deletion. And sending the failed deletion message to the message queue can avoid data loss and ensure that the deletion operation will be processed and repaired later. And when the deletion fails due to system failure or network problems, sending the message to the message queue helps to reprocess these failed operations and improve the reliability and stability of the system.
[0099] For example, when an online social platform uses Redis cache to store user friend relationships, the cache deletion system fails to delete the user's friend relationship data due to network problems. At this time, the embodiment of the present invention will send the failed deletion message to a message queue, such as RabbitMQ. Subsequently, these failed messages will be obtained from the message queue and the deletion operation will be retried to ensure that the user's friend relationship data is correctly deleted. In this way, even in the event of network failures or other problems, the system can ensure the accuracy and reliability of data operations, thereby improving the stability and fault tolerance of the system.
[0100] Step S600, controlling the cache deletion system to reacquire the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again;
[0101] In the steps of this embodiment, the cache deletion system will control to re-acquire the target data and .key data to be deleted from the message queue, and perform the deletion operation again after parsing these data. The specific embodiment of this step includes the following detailed steps:
[0102] S601. The cache deletion system periodically checks the message queue to obtain messages that failed to be deleted before, including the target data to be deleted and the corresponding .key data.
[0103] S602: These target .key data are parsed to determine the cache data items that need to be deleted, ensuring that the specified data is accurately deleted.
[0104] S603, re-execute the deletion operation, that is, control the deletion operation to be executed again, and try to delete the corresponding data in the cache to ensure data consistency.
[0105] The benefits of this step are: 1) Re-acquiring and processing the data that failed to be deleted from the message queue, enabling the system to have the ability to self-repair, improving the system's fault tolerance and reliability. 2) By re-executing the deletion operation, the consistency of cache data and database data is guaranteed, avoiding problems caused by data inconsistency. 3) The data that failed to be deleted can be processed automatically, reducing operation and maintenance costs and the need for manual intervention.
[0106] For example, when an online shopping website stores product information through cache, the deletion fails due to cache service exception when deleting the product information. At this time, the cache deletion system will control the re-acquisition of the failed deletion message from the message queue, parse the target .key data, and try to delete the corresponding product information data again. Through this step, the system will automatically handle the deletion failure and ensure the consistency of the product information in the cache with the database. This fault-tolerant recovery mechanism enables the system to cope with various abnormal situations and ensure the accuracy of data operations and the stability of the system.
[0107] Step S700: When the cache data is deleted successfully, the advertisement data is updated to the cache.
[0108] In the embodiment of this step, when the cache data is deleted successfully, the corresponding advertisement data will be updated to the cache. The specific implementation of this step includes the following detailed steps:
[0109] S701. In the embodiment of the present invention, after the deletion operation is completed, the system checks whether the corresponding cache data is successfully deleted to ensure the accuracy of the operation.
[0110] S702: If the cache data is deleted successfully, the system will obtain the latest advertisement data for updating.
[0111] S703: Update the latest advertisement data to the cache to ensure the timeliness and accuracy of the cache data, and ensure the consistency of the data information in the cache with the data information in the database.
[0112] For example, when an online news website uses a cache to store advertising data, when a certain advertising data needs to be deleted, the present invention will first delete the corresponding data in the cache. If the deletion is successful, the latest advertising data will be obtained from the database, and then the latest advertising data will be updated to the cache. Through this step, the present invention ensures the timeliness and consistency of the advertising data in the cache, while improving the effect of advertising display. This real-time data update mechanism helps to improve the performance of the system and the user experience, ensuring that the advertising content displayed by the system is always the latest.
[0113] In the embodiment of this step, by timely updating the advertisement data to the cache, the consistency of the cache data and the database data is ensured, and the data accuracy of the system is improved. In addition, updating the cache data can improve the performance of the system, reduce the response time when accessing the advertisement data later, and improve the user experience. In addition, the real-time nature of the advertisement data can be ensured, so that the system can display the latest advertisement content in a timely manner and improve the advertisement effect.
[0114] The method of the present invention is further described in detail below through a more specific application example:
[0115] like Figure 4 As shown, a method for processing advertisement delivery data integrity in this specific application embodiment includes the following steps:
[0116] Step S1: When data needs to be written, start updating the database data, for example, updating the data of a MySQL database. When the database data is updated successfully, a success message is returned.
[0117] Step S2, and delete the cached data, for example, delete the redis (cache) data; when the redis (cache) data deletion fails, a deletion failure message is fed back.
[0118] Step S3: asynchronously send the key message to be deleted to the message queue; when the message is sent successfully, a message of successful sending is returned.
[0119] Step S4: monitor messages and execute cache deletion.
[0120] Step S5, continue to retry deletion; and return the result.
[0121] Figure 4 As shown, this specific application embodiment adopts a cache delay double deletion strategy:
[0122] The specific method is to delete the cached data first. That is, delete the old data in redis (cache), and delete the data before writing the data).
[0123] Then write to the database.
[0124] Then, after sleeping for 500 milliseconds, delete the cache again, that is, delete the redis (cache) data again.
[0125] In this way, the dirty data reading time will only be 500 milliseconds at most in this specific application embodiment. The key is how to determine this sleep time. The purpose of using the delay time in this specific embodiment is to ensure that the read request is completed, and the write request can delete the cached dirty data caused by the read request. Therefore, the present invention needs to evaluate the time consumption of the project's data reading business logic by itself, and add a few hundred milliseconds as the delay time on the basis of the read time.
[0126] In a further embodiment, the present invention adopts a delete cache retry mechanism;
[0127] Specifically, in order to avoid cache deletion failure, that is, if the second deletion of delayed double deletion fails, in order to avoid the problem of being unable to delete dirty data. The present invention further adopts a retry mechanism in the embodiment to ensure successful cache deletion. For example, if the retry fails three times, the log is recorded in the database and a warning is sent. In a high-concurrency scenario, it is best to use an asynchronous method to retry, such as sending a message to the mq middleware to achieve asynchronous decoupling. Figure 4In step S5, if the deletion fails and the maximum number of retries is not reached, the message is requeued until the deletion is successful, otherwise it is recorded in the database and manual intervention is required.
[0128] In order to prevent intrusion into the business code, in a further embodiment of the present invention, a service that specifically subscribes to the binlog of the database is started to read the data to be deleted and perform a cache deletion operation.
[0129] Among them, the service of subscribing to database binlog refers to monitoring and subscribing to the binary log (binlog) of the database through specific software or services in the relational database system. The binary log is the transaction log of the database, which records all the change operations that occur in the database, such as inserting, updating, and deleting data. By subscribing to binlog, users can obtain the change operations in the database in real time, so as to synchronize data in real time, back up data, monitor data changes, etc. Common services for subscribing to database binlog include MySQL's binlog, PostgreSQL's wal, etc.
[0130] like Figure 5 As shown, the method for processing advertisement delivery data integrity according to a further embodiment of the present invention includes the following steps:
[0131] Step S11: When the business system needs to write data, it issues a database update instruction to update the database data; for example, it may be to update the data in a MySQL database.
[0132] Step S12: When the database data is updated successfully, a success message is returned;
[0133] Step S13, subscribe to binlog log; the database records the operation information in the binlog log;
[0134] The operation information is operation information for updating the database. When the database is updated, the binlog will be updated and the binlog will be subscribed immediately.
[0135] Step S14, take out the key to be deleted; use the canal data migration tool to subscribe to the binlog log to obtain the target data and key; then control the deletion of the data in the cache (redis);
[0136] In this step, the cache deletion system obtains the data of the canal data migration tool, parses the target key, and attempts to delete the cache. When it detects that the data in the cache fails to be deleted, it proceeds to step S15.
[0137] In the embodiment of the present invention, regarding obtaining target data and key, the target data and key respectively represent the redis data and redis .key that need to be deleted, and these data are first saved in the database.
[0138] In the present invention, using the Canal data migration tool to subscribe to binlog logs is a data synchronization technology, especially in MySQL databases. The Canal data migration tool is an open source incremental subscription & consumption component based on database binlog logs of a certain company, which can obtain change operations in MySQL databases in real time.
[0139] When using the Canal Data Migration Tool to subscribe to binlog logs, users can set up a Canal Data Migration Tool instance to listen to the database binlog, and then pass the change operations in the database (such as insert, update, delete) to the subscriber in the form of events. Through the Canal Data Migration Tool, users can obtain target data (specific data in the database) and key information (such as the primary key of the operation, operation type, etc.), thereby realizing real-time data synchronization, data backup, data analysis and other application scenarios.
[0140] In general, using the Canal data migration tool to subscribe to binlog logs can help users obtain changes in the database in real time, thereby meeting the needs of data synchronization and data processing;
[0141] Step S15: Send the key that failed to be deleted to the message queue. If the key is successfully sent, a message indicating the successful sending is returned to the specified cache deletion APP.
[0142] That is, if the deletion fails, the message is sent to the message queue and the process goes to step S16;
[0143] Step S16, retry the deletion, and re-queue if failed. That is, the cache deletion system re-obtains data from the message queue and performs the deletion operation again.
[0144] This process ensures the final consistency of the data. In order to prevent the failure of deleting redis (cache) data, the embodiment of the present invention adopts an asynchronous retry mechanism to ensure correct deletion. The asynchronous mechanism can send a delete message to the mq message middleware, or use the canal data migration tool to subscribe to the MySQL binlog log to listen to the write request to delete the corresponding cache.
[0145] When the cache is deleted successfully, the updated data is written to the cache.
[0146] Exemplary Devices
[0147] like Figure 6As shown, an embodiment of the present invention provides a system for processing advertisement delivery data integrity, the system comprising:
[0148] The acquisition and update module 310 is used to acquire the advertisement data to be updated and update the advertisement data into the database;
[0149] The log update module 320 is used to control the database to update and record the operation information of data update in the binlog log;
[0150] The deletion data subscription acquisition module 330 is used to use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache;
[0151] The first parsing and deleting module 340 is used to control the cache deletion system to obtain the target data and .key data in the cache to be deleted in the canal data migration tool, parse the target .key data, and try to delete the cache;
[0152] A message sending control module 350, used for sending the message of failed deletion to a message queue when the deletion fails;
[0153] The second parsing and deleting module 360 is used to control the cache deletion system to re-acquire the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again;
[0154] The cache update control module 370 is used to update the advertisement data into the cache when the cache data is deleted successfully, as described above in detail.
[0155] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 7 As shown. The smart terminal can be a stress test server for stress testing of the Internet production environment, including a processor, a memory, a network interface, a display screen, and a database connected through a system bus. Among them, the processor of the smart terminal is used to provide computing and control capabilities. The memory of the smart terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the smart terminal is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for processing data integrity based on advertising delivery is implemented. The database of the smart terminal is used to store a program for processing data integrity based on advertising delivery.
[0156] Those skilled in the art will understand that Figure 7The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0157] In one embodiment, a smart terminal is provided, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations:
[0158] Acquire the advertisement data to be updated, and update the advertisement data into the database;
[0159] The control database records the data update operation information in the binlog log;
[0160] Use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache;
[0161] The cache deletion system obtains the target data and .key data that need to be deleted from the cache of the canal data migration tool, parses the target .key data, and attempts to delete the cache;
[0162] If the deletion fails, the deletion failure message is sent to the message queue;
[0163] Control the cache deletion system to re-obtain the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again;
[0164] When the cache data is deleted successfully, the advertisement data is updated to the cache.
[0165] Among them, the target data and .key data that need to be deleted are the data in the redis cache and the .key data in the redis cache that need to be deleted.
[0166] The step of obtaining the advertisement data to be updated and updating the advertisement data into the database includes:
[0167] Get the advertisement data to be updated, and update the advertisement data into the MySQL database.
[0168] The step of controlling the database to update and record the operation information of data update in the binlog log includes:
[0169] Enable the binary log function in the database configuration to write update operation information into the binary log file;
[0170] Monitor data update operations in the database and record detailed information of each update operation in the binary log, including operation type, execution time, and affected data;
[0171] Select the appropriate binary log format based on your needs to ensure that the recorded operation information can meet subsequent needs.
[0172] The steps of using the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data to be deleted in the cache include:
[0173] Use the Canal data migration tool to obtain real-time update operation information in the database, including insert, update, and delete operations, by subscribing to the database's binlog logs.
[0174] Identify the target data and .key data to be deleted in the cache through Canal, and obtain the target data and .key data to be deleted in the cache;
[0175] Subscribe to binlog logs through the Canal tool to achieve data synchronization and migration between the database and cache.
[0176] The steps of obtaining the target data and .key data to be deleted from the cache of the canal data migration tool by the cache deletion system, parsing the target .key data, and attempting to delete the cache include:
[0177] A cache deletion system is pre-set to manage cache data, and deletes the data in the cache by receiving information transmitted from the outside that the data needs to be deleted;
[0178] By subscribing to the data stream provided by the Canal tool, the cache deletion system is controlled to obtain the target data and .key data to be deleted from the Canal data migration tool;
[0179] The cache deletion system parses the received target .key data, determines the unique identifier of the cache data item to be deleted, and locates the specified data to be deleted;
[0180] Based on the parsed target .key data, the cache deletion system is controlled to try to delete the corresponding data item in the cache.
[0181] The steps of controlling the cache deletion system to obtain the target data and .key data to be deleted from the cache from the message queue again, parsing the target .key data, and performing the deletion operation again include:
[0182] The cache deletion system periodically checks the message queue to obtain messages that failed to be deleted before, including the target data to be deleted and the corresponding .key data;
[0183] Parse the target .key data to determine the cache data items that need to be deleted, and ensure that the specified data is deleted accurately;
[0184] Re-execute the deletion operation, control the deletion operation again, try to delete the corresponding data in the cache, and ensure the consistency of the data, as described above.
[0185] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0186] In summary, the present invention provides a method, system, intelligent terminal and storage medium based on advertising data integrity processing. By acquiring the target data to be deleted in real time and deleting the cache, it can ensure that the data in the cache is consistent with the data in the database, avoid the problems caused by data inconsistency, and provide convenience for users.
[0187] And it has the following advantages: 1) Re-acquire and process the data that failed to be deleted from the message queue, so that the system has the ability to self-repair, improving the fault tolerance and reliability of the system. 2) By re-executing the deletion operation, the consistency of cache data and database data is guaranteed, avoiding the problems caused by data inconsistency. 3) It can automatically process the data that failed to be deleted, reducing the operation and maintenance costs and the need for manual intervention.
Claims
1. A method for processing advertisement delivery data integrity, characterized in that: The following steps are involved: Acquire the advertisement data to be updated, and update the advertisement data into the database; The control database records the data update operation information in the binlog log; Use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache; The cache deletion system obtains the target data and .key data that need to be deleted from the cache of the canal data migration tool, parses the target .key data, and attempts to delete the cache; If the deletion fails, the deletion failure message is sent to the message queue; Control the cache deletion system to re-obtain the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again; When the cache data is deleted successfully, the advertisement data is updated to the cache.
2. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The target data and .key data that need to be deleted are the data in the redis cache and the .key data in the redis cache that need to be deleted.
3. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The step of obtaining the advertisement data to be updated and updating the advertisement data into the database comprises: Get the advertisement data to be updated, and update the advertisement data into the MySQL database.
4. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The step of controlling the database to update and record the operation information of data update in the binlog log includes: Enable the binary log function in the database configuration to write update operation information into the binary log file; Monitor data update operations in the database and record detailed information of each update operation in the binary log, including operation type, execution time, and affected data; Select the appropriate binary log format based on your needs to ensure that the recorded operation information can meet subsequent needs.
5. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The steps of using the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data to be deleted in the cache include: Use the Canal data migration tool to obtain real-time update operation information in the database, including insert, update, and delete operations, by subscribing to the database's binlog logs. Identify the target data and .key data to be deleted in the cache through Canal, and obtain the target data and .key data to be deleted in the cache; Subscribe to binlog logs through the Canal tool to achieve data synchronization and migration between the database and cache.
6. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The cache deletion system obtains the target data and .key data to be deleted from the cache of the canal data migration tool, parses the target .key data, and attempts to delete the cache, including the following steps: A cache deletion system is pre-set to manage cache data, and deletes the data in the cache by receiving information transmitted from the outside that the data needs to be deleted; By subscribing to the data stream provided by the Canal tool, the cache deletion system is controlled to obtain the target data and .key data to be deleted from the Canal data migration tool; The cache deletion system parses the received target .key data, determines the unique identifier of the cache data item to be deleted, and locates the specified data to be deleted; Based on the parsed target .key data, the cache deletion system is controlled to try to delete the corresponding data item in the cache.
7. The method for processing advertisement delivery data integrity according to claim 1, characterized in that: The steps of controlling the cache deletion system to re-acquire the target data and .key data to be deleted from the cache from the message queue, parsing the target .key data, and performing the deletion operation again include: The cache deletion system periodically checks the message queue to obtain messages that failed to be deleted before, including the target data to be deleted and the corresponding .key data; Parse the target .key data to determine the cache data items that need to be deleted, and ensure that the specified data is deleted accurately; Re-execute the deletion operation, control the execution of the deletion operation again, and try to delete the corresponding data in the cache to ensure data consistency.
8. A system for processing advertisement delivery data integrity, characterized in that: The system comprises: An acquisition and update module, used for acquiring advertisement data to be updated, and updating the advertisement data into a database; The log update module is used to control the database to update and record the operation information of data update in the binlog log; Delete the data subscription acquisition module, which is used to use the canal data migration tool to subscribe to the binlog log to obtain the target data and .key data that need to be deleted in the cache; The first parsing and deletion module is used to control the cache deletion system to obtain the target data and .key data in the cache to be deleted in the canal data migration tool, parse the target .key data, and try to delete the cache; A message sending control module, used for sending the message of failed deletion to the message queue when the deletion fails; The second parsing and deleting module is used to control the cache deletion system to re-acquire the target data and .key data to be deleted from the cache from the message queue, parse the target .key data, and perform the deletion operation again; The cache update control module is used to update the advertisement data into the cache when the cache data is deleted successfully.
9. An intelligent terminal, characterized in that: The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include being used to execute the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Real-time cache updating method and system based on Redis
CN108491332A
Method and device for processing data in cache
CN109857812A
Data caching method and device, electronic equipment and storage medium
CN109871388A
Method and system for realizing consistency of database and cache by cache deletion retry mechanism
CN113626457A
Data deletion method and device, storage medium and electronic device
CN115048392A
Cited By
Consistency updating method and related equipment
CN121501809A
