A multi-tenant mode cross-platform data synchronization method, device, equipment and medium
By generating a data operation log table and querying data operation log lock tags, the problem of serial execution of data synchronization tasks among multiple tenants is solved, achieving more efficient cross-platform data synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZKTECO CO LTD
- Filing Date
- 2024-09-25
- Publication Date
- 2026-06-26
AI Technical Summary
In a multi-tenant environment, the task of synchronizing data between multiple tenants is executed sequentially, resulting in poor synchronization performance.
By generating a data operation log table, the target tenant and operation type are determined, key-value pairs are generated and cached, operation threads are created and data operation log records are queried, and data operation log lock flags are queried to avoid the repeated execution of synchronization tasks.
It improves the synchronization effect of cross-platform data synchronization in multi-tenant modules and avoids mutual interference between different synchronization tasks.
Smart Images

Figure CN119182789B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data synchronization technology, and in particular to a multi-tenant mode cross-platform data synchronization method, apparatus, device and medium. Background Technology
[0002] Different tenants of a SaaS cloud platform can synchronize data, such as contact information (departments, personnel, etc.). The conventional approach is to store the data to be synchronized in a relational database (such as MySQL) and then use Java timers (Timer & TimerTask) to implement the synchronization. Each time, the database is queried based on the insertion time, and then the data is grouped by tenant for synchronization. If the synchronization is successful, the data is deleted; otherwise, it is retried. If the synchronization fails after several retries, the data is archived.
[0003] However, in a multi-tenant environment, because data is processed serially (first-in, first-out) and has low performance, the tasks of synchronizing data among multiple tenants can interfere with each other, resulting in poor synchronization performance. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for cross-platform data synchronization in a multi-tenant mode, which addresses the technical problem that the tasks of synchronizing data among multiple tenants affect each other when executed serially, resulting in poor synchronization performance.
[0005] This invention provides a cross-platform data synchronization method in a multi-tenant mode, comprising:
[0006] When the SaaS cloud platform generates an operation, a data operation log table is generated;
[0007] Determine the target tenant and operation type corresponding to the operation;
[0008] Generate key-value pairs for each target tenant, and use the key-value pairs to generate a cache of the latest key-value pair data format for the tenant;
[0009] Create operation threads for each target tenant, and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant;
[0010] Check if a corresponding data operation log lock flag exists for the target tenant;
[0011] If it does not exist, then create the data operation log lock tag for the target tenant, and synchronize the operation data to the third-party SaaS cloud platform according to the target data operation log record.
[0012] Optionally, the step of generating key-value pairs for each of the target tenants and using the key-value pairs to generate a cache of the latest key-value pair data format for the tenant includes:
[0013] Obtain the tenant primary key and log primary key for each target tenant;
[0014] Using the tenant's primary key as the key and the log's primary key as the value, generate key-value pairs for each target tenant;
[0015] The key-value pairs are used to generate a cache of the latest key-value pair data format for the tenant.
[0016] Optionally, the step of creating operation threads for each target tenant and querying target data operation log records from the data operation log table based on the key-value pairs and operation types of each target tenant includes:
[0017] Create operation threads for each target tenant, and query the data operation log records of the target tenant from the data operation log table according to the tenant primary key and operation type of each target tenant;
[0018] The target data operation log record is determined from the data operation log records according to the creation time.
[0019] Optionally, the step of synchronizing operation data with a third-party SaaS cloud platform based on the target data operation log includes:
[0020] Based on the target operation type recorded in the target data operation log, call the synchronization API interface of the third-party SaaS cloud platform;
[0021] The operation data is synchronized to the third-party SaaS cloud platform through the synchronization API interface;
[0022] Receive feedback information from the third-party SaaS cloud platform in response to the operation data feedback;
[0023] When the feedback information indicates successful synchronization, obtain the current synchronization log primary key of the target tenant;
[0024] Determine whether the current synchronization log primary key is the same as the log primary key in the tenant's latest key-value pair data format cache;
[0025] If they are the same, the operation data synchronization is determined to be successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
[0026] Optionally, it also includes:
[0027] If the current synchronization log primary key is different from the log primary key in the latest key-value pair data format cache of the tenant, then determine whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant;
[0028] If they are the same, the operation data synchronization is determined to be successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
[0029] Optionally, it also includes:
[0030] When the feedback information is about network connectivity, proceed to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant.
[0031] Optionally, it also includes:
[0032] When the feedback information is an error code list, the log corresponding to the current synchronization log primary key is taken as the error operation log, and the process jumps to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant.
[0033] The present invention also provides a multi-tenant mode cross-platform data synchronization device, comprising:
[0034] The data operation log table generation module is used to generate a data operation log table when the SaaS cloud platform performs operations.
[0035] The target tenant and operation type determination module is used to determine the target tenant and operation type corresponding to the operation behavior;
[0036] The tenant's latest key-value pair data format cache generation module is used to generate key-value pairs for each of the target tenants and to generate the tenant's latest key-value pair data format cache using the key-value pairs;
[0037] The target data operation log query module is used to create operation threads for each target tenant and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant.
[0038] The data operation log lock tag query module is used to query whether a data operation log lock tag for the corresponding target tenant exists.
[0039] The synchronization module is used to create a data operation log lock tag for the target tenant if it does not exist, and to synchronize operation data to the third-party SaaS cloud platform according to the target data operation log record.
[0040] The present invention also provides an electronic device, the device comprising a processor and a memory:
[0041] The memory is used to store program code and transmit the program code to the processor;
[0042] The processor is used to execute the multi-tenant mode cross-platform data synchronization method as described above, according to the instructions in the program code.
[0043] The present invention also provides a computer-readable storage medium for storing program code for performing the multi-tenant mode cross-platform data synchronization method as described in any of the preceding claims.
[0044] As can be seen from the above technical solutions, the present invention has the following advantages: The present invention provides a cross-platform data synchronization method in a multi-tenant mode, and specifically discloses: when the SaaS cloud platform generates an operation behavior, a data operation log table is generated; the target tenant and operation type corresponding to the operation behavior are determined; key-value pairs for each target tenant are generated, and the latest key-value pair data format of the tenant is cached using key-value pairs; operation threads for each target tenant are created, and target data operation log records are queried from the data operation log table according to the key-value pairs and operation types of each target tenant; a data operation log lock mark for the corresponding target tenant is checked; if it does not exist, a data operation log lock mark for the target tenant is created, and operation data is synchronized to the third-party SaaS cloud platform according to the target data operation log records.
[0045] This invention obtains the corresponding target data operation log records by constructing key-value pairs for the target tenants that generate operational data changes. Interference between different synchronization tasks is avoided through threaded execution. Then, during data synchronization, the existence of a data operation log lock flag is checked to prevent duplicate execution of synchronization tasks. This improves the synchronization effect of cross-platform data synchronization in the multi-tenant module. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the 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.
[0047] Figure 1 A flowchart illustrating the steps of a multi-tenant mode cross-platform data synchronization method provided in this embodiment of the invention;
[0048] Figure 2 A flowchart illustrating a cross-platform data synchronization method in a multi-tenant mode provided by an embodiment of the present invention;
[0049] Figure 3 A flowchart illustrating the steps of a multi-tenant mode cross-platform data synchronization method provided in another embodiment of the present invention;
[0050] Figure 4 This is a structural block diagram of a multi-tenant mode cross-platform data synchronization device provided in an embodiment of the present invention. Detailed Implementation
[0051] This invention provides a method, apparatus, device, and medium for cross-platform data synchronization in a multi-tenant mode, which addresses the technical problem that data synchronization tasks among multiple tenants interfere with each other during serial execution, resulting in poor synchronization performance.
[0052] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0053] Please see Figure 1 , Figure 1 The flowchart illustrates the steps of a multi-tenant cross-platform data synchronization method provided in this embodiment of the invention.
[0054] This invention provides a cross-platform data synchronization method in a multi-tenant mode, comprising:
[0055] Step 101: When the SaaS cloud platform generates an operation, a data operation log table is generated;
[0056] SaaS (Software as a Service) allows users to use cloud-based applications via an internet connection.
[0057] In embodiments of the present invention, such as Figure 2 As shown, a SaaS cloud platform can include a sending layer, a persistence layer, a caching layer, a transport layer, and a receiving layer. Users can perform various operations such as adding, deleting, and updating data in the sending layer of the SaaS cloud platform, thereby generating different types of operation data. This operation data needs to be synchronized to the third-party SaaS cloud platform subsequently.
[0058] To facilitate subsequent data processing, embodiments of this invention can persistently store a data operation log table in the persistence layer, such as in a MySQL relational database. This data operation log table records information about the tenant that caused the data changes, including tenantId (tenant primary key), logId (log primary key), createTime (creation time accurate to nanoseconds), actionName (operation name - add, delete, update), retryCount (number of retries), and deleteFlag (logical deletion flag).
[0059] Step 102: Determine the target tenant and operation type corresponding to the operation behavior;
[0060] In this embodiment of the invention, the operation type may include different operation types such as add, delete, and modify. Based on the user's specific operation behavior at the sending layer, the specific target tenant that causes the data change and the corresponding operation type can be determined.
[0061] Step 103: Generate key-value pairs for each target tenant, and use the key-value pairs to generate the latest key-value pair data format cache for the tenant;
[0062] In this embodiment of the invention, the latest data operation logs can be cached and stored in a key-value pair data format on the caching layer, and the cache name is set as the tenant's latest key-value pair data format cache.
[0063] Step 104: Create operation threads for each target tenant, and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant;
[0064] In this embodiment of the invention, to avoid mutual interference in data synchronization among different target tenants, an operation thread can be created for each target tenant. The corresponding synchronization task is then executed within each of these operation threads.
[0065] When performing a data synchronization task, the target operation log records can be queried in the data operation log table according to the key-value pairs and operation types of each target tenant in order to perform the synchronization task.
[0066] It should be noted that during data synchronization, since a target tenant may have multiple data operation behaviors, and the data synchronization process corresponding to a data operation behavior may need to be repeated multiple times to achieve the desired result, in this embodiment of the invention, the transport layer can create a timed task scheduler (such as the timed scheduling function of Java based on ScheduledExecutorService), and set the task scheduling cycle (such as executing once every 5 seconds) according to specific business requirements.
[0067] Step 105: Query whether there is a corresponding data operation log lock tag for the target tenant;
[0068] Step 106: If it does not exist, create a data operation log lock tag for the target tenant and synchronize operation data to the third-party SaaS cloud platform according to the target data operation log record.
[0069] In this embodiment of the invention, when a target tenant for synchronization is determined, the system first checks whether a data operation log lock tag currently being executed by the target tenant exists in the cache layer's storage named [Tenant's Data Operation Log Lock Tag]. If it exists, the execution is skipped. If it does not exist, a data operation log lock tag for the target tenant is created, and operation data is synchronized to the third-party SaaS cloud platform according to the target's data operation log records.
[0070] This invention, in its embodiments, obtains the corresponding target data operation log records by constructing key-value pairs for the target tenants that generate operational data changes. Execution is performed in separate threads to avoid interference between different synchronization tasks. Then, during data synchronization, the existence of a data operation log lock flag is checked to prevent duplicate execution of synchronization tasks. This improves the synchronization effect of cross-platform data synchronization in the multi-tenant module.
[0071] Please see Figure 3 , Figure 3 A flowchart illustrating the steps of a multi-tenant cross-platform data synchronization method according to another embodiment of the present invention. Specifically, it may include the following steps:
[0072] Step 301: When the SaaS cloud platform generates an operation, a data operation log table is generated;
[0073] Step 302: Determine the target tenant and operation type corresponding to the operation behavior;
[0074] Steps 301-302 are the same as steps 101-102. For details, please refer to the description of steps 101-102. They will not be repeated here.
[0075] Step 303: Obtain the tenant primary key and log primary key for each target tenant;
[0076] Step 304: Generate key-value pairs for each target tenant using the tenant's primary key as the key and the log primary key as the value;
[0077] Step 305: Generate the latest key-value pair data format cache for the tenant using key-value pairs;
[0078] In this embodiment of the invention, the latest data operation logs can be cached and stored in a key-value pair data format on the caching layer. The cache name is set as "Tenant's Latest Key-Value Pair Data Format Cache". The key stores the tenantId (tenant primary key), and the value stores the logId (log primary key). Since the cached data operation logs are the latest ones, the value always represents the latest data operation log entry for the target tenant.
[0079] Step 306: Create operation threads for each target tenant, and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant;
[0080] In this embodiment of the invention, to avoid mutual interference in data synchronization among different target tenants, an operation thread can be created for each target tenant. The corresponding synchronization task is then executed within each of these operation threads.
[0081] When performing a data synchronization task, the target operation log records can be queried in the data operation log table according to the key-value pairs and operation types of each target tenant in order to perform the synchronization task.
[0082] In one example, the steps of creating operation threads for each target tenant and querying target data operation log records from the data operation log table based on the key-value pairs and operation types of each target tenant may include the following sub-steps:
[0083] S61, create operation threads for each target tenant, and query the data operation log records of the target tenant from the data operation log table according to the tenant primary key and operation type of each target tenant;
[0084] S62, determine the target data operation log record from the data operation log records according to the creation time.
[0085] In the specific implementation, data operation log records can be retrieved from the data operation log table based on the tenant primary key and operation type of the target tenant. Then, the first data operation log record is retrieved in ascending order by the creation time (created time accurate to nanoseconds), which is the earliest data operation log record generated by the target tenant under this operation type, and is used as the target data operation log record.
[0086] Step 307: Query whether there is a corresponding data operation log lock tag for the target tenant;
[0087] Step 308: If the target tenant's data operation log lock tag does not exist, create the target tenant's data operation log tag and synchronize the operation data to the third-party SaaS cloud platform according to the target data operation log record.
[0088] In this embodiment of the invention, when a target tenant for synchronization is determined, the system first checks whether a data operation log lock tag currently being executed by the target tenant exists in the cache layer's storage named [Tenant's Data Operation Log Lock Tag]. If it exists, the execution is skipped. If it does not exist, a data operation log lock tag for the target tenant is created, and operation data is synchronized to the third-party SaaS cloud platform according to the target's data operation log records.
[0089] In one example, the steps of synchronizing operation data with a third-party SaaS cloud platform based on the target data operation log may specifically include the following sub-steps:
[0090] S81, based on the target operation type recorded in the target data operation log, calls the synchronization API interface of the third-party SaaS cloud platform;
[0091] S82 synchronizes operation data with third-party SaaS cloud platforms via a synchronization API interface;
[0092] S83 receives feedback information from third-party SaaS cloud platforms regarding operational data feedback.
[0093] S84, when the feedback message is "synchronization successful", retrieve the current synchronization log primary key of the target tenant;
[0094] S85, determine whether the current synchronization log primary key is the same as the log primary key in the tenant's latest key-value pair data format cache;
[0095] S86, if they are the same, it is determined that the operation data synchronization was successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
[0096] S87. If the current synchronization log primary key is different from the log primary key in the tenant's latest key-value pair data format cache, then determine whether the current synchronization log primary key is the same as the target tenant's data operation log lock flag.
[0097] If S88 is the same, the data synchronization is considered successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
[0098] In the specific implementation, after creating a data operation log lock tag for the target tenant, the synchronization API interface provided by the third-party SaaS cloud platform can be called according to the target operation type (add, delete, update) in the target data operation log record to synchronize the operation data to the third-party SaaS cloud platform. Then, different operations are executed based on the feedback information from the third-party SaaS cloud platform.
[0099] When the feedback message indicates successful synchronization, retrieve the current synchronization log primary key of the target tenant and determine if it matches the log primary key in the tenant's latest key-value pair data format cache. If they match, the data synchronization operation is considered successful, and the corresponding key-value pair cached data for the target tenant is removed from the cache layer. If they do not match, check if the current synchronization log primary key matches the data operation log lock flag of the target tenant. If they match, the data synchronization operation is considered successful, and the corresponding key-value pair cached data for the target tenant is deleted from the tenant's latest key-value pair data format cache. If they do not match, the current thread's execution ends.
[0100] Furthermore, in this embodiment of the invention, when the feedback information is a network connection status, the process jumps to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant.
[0101] In the actual implementation, when the feedback information is about network connectivity, such as network fluctuations or the shutdown of third-party SaaS cloud platform services, the process will directly jump to the step of determining whether the primary key of the current synchronization log is the same as the data operation log lock mark of the target tenant, and start the next round of execution.
[0102] Furthermore, in this embodiment of the invention, when the feedback information is an error code list, the log corresponding to the current synchronization log primary key is taken as the error operation log, and the process jumps to execute the step of determining whether the current synchronization log primary key is the same as the data operation log lock mark of the target tenant.
[0103] In the actual implementation, if the feedback information is a list of error codes, then the corresponding special processing is performed according to the specific error code.
[0104] For example, personnel data has a specific order requirement (personnel must belong to a department, with the department appearing first and the personnel appearing later). If subsequent data is processed before the preceding data exists on the third-party SaaS cloud platform, an error message will appear indicating that the personnel / department does not exist. In this case, `retryCount` can be used to first archive the error operation log and then directly jump to the step of checking if the primary key of the current synchronization log is the same as the data operation log lock flag of the target tenant, and then start a new round of execution. If the specified number of retries is exceeded, the `deleteFlag` (logical deletion flag) of the record will be marked as deleted.
[0105] Furthermore, such as Figure 2 As shown in this embodiment of the invention, an operation platform can be set up to monitor the entire cross-platform data synchronization process. Through the operation platform, records marked as deleted can be queried, the status of the record can be manually restarted, and data synchronization can be restarted.
[0106] This invention, in its embodiments, obtains the corresponding target data operation log records by constructing key-value pairs for the target tenants that generate operational data changes. Execution is performed in separate threads to avoid interference between different synchronization tasks. Then, during data synchronization, the existence of a data operation log lock flag is checked to prevent duplicate execution of synchronization tasks. This improves the synchronization effect of cross-platform data synchronization in the multi-tenant module.
[0107] Please see Figure 4 , Figure 4 This is a structural block diagram of a multi-tenant mode cross-platform data synchronization device provided in an embodiment of the present invention.
[0108] This invention provides a multi-tenant mode cross-platform data synchronization device, comprising:
[0109] The data operation log table generation module 401 is used to generate a data operation log table when the SaaS cloud platform generates operation behavior;
[0110] The target tenant and operation type determination module 402 is used to determine the target tenant and operation type corresponding to the operation behavior;
[0111] The tenant's latest key-value pair data format cache generation module 403 is used to generate key-value pairs for each target tenant and to generate the tenant's latest key-value pair data format cache using the key-value pairs;
[0112] The target data operation log query module 404 is used to create operation threads for each target tenant and query target data operation log records from the data operation log table based on the key-value pairs and operation types of each target tenant.
[0113] The data operation log lock tag query module 405 is used to query whether there is a corresponding data operation log lock tag for the target tenant.
[0114] The synchronization module 406 is used to create a data operation log lock tag for the target tenant if it does not exist, and to synchronize operation data to the third-party SaaS cloud platform according to the target data operation log record.
[0115] In this embodiment of the invention, the tenant's latest key-value pair data format cache generation module 403 includes:
[0116] The tenant primary key and log primary key retrieval submodule is used to retrieve the tenant primary key and log primary key for each target tenant;
[0117] The key-value pair generation submodule is used to generate key-value pairs for each target tenant, using the tenant's primary key as the key and the log's primary key as the value.
[0118] The tenant's latest key-value pair data format cache generation submodule is used to generate a cache of the tenant's latest key-value pair data format using key-value pairs.
[0119] In this embodiment of the invention, the target data operation log recording query module 404 includes:
[0120] The data operation log query submodule is used to create operation threads for each target tenant and query the data operation log records of the target tenant from the data operation log table based on the tenant primary key and operation type of each target tenant.
[0121] The target data operation log record determination submodule is used to determine the target data operation log record from the data operation log record according to the creation time.
[0122] In this embodiment of the invention, the synchronization module 406 includes:
[0123] The Synchronous API Interface Call Submodule is used to call the synchronous API interface of the third-party SaaS cloud platform based on the target operation type recorded in the target data operation log.
[0124] The operation data synchronization submodule is used to synchronize operation data with third-party SaaS cloud platforms through the synchronization API interface;
[0125] The feedback information receiving submodule is used to receive feedback information from the third-party SaaS cloud platform in response to operation data feedback.
[0126] The current synchronization log primary key retrieval submodule is used to retrieve the current synchronization log primary key of the target tenant when the feedback information indicates successful synchronization.
[0127] The first judgment submodule is used to determine whether the primary key of the current synchronization log is the same as the primary key of the log in the tenant's latest key-value pair data format cache.
[0128] The first key-value pair deletion submodule is used to determine that the data synchronization is successful if the values are the same, and to delete the key-value pair corresponding to the target tenant from the latest key-value pair data format cache of the tenant.
[0129] In this embodiment of the invention, the synchronization module 406 further includes:
[0130] The second judgment submodule is used to determine whether the current synchronization log primary key is the same as the data operation log lock flag of the target tenant if the current synchronization log primary key is different from the log primary key in the latest key-value pair data format cache of the tenant.
[0131] The second deletion submodule is used to determine that the data synchronization was successful if the data is the same, and to delete the key-value pair corresponding to the target tenant from the latest key-value pair data format cache of the tenant.
[0132] In this embodiment of the invention, the synchronization module 406 further includes:
[0133] The first jump rotor module is used to jump to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant when the feedback information is the network connection status.
[0134] In this embodiment of the invention, the synchronization module 406 further includes:
[0135] The second jump rotor module is used to, when the feedback information is an error code list, take the log corresponding to the current synchronization log primary key as the error operation log, and jump to execute the step of judging whether the current synchronization log primary key is the same as the data operation log lock mark of the target tenant.
[0136] This invention also provides an electronic device, which includes a processor and a memory:
[0137] The memory is used to store program code and transfer the program code to the processor;
[0138] The processor is used to execute the multi-tenant mode cross-platform data synchronization method of this invention according to the instructions in the program code.
[0139] This invention also provides a computer-readable storage medium for storing program code for executing the multi-tenant mode cross-platform data synchronization method of this invention.
[0140] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0141] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0142] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0143] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0144] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0146] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0147] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0148] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A cross-platform data synchronization method in a multi-tenant mode, characterized in that, include: When the SaaS cloud platform generates an operation, a data operation log table is generated; Determine the target tenant and operation type corresponding to the operation; Generate key-value pairs for each target tenant, and use the key-value pairs to generate a cache of the latest key-value pair data format for the tenant; Create operation threads for each target tenant, execute synchronization tasks in the operation threads, and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant. Check if a corresponding data operation log lock flag exists for the target tenant; If it does not exist, create the data operation log lock tag for the target tenant and synchronize the operation data to the third-party SaaS cloud platform according to the target data operation log record; The step of generating key-value pairs for each target tenant and using the key-value pairs to generate a cache of the latest key-value pair data format for the tenant includes: Obtain the tenant primary key and log primary key for each target tenant; Using the tenant's primary key as the key and the log's primary key as the value, generate key-value pairs for each target tenant; The key-value pairs are used to generate a cache of the latest key-value pair data format for the tenant.
2. The method according to claim 1, characterized in that, The steps of creating operation threads for each target tenant and querying target data operation log records from the data operation log table based on the key-value pairs and operation types of each target tenant include: Create operation threads for each target tenant, and query the data operation log records of the target tenant from the data operation log table according to the tenant primary key and operation type of each target tenant; The target data operation log record is determined from the data operation log records according to the creation time.
3. The method according to claim 1, characterized in that, The step of synchronizing operation data with a third-party SaaS cloud platform based on the target data operation log records includes: Based on the target operation type recorded in the target data operation log, call the synchronization API interface of the third-party SaaS cloud platform; The operation data is synchronized to the third-party SaaS cloud platform through the synchronization API interface; Receive feedback information from the third-party SaaS cloud platform in response to the operation data feedback; When the feedback information indicates successful synchronization, obtain the current synchronization log primary key of the target tenant; Determine whether the current synchronization log primary key is the same as the log primary key in the tenant's latest key-value pair data format cache; If they are the same, the operation data synchronization is determined to be successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
4. The method according to claim 3, characterized in that, Also includes: If the current synchronization log primary key is different from the log primary key in the latest key-value pair data format cache of the tenant, then determine whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant; If they are the same, the operation data synchronization is determined to be successful, and the key-value pair corresponding to the target tenant is deleted from the latest key-value pair data format cache of the tenant.
5. The method according to claim 4, characterized in that, Also includes: When the feedback information is about network connectivity, proceed to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant.
6. The method according to claim 4, characterized in that, Also includes: When the feedback information is an error code list, the log corresponding to the current synchronization log primary key is taken as the error operation log, and the process jumps to the step of determining whether the current synchronization log primary key is the same as the data operation log lock tag of the target tenant.
7. A multi-tenant cross-platform data synchronization device, characterized in that, include: The data operation log table generation module is used to generate a data operation log table when the SaaS cloud platform performs operations. The target tenant and operation type determination module is used to determine the target tenant and operation type corresponding to the operation behavior; The tenant's latest key-value pair data format cache generation module is used to generate key-value pairs for each of the target tenants and to generate the tenant's latest key-value pair data format cache using the key-value pairs; The target data operation log query module is used to create operation threads for each target tenant, execute synchronization tasks in the operation threads, and query target data operation log records from the data operation log table according to the key-value pairs and operation types of each target tenant. The data operation log lock tag query module is used to query whether a data operation log lock tag for the corresponding target tenant exists. The synchronization module is used to create the data operation log lock tag for the target tenant if it does not exist, and to synchronize the operation data to the third-party SaaS cloud platform according to the target data operation log record. The module for generating the latest key-value pair data format cache for tenants includes: The tenant primary key and log primary key retrieval submodule is used to retrieve the tenant primary key and log primary key for each target tenant; The key-value pair generation submodule is used to generate key-value pairs for each target tenant, using the tenant's primary key as the key and the log's primary key as the value. The tenant's latest key-value pair data format cache generation submodule is used to generate a cache of the tenant's latest key-value pair data format using key-value pairs.
8. An electronic device, characterized in that, The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the multi-tenant mode cross-platform data synchronization method according to any one of claims 1-6 according to the instructions in the program code.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for executing the multi-tenant mode cross-platform data synchronization method according to any one of claims 1-6.