Data synchronization method, device, electronic device and storage medium

By setting different synchronization conditions and data acquisition methods for different clients on the blockchain platform, the problem that data synchronization cannot be controlled in fine-grained manner in the existing technology is solved, and efficient data synchronization and resource utilization are achieved, which is suitable for one-way accessibility network environments.

CN113779153BActive Publication Date: 2025-03-21SICHUAN JIUYUAN YINHAI SOFTWARE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111080658.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-15
Publication Date
2025-03-21
Estimated Expiration
2041-09-15

AI Technical Summary

Technical Problem

Data synchronization technology on existing blockchain platforms cannot be fine-grained according to the needs of different clients, resulting in unnecessary data synchronization increasing network load and resource consumption.

Method used

By setting different synchronization conditions for different clients, using the data synchronization configuration table to query the client's identity, data table identification information and data location information, determine the data acquisition method (full or incremental) and obtain the data to be synchronized, and finally synchronize the encapsulated data to the client.

Benefits of technology

It realizes fine-grained and controllable data synchronization, reduces unnecessary data synchronization, improves network efficiency and resource utilization, and realizes data synchronization in a one-way accessible network environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113779153B_ABST
    Figure CN113779153B_ABST
Patent Text Reader

Abstract

The present application discloses a data synchronization method, device, electronic device and storage medium, the method comprising: receiving a data synchronization request sent by a client; querying data table identification information and data location information corresponding to an identity identifier from a data synchronization configuration table; comparing the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method for the data table to be synchronized; based on the data acquisition method and data location information, acquiring the data to be synchronized; encapsulating all acquired data to be synchronized, and synchronizing the encapsulated data to the client. By adopting the above-mentioned data synchronization method, device, electronic device and storage medium, the problem of being unable to provide different synchronization data for different clients during data synchronization is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data synchronization method, device, electronic device and storage medium. Background Art

[0002] Blockchain is a distributed shared ledger and database with the characteristics of decentralization, immutability, full traceability, traceability, collective maintenance, openness and transparency. With the continuous development of blockchain alliance technology, most blockchain Baas platforms are based on centralized application and service resource models to build management and operation platforms.

[0003] In the prior art, data synchronization technology on blockchain platforms is usually synchronization from the server to the client, and each synchronization will synchronize all data or modified data on the server to all clients. However, when synchronizing data for multiple clients, not every client needs to synchronize all data on the server, but only needs to keep part of the data synchronized. Summary of the invention

[0004] In view of this, the present application provides a data synchronization method, device, electronic device and storage medium, the purpose of which is to achieve a fine-grained and controllable data synchronization method by setting different synchronization conditions for different clients.

[0005] In a first aspect, an embodiment of the present application provides a data synchronization method, including:

[0006] Receive a data synchronization request sent by a client, the data synchronization request including the client's identity and the last synchronization time;

[0007] Querying data table identification information and data location information corresponding to the identity identifier from the data synchronization configuration table, where the data synchronization configuration table stores a correspondence between the identity identifier, the data table identification information, and the data location information;

[0008] Compare the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method;

[0009] Based on the data acquisition method and data location information, the data to be synchronized is acquired;

[0010] Encapsulate all acquired data to be synchronized, and synchronize the encapsulated data to the client.

[0011] Optionally, comparing the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method may include: querying in the data synchronization record table whether there is a last synchronization time corresponding to the data table identification information, the data synchronization record table stores the last synchronization time corresponding to the data table identification information; if there is a last synchronization time corresponding to the data table identification information, determining that the data acquisition method is incremental acquisition; if there is no last synchronization time corresponding to the data table identification information, determining that the data acquisition method is full acquisition.

[0012] Optionally, the data synchronization method may further include: judging whether there is synchronization data loss based on the last synchronization time; if there is synchronization data loss, querying the data synchronization history table for historical synchronization records corresponding to the data table identification information and whose data synchronization time is between the last synchronization time and the last synchronization time, and sending the queried historical synchronization records to the client, the data synchronization history table is used to store the historical records of each synchronization, and the data synchronization loss record table is used to store the historical records corresponding to the lost synchronization data.

[0013] Optionally, based on the last synchronization time, determining whether there is synchronization data loss may include: determining whether the last synchronization time is earlier than the last synchronization time; if the last synchronization time is earlier than the last synchronization time, determining that there is synchronization data loss; if the last synchronization time is not earlier than the last synchronization time, determining that there is no synchronization data loss.

[0014] Optionally, obtaining the data to be synchronized based on the data acquisition method and the data location information may include: based on the data acquisition method, obtaining the data to be synchronized that corresponds to the data location information and meets the synchronization conditions from a database storing the data to be synchronized, wherein a data table corresponding to the data table identification information is stored in the database, and the data table stores the data to be synchronized that corresponds to the data location information, and the synchronization conditions are stored in a data synchronization configuration table for determining the data to be synchronized that meets the conditions.

[0015] Optionally, after receiving the data synchronization request sent by the client, it may also include: matching the identity with a preset identity whitelist, if the match is successful, determining that the client's identity is valid; if the match is unsuccessful, rejecting the data synchronization request sent by the client.

[0016] In a second aspect, an embodiment of the present application provides a data synchronization device, including:

[0017] A receiving module, used to receive a data synchronization request sent by a client, the data synchronization request includes the client's identity and the last synchronization time;

[0018] A query module, used to query data table identification information and data location information corresponding to the identity identifier from a data synchronization configuration table, wherein the data synchronization configuration table stores a correspondence between the identity identifier, the data table identification information and the data location information;

[0019] A determination module, used to compare the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method;

[0020] An acquisition module, used to acquire the data to be synchronized based on the data acquisition method and data location information;

[0021] The synchronization module is used to encapsulate all the acquired data to be synchronized and synchronize the encapsulated data to the client.

[0022] Optionally, the determination module can also be used to: query whether there is a last synchronization time corresponding to the data table identification information in the data synchronization record table, and the data synchronization record table stores the last synchronization time corresponding to the data table identification information; if there is a last synchronization time corresponding to the data table identification information, then determine that the data acquisition method is incremental acquisition; if there is no last synchronization time corresponding to the data table identification information, then determine that the data acquisition method is full acquisition.

[0023] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the data synchronization method as described above are performed.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned data synchronization method are executed.

[0025] The embodiments of the present application bring the following beneficial effects:

[0026] The embodiments of the present application provide a data synchronization method, device, electronic device and storage medium, including: receiving a data synchronization request sent by a client, the data synchronization request including the client's identity and the last synchronization time; querying data table identification information and data location information corresponding to the identity from a data synchronization configuration table, the data synchronization configuration table storing the correspondence between the identity, the data table identification information and the data location information; comparing the last synchronization time with the last synchronization time corresponding to the data table identification information to determine a data acquisition method; acquiring data to be synchronized based on the data acquisition method and the data location information; encapsulating all acquired data to be synchronized, and synchronizing the encapsulated data to the client, thereby solving the problem that different synchronization data cannot be provided to different clients during data synchronization, and the synchronization conditions and synchronization fields are uncontrollable.

[0027] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the following drawings are some implementation methods of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0029] Figure 1 A flowchart of a data synchronization method provided in an embodiment of the present application;

[0030] Figure 2 A schematic diagram of the structure of a data synchronization device provided in an embodiment of the present application;

[0031] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0033] In the prior art, data synchronization is usually performed from the server to the client, and each synchronization will synchronize all data on the server or part of the modified data to all clients. However, when synchronizing data to multiple clients, not every client needs to synchronize all data on the server. Some clients only need to synchronize part of the data. At the same time, when the client is in an intranet environment (confidential network or high-security network environment) and the server is in an extranet environment, the server cannot obtain synchronization data from the client, and cannot synchronize data in a one-way reachable network environment.

[0034] Based on this, the embodiments of the present application provide a data synchronization method, device, electronic device and storage medium, which solves the problem that different synchronization data cannot be provided to different clients during data synchronization, and the synchronization conditions and synchronization fields are uncontrollable. At the same time, it also solves the problem that data synchronization cannot be performed in a one-way reachable network environment.

[0035] To facilitate understanding of this embodiment, a data synchronization method disclosed in an embodiment of the present application is first introduced in detail. Figure 1 A flow chart of a data synchronization method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method comprises the following steps:

[0036] Step 101: Receive a data synchronization request sent by a client. The data synchronization request includes the client's identity and the last synchronization time.

[0037] Specifically, it is necessary to first create multiple data synchronization tables. These data synchronization tables can be created on both the server and the client. The purpose of creating these data synchronization tables on the client is to not only enable the client to initiate a data synchronization request to the server from which the server synchronizes data with the client, but also enable the client to initiate a data synchronization request to the server from which the client synchronizes data with the server, which is equivalent to the client realizing the function of the server. In this way, indirect data synchronization between clients can be realized. These data synchronization tables include: a data synchronization configuration table, a data synchronization record table, a data synchronization history table, and a data synchronization loss record table. Among them, the fields in the data synchronization configuration table include but are not limited to table name, field name, primary key, synchronization condition, and identity. The table name field is used to configure the table name of the data table to be synchronized where the data to be synchronized is located; the field name field is used to configure the field name of the field where the data to be synchronized is located in the data table to be synchronized; the primary key field is used to configure the primary key data corresponding to the row where the data to be synchronized is located in the primary key field of the data table to be synchronized, and the data location information of the data to be synchronized can be determined by the field name and the primary key; the identity field is used to configure which clients corresponding to which identities can synchronize the data table to be synchronized in the table name field. The data synchronization record table records the timestamp, synchronization quantity, and synchronization identifier corresponding to the last synchronization time of each data table synchronized by each client. It also records the corresponding content of each data table in the data synchronization configuration table, such as synchronization fields, synchronization conditions, and primary keys. The synchronization quantity is used to record how many data items have been synchronized in the data table, and the synchronization identifier is used to record whether the data table has been synchronized successfully. Here, the data synchronization table that records the corresponding content of each data table in the data synchronization configuration table is called a full table. The data synchronization history table records the historical records of each synchronization of each client, and the data synchronization history table is also a full table. The data synchronization loss record table records the historical records corresponding to the lost synchronization data, and the data synchronization loss record table is also a full table.

[0038] Based on the created data synchronization table, the server can synchronize data with the client that sent the data synchronization request. The information in the data synchronization request includes but is not limited to: the client's identity, the last synchronization time, the type of data to be synchronized, and the device information. Here, the identity is a unique identifier corresponding to each client, such as APPID. The last synchronization time refers to the timestamp generated by the client when the client last synchronized data with the server. There will be a special table on the client to record the time of each data synchronization.

[0039] In one example, after receiving a data synchronization request sent by a client, the identity is matched with a preset identity whitelist. If the match is successful, the client's identity is determined to be valid; if the match is unsuccessful, the data synchronization request sent by the client is rejected. It can be understood that after receiving a data synchronization request sent by a client, the validity of the client's identity needs to be verified to ensure that the data synchronization request can be accepted.

[0040] Step 102: query the data table identification information and data location information corresponding to the identity identifier from the data synchronization configuration table. The data synchronization configuration table stores the corresponding relationship between the identity identifier, the data table identification information and the data location information.

[0041] Specifically, after determining that the client identity is valid, it is necessary to determine which data to synchronize to the client. First, the data synchronization configuration table includes the table name field, field name field, primary key field, and identity field, that is, the data synchronization configuration table stores the correspondence between the identity, data table identification information, and data location information. Therefore, the data table identification information and data location information corresponding to the identity can be queried from the data configuration table.

[0042] Taking the above example, the data table identification information is the table name of the data table to be synchronized, and the data location information can be determined by the field name and the content configured in the primary key field.

[0043] Step 103: compare the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method.

[0044] Specifically, a query is made in the data synchronization record table as to whether there is a last synchronization time corresponding to the data table identification information. The data synchronization record table stores the last synchronization time corresponding to the data table identification information. If there is a last synchronization time corresponding to the data table identification information, the data acquisition method is determined to be incremental acquisition. If there is no last synchronization time corresponding to the data table identification information, the data acquisition method is determined to be full acquisition.

[0045] In one example, if there are multiple data tables to be synchronized corresponding to the data table identification information, then in the data synchronization record table, each data table to be synchronized is queried in turn according to the data table identification information to see whether there is a last synchronization time corresponding to the data table identification information, and for each data table to be synchronized, the data acquisition method corresponding to the data table to be synchronized is determined. If there is no last synchronization time corresponding to the data table identification information, it means that it is the first synchronization, and the data acquisition method is determined to be full acquisition; if there is a last synchronization time corresponding to the data table identification information, it means that it is not the first synchronization, and the data acquisition method is determined to be incremental acquisition.

[0046] During the data synchronization process, synchronization data loss may occur due to network instability, power outages, or abnormal downtime. Therefore, it is necessary to determine whether there is synchronization data loss in the time interval from the last synchronization time to the last synchronization time. If there is synchronization data loss, the synchronization record of the specific synchronization data loss can be sent to the client so that it can accurately locate the cause of the synchronization data loss or re-acquire the data to be synchronized corresponding to the time point of synchronization data loss. The above process can be implemented through the following steps: based on the last synchronization time, determine whether there is synchronization data loss; if there is synchronization data loss, query the historical synchronization record corresponding to the data table identification information and the data synchronization time between the last synchronization time and the last synchronization time in the data synchronization history table, and send the queried historical synchronization record to the client. Here, the data synchronization history table is used to store the historical records of each synchronization, and the data synchronization loss record table is used to store the historical records corresponding to the lost synchronization data.

[0047] Among them, the following process can be used to determine whether there is synchronization data loss: determine whether the last synchronization time is earlier than the last synchronization time; if the last synchronization time is earlier than the last synchronization time, it is determined that there is synchronization data loss; if the last synchronization time is not earlier than the last synchronization time, it is determined that there is no synchronization data loss.

[0048] Taking the above example as an example, if the last synchronization time recorded by the client is earlier than the last synchronization time recorded in the server data synchronization record table, it means that the last synchronization time recorded by the client is inconsistent with the last synchronization time recorded by the server for the client. This is because one or several data synchronizations during the period between the last synchronization time and the last synchronization time were not synchronized normally by the client, and there is a situation of synchronization data loss. On the contrary, if the last synchronization time recorded by the client is not earlier than the last synchronization time recorded in the server data synchronization record table, it means that the last synchronization time recorded by the client is consistent with the last synchronization time recorded by the server for the client, and there is no synchronization data loss. Here, since the data synchronization history table records the historical records of each synchronization of each client, and the data synchronization history table is a full table, all historical synchronization records corresponding to the data table identification information can be queried from the data synchronization history table according to the data table identification information, and the historical synchronization records whose data synchronization time is between the last synchronization time and the last synchronization time are selected, and the selected historical synchronization records are sent to the client. After the client receives the historical synchronization records sent by the server, it writes them into the data synchronization loss record table, so that the client can record which synchronization time points the data was not synchronized by it.

[0049] Step 104: Acquire the data to be synchronized based on the data acquisition method and data location information.

[0050] Specifically, the data to be synchronized can be acquired according to the determined data acquisition method and data location information. The data to be synchronized can be acquired through the following specific steps: based on the data acquisition method, the data to be synchronized corresponding to the data location information and meeting the synchronization conditions are acquired from a database storing the data to be synchronized, wherein a data table corresponding to the data table identification information is stored in the database, and the data table stores the data to be synchronized corresponding to the data location information, and the synchronization conditions are stored in the data synchronization configuration table, which is used to determine the data to be synchronized that meets the conditions.

[0051] Taking the above example as an example, based on the data table identification information and data location information, it is possible to determine in which data table the data to be synchronized is stored, as well as the specific field name and primary key corresponding to the data to be synchronized in the data table, so that the data to be synchronized that has not been filtered by the synchronization conditions can be determined, and then, based on the synchronization conditions corresponding to the data table identification information configured in the data synchronization configuration table, the data to be synchronized that has been filtered by the synchronization conditions can be determined. For example: the data to be synchronized that has not been filtered by the synchronization conditions is all the data in the telephone number field of the user data table. If the synchronization condition is that only telephone numbers starting with 130 can be synchronized to the client, then based on the synchronization condition, the data of telephone numbers starting with 130 in the telephone number field of the user data table is determined as the data to be synchronized.

[0052] Here, a SQL script for data query can be constructed according to the data table identification information, data location information and synchronization conditions, and then the server calls and runs the SQL script to obtain the data to be synchronized corresponding to the data acquisition method from the database. It can be understood that obtaining the data to be synchronized corresponding to the data acquisition method from the database means that if the data acquisition method is full acquisition, the data to be synchronized corresponding to the data table identification information and data location information and whose data synchronization time is before the last synchronization time is obtained from the database. If the data acquisition method is incremental acquisition, the data to be synchronized corresponding to the data table identification information and data location information and whose data synchronization time is between the last synchronization time and the last synchronization time is obtained from the database.

[0053] It should be pointed out that if the data table identification information corresponds to multiple data tables to be synchronized, a data query SQL script is constructed for each data table to be synchronized, and then the server calls and runs the SQL script to obtain the data to be synchronized corresponding to the data acquisition method from the database.

[0054] Step 105: encapsulate all acquired data to be synchronized, and synchronize the encapsulated data to the client.

[0055] Specifically, after obtaining the data to be synchronized, it is necessary to encapsulate the data to be synchronized. The encapsulation process includes serializing and asymmetric encryption of the data to be processed. Here, serialization is a data exchange format, including but not limited to JSON, XML, YAML. Technical personnel in this field can choose according to actual conditions, and this application does not limit this. Asymmetric encryption is implemented through an asymmetric encryption algorithm. Asymmetric encryption algorithms include but are not limited to RSA, Elgamal, backpack algorithm, Rabin, DH, ECC. Technical personnel in this field can choose according to actual conditions, and this application does not limit this. Finally, the encapsulated data is synchronized to the client, and the data synchronization record table and the data synchronization history table are updated. After the client completes data synchronization, the last synchronization time will also be updated.

[0056] It can be seen that the above data synchronization method can not only provide different synchronization data for different clients and realize fine-grained controllable data synchronization through the client actively sending data synchronization requests to the server and configuring the data synchronization scheme, but also realize data synchronization in a one-way reachable network environment.

[0057] Figure 2 A schematic diagram of the structure of a data synchronization device provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the device includes the following modules:

[0058] The receiving module 201 is used to receive a data synchronization request sent by a client, where the data synchronization request includes the identity of the client and the last synchronization time.

[0059] The query module 202 is used to query the data table identification information and data location information corresponding to the identity identifier from the data synchronization configuration table, and the data synchronization configuration table stores the correspondence between the identity identifier, the data table identification information and the data location information.

[0060] The determination module 203 is used to compare the last synchronization time with the last synchronization time corresponding to the data table identification information to determine the data acquisition method.

[0061] The acquisition module 204 is used to acquire the data to be synchronized based on the data acquisition method and the data location information.

[0062] The synchronization module 205 is used to encapsulate all acquired data to be synchronized, and synchronize the encapsulated data to the client.

[0063] Corresponds to Figure 1 The data synchronization method in the present application embodiment also provides a structural diagram of an electronic device 300, such as Figure 3As shown, the electronic device 300 includes a processor 310, a memory 320 and a bus 330. The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 communicates with the memory 320 through the bus 330. When the machine-readable instructions are executed by the processor 310, the above-mentioned data synchronization method can be executed by the client actively sending a data synchronization request to the server and the data synchronization scheme configuration method, which can not only provide different synchronization data for different clients and realize fine-grained controllable data synchronization, but also realize data synchronization in a one-way reachable network environment.

[0064] Corresponds to Figure 1 In the data synchronization method, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned data synchronization method are executed.

[0065] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the above-mentioned data synchronization method can be executed. By the client actively sending a data synchronization request to the server and configuring the data synchronization scheme, it can not only provide different synchronization data for different clients and realize fine-grained controllable data synchronization, but also realize data synchronization in a one-way reachable network environment.

[0066] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the above method embodiments and will not be repeated here.

[0067] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0068] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0069] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0070] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0071] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0072] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A data synchronization method, characterized in that: Applied to a server, the data synchronization method includes: Receiving a data synchronization request sent by a client, wherein the data synchronization request includes an identity identifier of the client and a last synchronization time; Querying data table identification information and data location information corresponding to the identity identifier from a data synchronization configuration table, wherein the data synchronization configuration table stores a correspondence between the identity identifier, the data table identification information, and the data location information; Determine a data acquisition method according to the last synchronization time corresponding to the data table identification information, wherein the last synchronization time is the time when the client last synchronized the data table corresponding to the data table identification information; Based on the data acquisition method, acquiring the data to be synchronized corresponding to the data location information from a database; Encapsulating all acquired data to be synchronized, and synchronizing the encapsulated data to the client; The determining of the data acquisition method according to the last synchronization time corresponding to the data table identification information includes: querying in a data synchronization record table whether there is a last synchronization time corresponding to the data table identification information, wherein the data synchronization record table stores the last synchronization time corresponding to the data table identification information; If there is a last synchronization time corresponding to the data table identification information, determining that the data acquisition mode is incremental acquisition; If there is no last synchronization time corresponding to the data table identification information, it is determined that the data acquisition mode is full acquisition.

2. The data synchronization method according to claim 1, characterized in that: The data synchronization method further includes: Based on the last synchronization time, determining whether there is synchronization data loss; If there is synchronization data loss, the historical synchronization records corresponding to the data table identification information and whose data synchronization time is between the last synchronization time and the last synchronization time are queried in the data synchronization history table, and the queried historical synchronization records are sent to the client. The data synchronization history table is used to store the historical records of each synchronization, and the data synchronization loss record table is used to store the historical records corresponding to the lost synchronization data.

3. The data synchronization method according to claim 2, characterized in that: The determining whether there is synchronization data loss based on the last synchronization time includes: Determine whether the last synchronization time is earlier than the last synchronization time; If the last synchronization time is earlier than the last synchronization time, it is determined that synchronization data is lost; If the last synchronization time is not earlier than the final synchronization time, it is determined that there is no synchronization data loss.

4. The data synchronization method according to claim 1, characterized in that: The acquiring the to-be-synchronized data corresponding to the data location information from the database based on the data acquisition method includes: Based on the data acquisition method, the data to be synchronized corresponding to the data location information and meeting the synchronization conditions are obtained from a database storing the data to be synchronized, the database storing a data table corresponding to the data table identification information, the data table storing the data to be synchronized corresponding to the data location information, and the synchronization conditions are stored in the data synchronization configuration table for determining the data to be synchronized that meets the conditions.

5. The data synchronization method according to claim 1, characterized in that: After receiving the data synchronization request sent by the client, the method further includes: Matching the identity with a preset identity whitelist, and if the match succeeds, determining that the identity of the client is valid; If the match is unsuccessful, the data synchronization request sent by the client is rejected.

6. A data synchronization device, characterized in that: include: A receiving module, configured to receive a data synchronization request sent by a client, wherein the data synchronization request includes an identity identifier of the client and a last synchronization time; A query module, used to query data table identification information and data location information corresponding to the identity identifier from a data synchronization configuration table, wherein the data synchronization configuration table stores a correspondence between the identity identifier, the data table identification information and the data location information; A determination module, configured to determine a data acquisition method according to a last synchronization time corresponding to the data table identification information, wherein the last synchronization time is the time when the client last synchronized the data table corresponding to the data table identification information; An acquisition module, used for acquiring the to-be-synchronized data corresponding to the data location information from a database based on the data acquisition method; A synchronization module, used to encapsulate all acquired data to be synchronized, and synchronize the encapsulated data to the client; The determining module is also used for: querying in a data synchronization record table whether there is a last synchronization time corresponding to the data table identification information, wherein the data synchronization record table stores the last synchronization time corresponding to the data table identification information; If there is a last synchronization time corresponding to the data table identification information, determining that the data acquisition mode is incremental acquisition; If there is no last synchronization time corresponding to the data table identification information, it is determined that the data acquisition mode is full acquisition.

7. An electronic device, characterized in that: It includes a processor, a memory and a bus, the memory stores machine-readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the data synchronization method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data synchronization method according to any one of claims 1 to 5 are executed.

Citation Information

Patent Citations

  • Data synchronizing method and device

    CN105787077A

  • Method and device for data synchronization

    CN106101256A