A data synchronization method, apparatus, device, and storage medium

CN118467631BActive Publication Date: 2026-10-16ZHOUPU DATA TECH NANJING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410547217.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-06
Publication Date
2026-10-16
Estimated Expiration
2044-05-06

AI Technical Summary

Technical Problem

[0002]随着大数据的发展,业务系统需要进行对数据的跨多维度聚合,单纯一个数据库的查询聚合能力无法满足要求,因此往往需要将数据同步至不同数据库,但随着需要写入数据库数量的增多,现有的代码多写方式容易导致代码冗余,降低写入的效率

Benefits of technology

[0018] The technical solution of this invention, upon detecting a data update event, determines the updated data and write configuration information for the updated data, and generates candidate write codes based on the updated data and write configuration information. If synchronization conditions are met, a scan is performed within the local write code to determine the target write code containing code annotations. Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases. By utilizing code annotations to quickly write updated data to multiple databases, code redundancy is avoided, effectively improving the working efficiency of the business system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467631B_ABST
    Figure CN118467631B_ABST
Patent Text Reader

Abstract

The application discloses a data synchronization method, device and equipment and a storage medium. The method comprises the following steps: if a data update event is detected, determining update data and write configuration information of the update data, and generating a candidate write code according to the update data and the write configuration information; in the case that a synchronization condition is met, scanning in a local write code to determine a target write code containing code annotation; and writing target write data corresponding to the target write code and the target code annotation into different target databases to realize data synchronization between the different databases. The technical scheme of the application can quickly write update data into multiple databases by using code annotation, avoids code redundancy, and effectively improves the working efficiency of a business system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of big data, and in particular to a data synchronization method, apparatus, device, and storage medium. Background Technology

[0002] With the development of big data, business systems need to aggregate data across multiple dimensions. The query and aggregation capabilities of a single database are insufficient to meet the requirements. Therefore, it is often necessary to synchronize data to different databases. However, as the number of databases to be written increases, the existing multi-write approach can easily lead to code redundancy and reduce writing efficiency.

[0003] Therefore, how to use code annotations to quickly write updated data to multiple databases, avoid code redundancy, and effectively improve the work efficiency of business systems is an urgent problem to be solved. Summary of the Invention

[0004] This invention provides a data synchronization method, apparatus, device, and storage medium to quickly write updated data to multiple databases using code annotations, avoiding code redundancy and effectively improving the working efficiency of business systems.

[0005] According to one aspect of the present invention, a data synchronization method is provided, comprising:

[0006] If a data update event is detected, the updated data and the write configuration information for the updated data are determined, and candidate write codes are generated based on the updated data and the write configuration information.

[0007] If the synchronization condition is detected, a scan is performed in the local write code to determine the target write code containing code annotations;

[0008] Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases.

[0009] According to another aspect of the present invention, a data synchronization device is provided, comprising:

[0010] The generation module is used to determine the updated data and the write configuration information for the updated data if a data update event is detected, and to generate candidate write codes based on the updated data and the write configuration information.

[0011] The determination module is used to scan the local write code to determine the target write code containing code annotations when the synchronization condition is detected.

[0012] The synchronization module is used to write the target write data to different target databases based on the target write data and target code annotations corresponding to the target write code, so as to achieve data synchronization between different databases.

[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the data synchronization method according to any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the data synchronization method described in any embodiment of the present invention.

[0018] The technical solution of this invention, upon detecting a data update event, determines the updated data and write configuration information for the updated data, and generates candidate write codes based on the updated data and write configuration information. If synchronization conditions are met, a scan is performed within the local write code to determine the target write code containing code annotations. Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases. By utilizing code annotations to quickly write updated data to multiple databases, code redundancy is avoided, effectively improving the working efficiency of the business system.

[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a flowchart of a data synchronization method provided in Embodiment 1 of the present invention;

[0022] Figure 2 This is a flowchart of a data synchronization method provided in Embodiment 2 of the present invention;

[0023] Figure 3 This is a structural block diagram of a data synchronization device provided in Embodiment 3 of the present invention;

[0024] Figure 4 This is a schematic diagram of the structure of the electronic device provided in Embodiment 4 of the present invention. Detailed Implementation

[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0026] It should be noted that the terms "first," "second," "target," "candidate," "alternative," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] Example 1

[0028] Figure 1 This is a flowchart of a data synchronization method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where a business system quickly synchronizes updated data to different databases based on code annotations. This method can be executed by a data synchronization device, which can be implemented in hardware and / or software. The data synchronization device can be configured in an electronic device, such as a business system, and executed by the business system's processor. Figure 1 As shown, the data synchronization method includes:

[0029] S101. If a data update event is detected, determine the updated data and the write configuration information for the updated data, and generate candidate write codes based on the updated data and the write configuration information.

[0030] Data update events refer to data update events that occur during the operation of the business system, such as events that generate new order information. Write configuration information refers to information that limits the method and content of writing updated data to the database. Write configuration information can include at least one of the following: operation type, updated field information, updated database, update write order, and target table information.

[0031] Optionally, determine the write configuration information for the updated data, including: determining the operation type, update write order, and update field information corresponding to the updated data based on the data update event; determining the update database and target table information to be written to from the candidate database based on the update data category to which the updated data belongs and the storage data category of the preset candidate database; and determining the write configuration information based on the operation type, update field information, update database, update write order, and target table information.

[0032] The operation type can be adding, deleting, or modifying data. Update field information refers to the fields that have been updated in the data update event, such as updating fields like name or age in the original data. The update write order refers to the order in which data is written to multiple databases when there are multiple databases to be written to. Target table information refers to the attribute information of the table corresponding to the updated data in different databases, such as table name, key, and ID (Identity Document, unique code). Specifically, for MySQL and Elasticsearch, the target table information can be the table name; for Redis, it can be the key. Candidate write code is the code used to write the updated data to the default database, such as MySQL. The write configuration information may specify other databases besides the default database that need to be written to for updating data.

[0033] Optionally, based on the update data category to which the update data belongs, a matching process can be performed in the storage data categories of the preset candidate databases. The update database containing all or part of the update data categories can be identified as the update database to be written with the update data, and the storage table information of the data corresponding to the update data category in the update database can be determined, that is, the target table information can be determined.

[0034] Optionally, after generating candidate write codes, relevant personnel can add code comments to the candidate write codes according to the write configuration information to instruct subsequent business systems to automatically execute the candidate write codes according to the content in the code comments and perform write operations on the relevant databases when the synchronization conditions are met; alternatively, a preset process can be called to generate candidate code comments for candidate write codes according to the write configuration information. If it is determined according to the write configuration information that the updated data does not need to be written to other databases, then no comments need to be added to the candidate write codes.

[0035] Optionally, after generating candidate write code, the candidate write code can be stored in the local write code library of the business system so that write operations can be performed in a timely manner when the synchronization conditions are met.

[0036] S102. If the synchronization condition is detected, a scan is performed in the local write code to determine the target write code containing code annotations.

[0037] Synchronization conditions refer to the conditions under which a business system writes updated data to different databases for data synchronization. Specifically, this can be determined periodically or upon each startup of the business system, assuming that the synchronization conditions are met. Target write code refers to candidate write code containing code annotations.

[0038] Optionally, if the synchronization condition is detected, all methods of the local write code Java class can be scanned, and the write code corresponding to the methods containing code annotations can be identified as the target write code.

[0039] S103. Based on the target write data and target code annotations corresponding to the target write code, write the target write data to different target databases to achieve data synchronization between different databases.

[0040] The target write data refers to the updated data in the target write code, which is the data stored in advance during the data update event. The target code annotation refers to the code annotation corresponding to the target write code. The target code annotation can be used to instruct the business system to synchronously write the target write data to multiple databases with different table structures.

[0041] Optionally, the number of target databases can be determined based on the update database in the target code annotation. If there is only one target database, the target write data only needs to be written to the default database, that is, the write operation of the target write data can be implemented by executing the target write code. If there are at least two target databases, the target write data needs to be written to the default first target database first by executing the target write code, and then the write operation of other databases can be performed according to the target code annotation.

[0042] Optionally, the target code annotation can include exception handling instructions. If an exception is detected during the subsequent execution of the target write code, the business system can determine whether to continue writing to other target databases based on the instructions.

[0043] Optionally, based on the target write data corresponding to the target write code and the target code annotation, the target write data is written to different target databases, including: writing the target write data to the first target database according to the target write code; generating a target write instruction for the second target database according to the target code annotation, and determining the target executor corresponding to the second target database; and executing the write operation to the second target database by calling the target executor according to the target write instruction.

[0044] The first target database refers to the database that, by default, performs the target write operation; that is, the database that can be written to by executing the target write code. The second target database refers to the database whose target code annotations indicate that the target write data needs to be synchronously written. There can be at least two second target databases. The target executor refers to the data processor that performs the write operation; one target executor corresponds to one database. The target executor can include at least one of the following: a MySQL executor, a Redis executor, and an ElasticSearch executor. The target write command is a command adapted to the second target database to operate on the second target database.

[0045] For example, if a data update event refers to an event in which the business system aggregates orders across multiple dimensions during business processing, then the target data to be written can refer to all order information of the new order. Specifically, it can be written to a MySQL database, i.e., the first target database. Furthermore, key data in the target data to be written can be filtered out and written to the ElasticSearch search engine, i.e., the second target database.

[0046] Optionally, the target data to be written can be filtered based on the update field information in the target code annotation to determine the key data that needs to be written to the second target database. Then, based on the key data and the second target database, write statements (such as delete statements, add statements, or update statements) to the second target database can be dynamically generated, thereby generating write instructions to write the key data to the second target database and realizing the modification of the data in the second target database.

[0047] It should be noted that after writing the target data into the first target database, the present invention can further determine the data to be written into the second target database based on the target code annotation. The data to be written into the second target database can be all the target data or key data obtained by filtering the target data. The present invention does not limit this.

[0048] Optionally, the second target database includes a first write database and a second write database. Correspondingly, the write operation on the second target database includes: filtering the target write data according to the target code annotations to determine the first write data and the second write data, and generating a first write instruction and a second write instruction; determining the write database and target executor corresponding to the first write data and the second write data, as well as the target write order, according to the target code annotations; and writing the first write data and the second write data into the first write database and the second write database respectively by calling the corresponding target executor according to the first write instruction, the second write instruction, and the target write order.

[0049] In this context, both the first and second write data can be all the target write data or a selected portion of the target write data. The target write order refers to the order in which different write databases are accessed; this order can be simultaneous or sequential. The first and second write instructions are commands adapted to the specific write database to perform operations on it.

[0050] Optionally, based on the target write order, the target executor corresponding to the first write database can be called first to write the first write data to the first write database according to the first write instruction, and then the target executor corresponding to the second write database can be called to write the second write data to the second write database according to the second write instruction.

[0051] It should be noted that since data writing can result in success or failure, this invention can pre-configure whether to write to database B only after successfully writing to database A. In other words, it is not required that database A must be written before database B. By setting the target writing order, it is possible to pre-configure according to the correlation and importance of different databases, thereby improving the efficiency of data writing and minimizing mutual interference between databases.

[0052] It should be noted that the method of filtering the target data before writing it to other databases in this invention can improve data processing efficiency. Specifically, this invention considers that when performing cross-dimensional aggregation of orders, the query aggregation capabilities of MySQL alone cannot meet the performance requirements of the business system, while Elasticsearch provides high-performance aggregation query capabilities. Therefore, it is necessary to write order information to both MySQL and Elasticsearch simultaneously. Specifically, when writing orders to MySQL, the complete order information is written, while when writing orders to Elasticsearch, only some key information needs to be written. This can speed up the writing process, save Elasticsearch storage, and also save time when reading.

[0053] Optionally, the target write data is filtered based on the target code annotations, including: matching and transforming the updated field information corresponding to the target write data according to the key field information specified in the target code annotations; and filtering out the data under the corresponding key field information in the target write data as the write data to be written to the second target database based on the matching and transformation results.

[0054] Among them, key field information refers to the key field information that needs to be synchronized to other databases in advance. For example, in the scenario of cross-dimensional aggregation of orders, after storing all order information in the MySQL database, it is also necessary to synchronize the tenant identifier, document submitter, submission time, document amount, and included product information in the order information as key data to the Elasticsearch search engine. At this time, the Elasticsearch search engine can be determined as the second target database, and the key field information is the field name such as tenant identifier, document submitter, submission time, document amount, and included product information.

[0055] Optionally, the updated field containing the field name can be matched with the updated field information corresponding to the target written data based on the field name in the key field information to determine the updated field. Then, the updated field can be converted according to the data storage format of the second target database to obtain the data under the corresponding key field information in the target written data.

[0056] For example, if the target data to be written contains fields such as amount, ID, and name, and the key fields of the second target database are ID and name, then it means that only the ID and name fields in the second target database need to be written.

[0057] For example, if the field name of the original storage name information of the updated data is realName, while the field name of the name information stored in the database to be written is name, then the corresponding updated field name needs to be converted to obtain the write data to be written to the second target database.

[0058] Optionally, based on the target code annotations, a target write instruction for the second target database is generated, and the target executor corresponding to the second target database is determined, including: generating a target write instruction for the second target database based on the operation type, update field information, and target table information in the target code annotations, combined with the database type to which the update database belongs; and determining the data processor corresponding to the database type to which the update database belongs as the target executor corresponding to the second target database.

[0059] For example, if the write configuration information in the target code annotation is represented as: {"id":#p1,"name":#p2}, that is, the updated field information is id and name, and the target table name of the second target database is user, the operation type is insert, and the database type is MySQL, then the corresponding target write instruction can be "Insert into user(id,name)values(a,b)", where (a,b) is the data to be written to the second target database; correspondingly, if the operation type is update, the corresponding target write instruction can be "Update user set name=?where id=?", where id is the default update condition, and other unique keys can also be configured, such as specifying the update condition as mobile through "@Update(key="mobile")"; similarly, if the operation type is delete, the corresponding target write instruction can be "Delete from userwhere id=?".

[0060] For example, based on the following passage in the configuration information, the business system can use the executor specified by the database to perform data write operations:

[0061] "saleOrder:mysql->MysqlWriter->sale_order,redis->RedisWriter->saleOrder"

[0062] That is, the MysqlWriter executor is used when writing data to the MySQL database, and the RedisWriter executor is used when writing data to the Redis database.

[0063] Optionally, before writing the target data to different target databases, the method further includes: using a preset code generation library to generate a target proxy object corresponding to the target writing code; through the target proxy object, if a call to the target writing code is detected, adding post-execution logic to the target writing code according to the target code annotation corresponding to the target writing code, so as to perform synchronization operations on other databases after the target writing code is executed.

[0064] The default code generation library can be CGLIB (Code Generation Library). The target proxy object (such as a Proxy object in Java) refers to the code object generated by the code generation library for weaving logic before and after the code.

[0065] Optionally, when the synchronization conditions are detected, such as when the business system starts, the method class contained in the target code annotation can be determined, and then a target proxy object can be dynamically generated for this method class using CGLIB. The purpose of generating the proxy object is to weave logic before and after the execution of the annotated code, such as synchronizing data to other databases by reading the annotation configuration after the code execution is completed.

[0066] The technical solution of this invention, upon detecting a data update event, determines the updated data and write configuration information for the updated data, and generates candidate write codes based on the updated data and write configuration information. If synchronization conditions are met, a scan is performed within the local write code to determine the target write code containing code annotations. Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases. By utilizing code annotations to quickly write updated data to multiple databases, code redundancy is avoided, effectively improving the working efficiency of the business system.

[0067] Example 2

[0068] Figure 2 This is a flowchart of a data synchronization method provided in Embodiment 2 of the present invention; based on the above embodiments, this embodiment provides a preferred example of how a business system performs data synchronization when it detects that the synchronization conditions are met.

[0069] like Figure 2 As shown, the method includes the following steps:

[0070] If the synchronization condition is met, intercept the method execution before execution. That is, through the preset target proxy object, read and parse the annotation configuration before the target writing code performs the writing operation.

[0071] Furthermore, the original logic written in the target code can be executed, and it can be determined whether there are any exceptions during the code execution process. If so, it can be determined whether to continue execution based on the target code annotations; otherwise, the executor list parsing operation can be performed.

[0072] Optionally, the list of executors to be parsed can be determined based on the updated database name involved in the target code annotation. By initializing the executor list and sequentially calling the executors corresponding to the databases to be written (i.e., the target executors), the target data can be written to different target databases.

[0073] It should be noted that the way to generate target write instructions differs for different target executors. For example, for the MySQL executor, SQL statements can be generated based on the action type, target table information, and update field information. For instance, for an insert operation, if the target table is user and the update fields are id, username, and age, then the table metadata can be read first, and then an insert statement for the user table can be generated based on the update fields.

[0074] For example, for the executor of the ElasticSearch search engine, the corresponding API (Application Programming Interface) can be determined according to the operation type, and document parameters can be generated to initiate the update and synchronization of data stored in the ElasticSearch search engine.

[0075] For example, for the Redis executor, you can select a command based on the operation type and update the data according to the updated field information. The operation type can be CRUD (Create, Read, Update). CRUD operations can be performed using the `SET key value` command, while deletion can be performed using the `DELETE key` command. The default key is the table name + id.

[0076] Alternatively, data writing operations can be performed using a custom executor. Different logic can be written using a custom executor. For example, if a new database is added, such as MongoDB, but MongoDB's write, update, and delete operations are different from MySQL, then a custom executor needs to be configured separately to perform write operations on the MongoDB database.

[0077] It should be noted that in related technologies, synchronization is often achieved by writing more code in the code, which means adding repetitive code to the code area of ​​each database. The solution of this invention avoids adding new code in different database areas of the code library by adding annotations, thus avoiding logical intrusion and code redundancy of the original code, improving data synchronization efficiency, and saving storage space of the business system.

[0078] Example 3

[0079] Figure 3 This is a structural block diagram of a data synchronization device provided in Embodiment 3 of the present invention. This embodiment is applicable to situations where a business system quickly synchronizes updated data to different databases based on code annotations. The data synchronization device provided in this embodiment can execute the data synchronization method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. This data synchronization device can be implemented in hardware and / or software and configured in a device with data synchronization function, such as in a business system, and executed by the processor of the business system. Figure 3 As shown, the data synchronization device specifically includes:

[0080] The generation module 301 is used to determine the updated data and the write configuration information for the updated data if a data update event is detected, and to generate candidate write codes based on the updated data and the write configuration information.

[0081] The determination module 302 is used to scan the local write code to determine the target write code containing code annotations when the synchronization condition is detected.

[0082] The synchronization module 303 is used to write the target write data to different target databases based on the target write data and target code annotations corresponding to the target write code, so as to achieve data synchronization between different databases.

[0083] The technical solution of this invention, upon detecting a data update event, determines the updated data and write configuration information for the updated data, and generates candidate write codes based on the updated data and write configuration information. If synchronization conditions are met, a scan is performed within the local write code to determine the target write code containing code annotations. Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases. By utilizing code annotations to quickly write updated data to multiple databases, code redundancy is avoided, effectively improving the working efficiency of the business system.

[0084] Furthermore, the synchronization module 303 may include:

[0085] The writing unit is used to write the target writing code and write the target writing data into the first target database according to the target writing code.

[0086] The determination unit is used to generate target write instructions for the second target database based on the target code annotations, and to determine the target executor corresponding to the second target database;

[0087] The execution unit is used to perform write operations on the second target database by calling the target executor and according to the target write instructions.

[0088] Furthermore, the second target database includes a first write database and a second write database, and correspondingly, the execution unit may include:

[0089] The generation subunit is used to filter the target write data according to the target code annotation, determine the first write data and the second write data, and generate the first write instruction and the second write instruction.

[0090] The determination subunit is used to determine the writing database and target executor corresponding to the first and second written data, as well as the target writing order, based on the target code annotations;

[0091] The write subunit is used to write the first write data and the second write data into the first write database and the second write database respectively by calling the corresponding target executor according to the first write instruction, the second write instruction and the target write order.

[0092] Furthermore, the generation of sub-units is specifically used for:

[0093] Based on the key field information pre-specified in the target code annotation, match and transform the update field information corresponding to the data written to the target;

[0094] Based on the matching and transformation results, the data under the corresponding key field information in the target data is selected as the data to be written to the second target database.

[0095] Furthermore, the specific use of the unit is as follows:

[0096] Based on the operation type, update field information, and target table information in the target code annotations, and combined with the database type to which the update database belongs, a target write instruction for the second target database is generated.

[0097] The data processor corresponding to the database type of the updated database will be identified as the target executor corresponding to the second target database.

[0098] Furthermore, the generation module 301 is specifically used for:

[0099] Based on the data update event, determine the operation type, update write order, and update field information corresponding to the updated data;

[0100] Based on the update data category to which the update data belongs and the storage data category of the preset candidate databases, determine the update database and target table information to be written with the update data from the candidate databases;

[0101] The write configuration information is determined based on the operation type, updated field information, updated database, update write order, and target table information.

[0102] Furthermore, the above-mentioned device is also used for:

[0103] A pre-defined code generation library is used to generate the target proxy object corresponding to the target code.

[0104] If a call to the target write code is detected through the target proxy object, post-execution logic is added to the target write code based on the target code annotation corresponding to the target write code, so as to perform synchronization operations on other databases after the target write code is executed.

[0105] Example 4

[0106] Figure 4 This is a schematic diagram of the structure of the electronic device provided in Embodiment 4 of the present invention; Figure 4 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0107] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0108] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0109] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as data synchronization methods.

[0110] In some embodiments, the data synchronization method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the data synchronization method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the data synchronization method by any other suitable means (e.g., by means of firmware).

[0111] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0112] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0113] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0114] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0115] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0116] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0117] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0118] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A data synchronization method, characterized in that, include: If a data update event is detected, the updated data and the write configuration information for the updated data are determined, and candidate write codes are generated based on the updated data and the write configuration information. If the synchronization conditions are met, a scan is performed in the local code-writing section to identify the target code containing code annotations; wherein, the synchronization conditions refer to the conditions under which the business system writes updated data to different databases for data synchronization. Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases to achieve data synchronization between different databases; Based on the target write data and target code annotations corresponding to the target write code, the target write data is written to different target databases, including: Write the code according to the target, and write the target data into the first target database; Based on the target code annotations, generate target write instructions for the second target database and determine the target executor corresponding to the second target database; By invoking the target executor, a write operation is performed on the second target database according to the target write instruction.

2. The method according to claim 1, characterized in that, in, The second target database includes the first write database and the second write database. Accordingly, write operations are performed on the second target database, including: The target write data is filtered based on the target code annotations to determine the first write data and the second write data, and the first write instruction and the second write instruction are generated. Based on the target code annotations, determine the writing database and target executor corresponding to the first and second written data, as well as the target writing order; According to the first write instruction, the second write instruction, and the target write order, the first write data and the second write data are written to the first write database and the second write database respectively by calling the corresponding target executor.

3. The method according to claim 2, characterized in that, The data written to the target is filtered based on the target code annotations, including: Based on the key field information pre-specified in the target code annotation, match and transform the update field information corresponding to the data written to the target; Based on the matching and transformation results, the data under the corresponding key field information in the target data is selected as the data to be written to the second target database.

4. The method according to claim 1, characterized in that, Based on the target code annotations, generate target write instructions for the second target database and determine the target executor corresponding to the second target database, including: Based on the operation type, update field information, and target table information in the target code annotations, and combined with the database type to which the update database belongs, a target write instruction for the second target database is generated. The data processor corresponding to the database type of the updated database will be identified as the target executor corresponding to the second target database.

5. The method according to claim 1, characterized in that, Determine the write configuration information for updated data, including: Based on the data update event, determine the operation type, update write order, and update field information corresponding to the updated data; Based on the update data category to which the update data belongs and the storage data category of the preset candidate databases, determine the update database and target table information to be written with the update data from the candidate databases; The write configuration information is determined based on the operation type, updated field information, updated database, update write order, and target table information.

6. The method according to claim 1, characterized in that, Before writing the target data to different target databases, the following steps are also included: A pre-defined code generation library is used to generate the target proxy object corresponding to the target code. If a call to the target write code is detected through the target proxy object, post-execution logic is added to the target write code based on the target code annotation corresponding to the target write code, so as to perform synchronization operations on other databases after the target write code is executed.

7. A data synchronization device, characterized in that, include: The generation module is used to determine the updated data and the write configuration information for the updated data if a data update event is detected, and to generate candidate write codes based on the updated data and the write configuration information. The determination module is used to scan the local code to identify the target code containing code annotations when the synchronization conditions are met; wherein, the synchronization conditions refer to the conditions under which the business system writes updated data to different databases for data synchronization. The synchronization module is used to write the target write data to different target databases based on the target write data and target code annotations corresponding to the target write code, so as to achieve data synchronization between different databases; The synchronization module includes: The writing unit is used to write the target writing code and write the target writing data into the first target database according to the target writing code. The determination unit is used to generate target write instructions for the second target database based on the target code annotations, and to determine the target executor corresponding to the second target database; The execution unit is used to perform write operations on the second target database by calling the target executor and according to the target write instructions.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that is executed by the at least one processor to enable the at least one processor to perform the data synchronization method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the data synchronization method of any one of claims 1-6.

Citation Information

Patent Citations

  • Data synchronization method and device, electronic equipment and storage medium

    CN111782721A

  • Database writing method and device, electronic equipment and storage medium

    CN117033480A