Data synchronization method, device, equipment and medium
By listening to data changes in the memory database and obtaining and comparing metadata information, the data synchronization problem between the memory database and the business database is solved, and the timely, accurate synchronization and efficient compatibility of the data is achieved, ensuring the consistency of the data.
Patent Information
- Application Number
- CN202311462119.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-03
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-11-03
AI Technical Summary
In the prior art, there is a lack of an effective data synchronization mechanism between the in-memory database and the business database, which makes it difficult to ensure data consistency and accuracy, especially in the memory computing scenario where data is synchronized from the in-memory database to the business database.
By listening to data changes in the in-memory database, determining the target business database, obtaining and comparing the metadata information between the two, ensuring that the field column set is consistent and data synchronization is performed, including data type conversion and field identification mapping, ensuring data accuracy and efficiency.
It realizes timely and accurate synchronization of in-memory database data to the business database, ensures the consistency of data and the efficiency of synchronization process, and adapts to the compatibility needs of different databases.
Smart Images

Figure CN117493456B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a data synchronization method, apparatus, device, and medium. Background Art
[0002] Currently, in-memory computing uses in-memory databases to provide accelerated computing and data analysis services for businesses. In-memory computing is a solution designed for specific scenarios, and its compatibility with general scenarios must be considered, especially regarding data consistency between in-memory databases and business databases (such as Oracle and SQL Server). For example, if business A doesn't directly use in-memory computing or an in-memory database but uses data from business B that has been computed in-memory, the data computed by business B needs to be synchronized from the in-memory database to the business database.
[0003] Therefore, a solution for synchronizing the in-memory database to the business database is needed to synchronize the data in the in-memory database to the business database. Summary of the Invention
[0004] One or more embodiments of this specification provide a data synchronization method, apparatus, device, and medium for solving the technical problems raised in the background technology.
[0005] One or more embodiments of this specification adopt the following technical solutions:
[0006] One or more embodiments of this specification provide a data synchronization method, including:
[0007] When monitoring data changes in the in-memory database, determine the target business database;
[0008] Obtaining a business database field column set from metadata information pre-configured in the target business database;
[0009] Obtaining a memory database field column set from metadata information pre-configured in the memory database;
[0010] Comparing the business library field column set with the memory field column set to see if they are consistent;
[0011] If the business database field column set is consistent with the memory field column set, the changed data of the memory database is synchronized from the memory database to the target business database.
[0012] One or more embodiments of this specification provide a data synchronization device, the device comprising:
[0013] The target database determination unit determines the target business database when monitoring the data changes in the memory database;
[0014] A business field acquisition unit, which acquires a business database field column set from metadata information pre-configured in the target business database;
[0015] A memory field acquisition unit, which acquires a memory database field column set from metadata information pre-configured in the memory database;
[0016] A comparison unit compares the business library field column set with the memory field column set to see whether they are consistent;
[0017] The synchronization unit synchronizes the changed data of the memory database from the memory database to the target business database if the business database field column set is consistent with the memory field column set.
[0018] One or more embodiments of this specification provide a data synchronization device, including:
[0019] at least one processor; and,
[0020] a memory communicatively connected to the at least one processor; wherein,
[0021] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0022] When monitoring data changes in the in-memory database, determine the target business database;
[0023] Obtaining a business database field column set from metadata information pre-configured in the target business database;
[0024] Obtaining a memory database field column set from metadata information pre-configured in the memory database;
[0025] Comparing the business library field column set with the memory field column set to see if they are consistent;
[0026] If the business database field column set is consistent with the memory field column set, the changed data of the memory database is synchronized from the memory database to the target business database.
[0027] One or more embodiments of this specification provide a non-volatile computer storage medium storing computer-executable instructions. When executed by a computer, the computer-executable instructions can achieve:
[0028] When monitoring data changes in the in-memory database, determine the target business database;
[0029] Obtaining a business database field column set from metadata information pre-configured in the target business database;
[0030] Obtaining a memory database field column set from metadata information pre-configured in the memory database;
[0031] Comparing the business library field column set with the memory field column set to see if they are consistent;
[0032] If the business database field column set is consistent with the memory field column set, the changed data of the memory database is synchronized from the memory database to the target business database.
[0033] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0034] In the embodiment of this specification, when the memory database monitors data changes, the target business database can be determined by this method, that is, the target of data synchronization can be determined; the business library field column set can be obtained through the metadata information pre-configured in the target business database, that is, the field information that needs to be synchronized in the target business database can be obtained; the memory library field column set can be obtained through the metadata information pre-configured in the memory database, that is, the field information of the data in the memory database can be obtained; the business library field column set and the memory field column set are compared to see whether they are consistent, that is, to determine whether the field information of the target business database matches the field information of the memory database. If the business library field column set is consistent with the memory field column set, that is, the field information of the target business database matches the field information of the memory database, the changed data of the memory database can be synchronized to the target business database to achieve synchronous update of the data. This method can ensure that the data in the memory database can be synchronized to the business database in a timely manner, ensuring the consistency and accuracy of the data. At the same time, the efficiency and accuracy of the synchronization process can be ensured through the pre-configured metadata information. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some of the embodiments described in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without inventive work. In the drawings:
[0036] Figure 1 A flowchart of a data synchronization method provided in one or more embodiments of this specification;
[0037] Figure 2 A schematic diagram of the structure of a data synchronization device provided in one or more embodiments of this specification;
[0038] Figure 3A schematic diagram of the structure of a data synchronization device provided in one or more embodiments of this specification. DETAILED DESCRIPTION
[0039] The embodiments of this specification provide a data synchronization method, apparatus, device, and medium.
[0040] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this specification without creative work should fall within the scope of protection of this specification.
[0041] Figure 1 This is a flowchart of a data synchronization method provided in one or more embodiments of this specification. The process can be executed by a data synchronization system. Certain input parameters or intermediate results in the process allow manual intervention and adjustment to help improve accuracy.
[0042] The method steps of the embodiment of this specification are as follows:
[0043] S102: When a data change in the memory database is detected, a target business database is determined.
[0044] In the embodiment of this specification, the above-mentioned monitoring of the data change of the memory database and determining the target business database may be implemented in the following steps:
[0045] Monitor data changes in the in-memory database: Create a monitoring program or trigger to monitor data changes in the in-memory database. You can use the API or plug-in provided by the in-memory database to implement this function.
[0046] Determine the target business database: When monitoring data changes in the in-memory database, determine the target business database to which the changed data should be synchronized based on pre-defined rules or configuration files. This rule can be defined based on business needs or specific data matching conditions.
[0047] S104: Acquire a business database field column set from metadata information pre-configured in the target business database.
[0048] In the embodiment of this specification, according to the above-mentioned content related to obtaining the business library field column set, the implementation steps can be as follows:
[0049] Obtain metadata information of the target business database: By connecting to the target business database and using the database's metadata query function, obtain the table structure information of the business database, including table name, field name, data type, data precision, and other information.
[0050] Parse metadata information: parse the obtained metadata information and extract the required business library field information, including field name, data type, data precision, etc.
[0051] Build a business library field column set: Based on the parsed business library field information, build a business library field column set. You can use data structures (such as lists, dictionaries, etc.) to store field information to ensure the uniqueness and integrity of each field.
[0052] Process field information as needed: If additional processing is required on field information, such as converting data types or precision, this is done based on specific needs. For example, if the data types of the in-memory database and the business database do not fully match, data type conversion may be required.
[0053] Return the business library field column set: Return the constructed business library field column set to the caller as the basic data for data consistency comparison in subsequent steps.
[0054] It's important to note that the specific implementation steps may vary depending on the target business database type and technical implementation methods. Before implementation, it's important to understand the characteristics of the target business database, metadata query methods, and specific requirements to determine the appropriate technologies and tools for acquiring and processing business database field information.
[0055] S106: Obtain a memory database field column set from metadata information pre-configured in the memory database.
[0056] In the embodiment of this specification, according to the above-mentioned content related to obtaining the memory library field column set, the implementation steps can be as follows:
[0057] Get metadata information of the in-memory database: By querying the metadata information of the in-memory database, you can obtain the table structure information of the in-memory database, including table name, field name, data type, data precision, etc.
[0058] Parse metadata information: Parse the obtained metadata information and extract the required memory library field information, including field name, data type, data precision, etc.
[0059] Construct a memory library field column set: Based on the parsed memory library field information, construct a memory library field column set. You can use data structures (such as lists and dictionaries) to store field information to ensure the uniqueness and integrity of each field.
[0060] Process field information as needed: If additional processing is required on field information, such as converting data types or precision, this is done based on specific needs. For example, if the data types of the in-memory database and the business database do not fully match, data type conversion may be required.
[0061] Return the memory library field column set: Return the constructed memory library field column set to the caller as the basic data for data consistency comparison in subsequent steps.
[0062] It's important to note that the specific implementation steps may vary depending on the type of in-memory database used and the technical implementation method. Before implementation, it's important to understand the characteristics of the in-memory database, metadata query methods, and specific requirements to determine the appropriate technologies and tools for acquiring and processing in-memory database field information.
[0063] S108: Compare the business library field column set with the memory field column set to see if they are consistent.
[0064] In the embodiment of this specification, according to the above-mentioned comparison of the business library field column set and the memory field column set, the implementation steps are as follows:
[0065] Compare field column sets: Compare the field information of the business database field column set and the memory field column set one by one, including data precision, data type, and field identifier.
[0066] Check data precision: Compare the data precision in the business database field column set and the in-memory field column set to determine whether they are consistent. If the data precision is inconsistent, data precision conversion or adjustment is required.
[0067] Check data types: Compare the data types in the business database field column set and the memory field column set to determine whether they are consistent. If the data types are inconsistent, data type conversion or adjustment is required.
[0068] Check field identifiers: Compare the field identifiers in the business database field column set and the memory field column set to determine whether they are consistent. If the field identifiers are inconsistent, you need to establish a field identifier mapping relationship or adjust the field identifiers.
[0069] Process changed data based on the comparison results: Based on the comparison results, determine whether the changed data needs to be processed. If the data precision, data type, and field identifiers of the business database field column set and the in-memory field column set are completely consistent, the changed data in the in-memory database can be directly synchronized to the target business database. If inconsistencies exist, appropriate data processing is required to ensure compatibility with the target business database.
[0070] S110: If the business database field column set is consistent with the memory field column set, synchronize the changed data of the memory database from the memory database to the target business database.
[0071] In the embodiment of this specification, when synchronizing the changed data of the memory database from the memory database to the target business database, the changed data can be first stored in a change set object; and then the change set object is synchronized from the memory database to the target business database.
[0072] In the embodiment of this specification, based on the above content, the steps for synchronizing the changed data of the in-memory database to the target business database may be as follows:
[0073] Extract changed data: Extract changed data from the in-memory database.
[0074] Synchronize change set objects: Use appropriate synchronization mechanisms to synchronize the changed data to the target business database.
[0075] Update the target business database: Update the target business database based on the changed data.
[0076] The specific implementation steps may vary depending on the specific situation. For example, triggers or periodic polling can be used to extract the changed data and add it to the changeset object. Synchronization mechanisms can be implemented using technologies such as database replication and message queues, depending on the system requirements and constraints. When updating data, potential conflicts and errors must be considered and handled.
[0077] In addition, it is also necessary to ensure that data consistency and integrity are maintained throughout the synchronization process, for example, through transaction management to ensure data correctness.
[0078] Furthermore, when the embodiment of this specification stores the change data in a change set object, the cache entity of the change data can be obtained in the read trigger of the in-memory database; the cache entity can be traversed through a loop iteration to obtain the corresponding value from the cache entity; finally, the value corresponding to the cache entity is filled into the change set object, and the data identifier and the target business database identifier are set for the change set object.
[0079] According to the above content, the steps for storing the changed data in the changeset object may be as follows:
[0080] Create a changeset object: Create a changeset object to store the changed data.
[0081] Trigger obtains cache entity: In the read trigger of the in-memory database, the cache entity corresponding to the changed data is obtained. The trigger can be the code logic that is automatically triggered when the read operation occurs.
[0082] Iterate cache entities: traverse cache entities through loop iteration and obtain corresponding values from them.
[0083] Fill the changeset object: Fill the changeset object with the values obtained from the cache entity. You can assign values to each field one by one according to the structure of the cache entity and the definition of the changeset object.
[0084] Set the data identifier and target business database identifier: Set the data identifier and target business database identifier in the change set object to identify the source and destination of the changed data.
[0085] It should be noted that the specific implementation steps may vary depending on the actual situation and need to be adjusted according to the specific database and trigger implementation. When iterating cached entities and populating changeset objects, it is necessary to pay attention to data type conversion and processing to ensure data accuracy and integrity.
[0086] In addition, possible concurrent access and conflict situations can be considered and handled to ensure data consistency when multiple triggers are fired simultaneously.
[0087] Furthermore, if the data precision, data type and field identifier in the business library field column set and the memory field column set are inconsistent, the embodiment of this specification can process the change data of the memory database before synchronizing it from the memory database to the target business database to obtain processed change data, and the processed change data is compatible with the target business database.
[0088] According to the above content, the steps for synchronizing the changed data of the in-memory database to the target business database can be as follows:
[0089] Analyze field differences: Compare the business database field column set and the memory field column set to find out the differences in data precision, data type, and field identifier.
[0090] Data processing rule design: Design data processing rules based on field differences to ensure compatibility with the target business database. For example, if data precision is inconsistent, data rounding or zero padding can be performed; if data types are inconsistent, data type conversion or formatting can be performed; if field identifiers are inconsistent, field mapping or renaming can be performed.
[0091] Change Data Processing: Apply the designed data processing rules to the change data to convert it into processed change data. Depending on the specific circumstances of the differences, data conversion, format adjustment, rounding, zero padding, and other operations may be required during the processing process.
[0092] Synchronize processed changed data: Use an appropriate synchronization mechanism to synchronize the processed changed data to the target business database. Choose the appropriate synchronization method based on the specific situation, such as database replication or data import.
[0093] Update the target business database: Update the target business database based on the processed change data to ensure data consistency and integrity.
[0094] During implementation, attention must be paid to the compatibility of the processed change data with the target business database to ensure data accuracy and availability. Appropriate testing and verification must also be performed to ensure that the processed data is consistent with the expected results in the target business database.
[0095] Furthermore, if the data precision in the business library field column set is inconsistent with that in the memory field column set, when the embodiment of this specification processes the changed data, the data precision of the changed data can be converted according to the data precision in the business library field column set.
[0096] According to the above content, the steps for implementing data processing on the changed data to convert the data precision can be as follows:
[0097] Analyze data precision differences: Compare the data precision differences between the business database field column set and the memory field column set to determine which fields require data precision conversion.
[0098] Design data precision conversion rules: Design data precision conversion rules based on the data precision of the business database field column set. Determine how to convert the changed data in the in-memory database to data consistent with the business database field precision.
[0099] Data precision conversion processing: According to the designed precision conversion rules, the fields in the changed data that need precision conversion are processed. Data precision conversion can be performed using rounding, truncation, or zero padding.
[0100] Update the target business database: Update the changed data after data precision conversion to the target business database to ensure data consistency and integrity.
[0101] Verify conversion results: Verify and confirm to ensure that the data after data accuracy conversion is consistent with the expected results of the target business database.
[0102] During implementation, it is important to be mindful of potential data loss or changes caused by data precision conversion. Ensure that the conversion process does not result in data loss, irreversibility, or the introduction of incorrect data.
[0103] Furthermore, if the data types in the business library field column set are inconsistent with those in the memory field column set, when processing the changed data, the embodiment of this specification may convert the data type of the changed data according to the data type in the business library field column set.
[0104] Based on the above content, the steps for implementing data processing on the changed data to convert the data type can be as follows:
[0105] Analyze data type differences: Compare the data type differences between the business library field column set and the memory field column set to determine which fields require data type conversion.
[0106] Design data type conversion rules: Design data type conversion rules based on the data types in the business database field column set. Determine how to convert the changed data in the in-memory database into data consistent with the business database field type.
[0107] Data type conversion processing: According to the designed data type conversion rules, the fields that need to be converted in the changed data are processed. Depending on the data type, appropriate methods can be used for conversion, such as type conversion functions, formatting operations, etc.
[0108] Update the target business database: Update the changed data after data type conversion to the target business database to ensure data consistency and integrity.
[0109] Verify conversion results: Perform verification and confirmation to ensure that the data after data type conversion is consistent with the expected results of the target business database.
[0110] During implementation, be mindful of data truncation, loss, or changes that may occur due to data type conversion. Ensure that the conversion process does not result in data loss, irreversibility, or the introduction of incorrect data.
[0111] Furthermore, if the field identifiers in the business library field column set are inconsistent with those in the memory field column set, when the embodiment of this specification processes the change data, a mapping relationship can be established between the field identifiers in the business library field column set and the field identifiers in the memory field column set, and the mapping relationship can be added to the change data.
[0112] Based on the above content, the steps for implementing data processing on the changed data to establish a field identifier mapping relationship may be as follows:
[0113] Analyze field identifier differences: Compare the field identifier differences between the business database field column set and the memory field column set. Determine which fields require mapping relationships.
[0114] Design field identifier mapping relationships: Design field identifier mapping relationships based on the field identifiers in the business library field column set and the field identifiers in the memory field column set. Determine the mapping relationship between each field in the business library field column set and the field in the memory field column set.
[0115] Add mapping to change data: Add the designed field identifier mapping to the change data. You can add a field to the change data to store the field identifier mapping.
[0116] Update the target business database: Update the changed data with the field identifier mapping relationship to the target business database. Based on the mapping relationship, convert the field identifiers in the changed data into the corresponding field identifiers in the target business database.
[0117] Verify mapping results: Verify and confirm to ensure that the data after field identifier mapping is consistent with the expected results of the target business database.
[0118] During implementation, it is necessary to ensure that the established field identifier mapping relationships are accurate to ensure data correctness and consistency. At the same time, appropriate testing and verification are required to ensure that the mapped data is consistent with the expected results of the target business database.
[0119] It should be noted that the embodiments of this specification propose the creation of a system that supports "custom persistence" and "data dual-write synchronization." This solves the problem of "data consistency between different functions caused by whether in-memory computing is enabled," achieves reliable data write-back from in-memory data to the target business database, and is compatible with database differences. Functional points include: enabling monitoring of in-memory database changes, retrieving source / target database field information, obtaining field information that needs to be changed, and constructing / sending a change set. The following is a brief description of the main process:
[0120] Monitor the data changes in the memory library through the configuration file. After the data is modified (update, insert, delete), the 'data trigger' will be automatically triggered. There are several steps:
[0121] 1. First, obtain the source database (memory database) field A set, schema name, target database connection (business database) and other information from the memory CacheStoreSession;
[0122] 2. Obtain the business database field column set B from the pre-configured data table (gspmcfconfig) in the target database, and obtain the in-memory database field column set A from the metadata information of the in-memory database session configuration (this session exists throughout the entire data synchronization lifecycle). Compare the A and B sets to see if they are consistent (name, type, precision). If not, an error will be reported. If they are consistent, read the cache entity (Cache.Entry) in the trigger, iterate all data from the cache entity, and extract the value from the Entry and fill it into the change set object (ChangeSet). Assign a unique ID, target business number, and data change type to each change set.
[0123] It should be noted that if a certain library does not support a certain field, it can be allowed to find a similar field as a substitute. In this case, field type mismatch is allowed, such as long text fields. Obviously, when data synchronization is necessary, such fields must be compatible, that is, data column difference types must be compatible. Compatibility is divided into two steps: identifying the database type and identifying the field column type. Through the session reading field column type method (see above), the database type is obtained through a pre-prepared public configuration table. According to the obtained database type and column type, the differences are processed. For example: Since the memory database in the present invention does not support long text (Text / Clob) fields, all character strings are represented by the character set varchar. When converting to the varchar field with a limited length in each business database, it is necessary to check whether the length is too long. If it is too long, an error will be thrown or truncation will be performed. If the target database field is a long text field such as Clob / Text, the string needs to be encapsulated into a JDBC Clob / Text object before insertion.
[0124] 3. Finally, obtain the sender in a non-bean manner and send the change set to the "data synchronization (consumption) framework". This process ensures data consistency between the memory library and the business library, that is, implements "data version control". The synchronized data has a hidden version number (currently a timestamp) to determine the newness of the data. The process is briefly described as follows:
[0125] (1) After the memory data is changed, the data is directly written to the disk to ensure that the data in the memory library is the latest and completely real-time
[0126] (2) Then trigger the custom persister of the present invention, the present invention will add a current timestamp to the current data and send it to the message queue. If the sending is successful, the present invention records the change set ID, data volume, and timestamp to the 'success log table' of the business library. If it fails, it records the failure stack information, error information, data volume, etc. to the 'failure log table' of the target database.
[0127] (3) The message queue will determine the data consumption order based on the current timestamp, update the business database data, and retransmit failed data based on the version number in near real time.
[0128] The above is the main process of the memory data synchronization framework. The following is a supplementary explanation of some implementation details.
[0129] To monitor in-memory database data changes, this embodiment rewrites a custom cache change event listener based on a public interface. Using an asynchronous trigger mechanism, it reads the synchronization flag recorded in the target business database and synchronizes the table if synchronization is enabled. Otherwise, it skips synchronization. When synchronization is enabled and data changes occur, the event is triggered every 5 seconds or every 1,000 data changes.
[0130] In summary, the embodiments of this specification: 1) provide a monitoring mechanism and a double-write mechanism for data changes in the memory database, and collect change data according to certain rules; 2) construct a change set for the collected change data according to the corresponding business number, check mismatched fields, compatible field type differences, and control versions; 3) have certain verification mechanisms and recording mechanisms, record errors when there are serious synchronization exceptions that cannot be handled, and prepare for the secondary synchronization of data in the subsequent framework.
[0131] Figure 2 This is a structural diagram of a data synchronization device provided in one or more embodiments of this specification, wherein the device includes: a target library determination unit 202, a business field acquisition unit 204, a memory field acquisition unit 206, a comparison unit 208 and a synchronization unit 210.
[0132] The target database determining unit 202 determines the target business database when monitoring the data change of the memory database;
[0133] The business field acquisition unit 204 acquires a business database field column set from metadata information pre-configured in the target business database;
[0134] A memory field acquisition unit 206 acquires a memory database field column set from metadata information pre-configured in the memory database;
[0135] A comparison unit 208 compares the business library field column set with the memory field column set to see if they are consistent;
[0136] The synchronization unit 210 synchronizes the changed data of the memory database from the memory database to the target business database if the business database field column set is consistent with the memory field column set.
[0137] Figure 3 A schematic diagram of a data synchronization device provided for one or more embodiments of this specification includes:
[0138] at least one processor; and,
[0139] a memory communicatively connected to the at least one processor; wherein,
[0140] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0141] When monitoring data changes in the in-memory database, determine the target business database;
[0142] Obtaining a business database field column set from metadata information pre-configured in the target business database;
[0143] Obtaining a memory database field column set from metadata information pre-configured in the memory database;
[0144] Comparing the business library field column set with the memory field column set to see if they are consistent;
[0145] If the business database field column set is consistent with the memory field column set, the changed data of the memory database is synchronized from the memory database to the target business database.
[0146] One or more embodiments of this specification provide a non-volatile computer storage medium storing computer-executable instructions. When executed by a computer, the computer-executable instructions can achieve:
[0147] When monitoring data changes in the in-memory database, determine the target business database;
[0148] Obtaining a business database field column set from metadata information pre-configured in the target business database;
[0149] Obtaining a memory database field column set from metadata information pre-configured in the memory database;
[0150] Comparing the business library field column set with the memory field column set to see if they are consistent;
[0151] If the business database field column set is consistent with the memory field column set, the changed data of the memory database is synchronized from the memory database to the target business database.
[0152] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, apparatus, and non-volatile computer storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simplified. For relevant details, refer to the descriptions of the method embodiments.
[0153] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0154] The foregoing description is merely one or more embodiments of this specification and is not intended to limit this specification. It will be apparent to those skilled in the art that various modifications and variations may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of one or more embodiments of this specification are intended to be within the scope of the claims of this specification.
Claims
1. A data synchronization method, characterized in that: The method comprises: When monitoring data changes in the in-memory database, determine the target business database; Obtaining a business database field column set from metadata information pre-configured in the target business database; Obtaining a memory field column set from metadata information pre-configured in the memory database; Comparing the business library field column set with the memory field column set to see if they are consistent; If the business database field column set is consistent with the memory field column set, synchronizing the changed data of the memory database from the memory database to the target business database; The step of synchronizing the changed data of the memory database from the memory database to the target business database includes: Storing the change data in a changeset object; Synchronize the changeset object from the in-memory database to the target business database; The storing the changed data in a changeset object includes: In a read trigger of the memory database, obtaining a cache entity of the changed data; Traverse the cache entity in a loop iteration manner and obtain the corresponding value from the cache entity; Fill the value corresponding to the cache entity into the change set object, and set the data identifier and the target business database identifier for the change set object; If one or more of the data precision, data type, and field identifier in the business database field column set and the memory field column set are inconsistent, before synchronizing the changed data of the memory database from the memory database to the target business database, the method further includes: The changed data is processed to obtain processed changed data, where the processed changed data is compatible with the target business database.
2. The method according to claim 1, characterized in that If the data precision of the business library field column set is inconsistent with the data precision of the memory field column set, the data processing of the changed data includes: The data precision of the changed data is converted according to the data precision in the business library field column set.
3. The method according to claim 1, characterized in that If the data types in the business library field column set are inconsistent with those in the memory field column set, processing the changed data includes: The data type of the changed data is converted according to the data type in the business library field column set.
4. The method according to claim 1, wherein If the field identifiers in the business library field column set are inconsistent with those in the memory field column set, processing the changed data includes: A mapping relationship is established between the field identifiers in the business library field column set and the field identifiers in the memory field column set, and the mapping relationship is added to the change data.
5. A data synchronization device, characterized in that: The device comprises: The target database determination unit determines the target business database when monitoring the data changes in the memory database; A business field acquisition unit, which acquires a business database field column set from metadata information pre-configured in the target business database; A memory field acquisition unit, which acquires a memory field column set from metadata information pre-configured in the memory database; A comparison unit compares the business library field column set with the memory field column set to see whether they are consistent; a synchronization unit, which synchronizes the changed data of the memory database from the memory database to the target business database if the business database field column set is consistent with the memory field column set; The step of synchronizing the changed data of the memory database from the memory database to the target business database includes: Storing the change data in a changeset object; Synchronize the changeset object from the in-memory database to the target business database; The storing the changed data in a changeset object includes: In a read trigger of the memory database, obtaining a cache entity of the changed data; Traverse the cache entity in a loop iteration manner and obtain the corresponding value from the cache entity; Fill the value corresponding to the cache entity into the change set object, and set the data identifier and the target business database identifier for the change set object; If one or more of the data precision, data type, and field identifier in the business database field column set and the memory field column set are inconsistent, before synchronizing the changed data of the memory database from the memory database to the target business database, the method further includes: The changed data is processed to obtain processed changed data, where the processed changed data is compatible with the target business database.
6. A data synchronization device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to implement the data synchronization method according to any one of claims 1 to 4.
7. A non-volatile computer storage medium, characterized in that Computer-executable instructions are stored, and when the computer-executable instructions are executed by a computer, the data synchronization method according to any one of claims 1 to 4 can be implemented.
Citation Information
Patent Citations
Method and equipment for realizing data synchronization service
CN115630121A
Distributed memory database management system
CN116910035A