Data synchronization methods, devices, equipment, and storage media

CN116962430BActive Publication Date: 2026-09-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210395610.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-14
Publication Date
2026-09-22
Estimated Expiration
2042-04-14

AI Technical Summary

Benefits of technology

[0027]在本实施例中,通过第一序列号,确定数据的同步方式,相当于,考虑到在数据变化频繁的场景中,可能有大量的数据删除操作,此时,若直接使用增量同步,则需同步大量指示信息指示不保留的待同步节点,反倒会导致性能降低,同步资源浪费;所以,利用第一序列号,可以明确增量数据,进而可以通过对增量数据和全量数据进行比较,确定数据的同步方法,即,利用第一序列号,能够使服务器根据数据同步的实际情况,选择最优的同步方式。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116962430B_ABST
    Figure CN116962430B_ABST
Patent Text Reader

Abstract

This application provides a data synchronization method, apparatus, device, and storage medium, relating to the field of computer technology. The method includes: receiving a data synchronization request sent by a terminal device, the data synchronization request including a first sequence number and a second sequence number; determining a data synchronization method based on the first sequence number; and when the synchronization method is incremental synchronization and the first sequence number is less than the second sequence number, sending data of a target node to the terminal device in ascending order of sequence numbers, the target node being a node on the server whose sequence number is greater than the first sequence number and less than or equal to the second sequence number, and whose indication information indicates it is reserved for synchronization. This method enables the server to select the optimal synchronization method based on the actual data synchronization situation. Furthermore, by introducing the concept of a second sequence number and synchronizing data in ascending order of sequence numbers, it can reduce the amount of data during incremental synchronization, improve synchronization efficiency, and save synchronization time and bandwidth.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to a data synchronization method, apparatus, device, and storage medium. Background Technology

[0002] Currently, when a terminal device needs to synchronize data for a certain business scenario from a server, there are two solutions: Solution 1: The server pulls all backend data related to the business scenario and synchronizes all backend data to the terminal device for its business scenario use; Solution 2: The server provides the ability to pull all child node data based on the parent node, and the terminal device obtains data from the server according to the actual needs of the business scenario.

[0003] However, Solution 1 is only suitable for scenarios with small data volumes, low data usage frequency, and infrequent data modification events. For scenarios with data volumes in the tens of thousands or frequent modification events, synchronizing all data at once will result in wasted bandwidth and synchronization time, becoming a bottleneck for the system. Although Solution 2 utilizes the hierarchical characteristics of a tree-like data structure and designs a method for real-time data retrieval by level, which can meet the needs of most hierarchical display business scenarios, it still faces the problem of large data volumes for single synchronization when a single parent node has too many child nodes or when recursively retrieving the entire subtree. Summary of the Invention

[0004] This application provides a data synchronization method, apparatus, device, and storage medium that enables the server to select the optimal synchronization method based on the actual data synchronization situation. Furthermore, by introducing the concept of a second sequence number and synchronizing data in ascending order of the sequence number, the amount of data during incremental synchronization can be reduced, synchronization efficiency can be improved, and synchronization time and bandwidth can be saved.

[0005] Firstly, this application provides a data synchronization method, which is applied to a server and includes:

[0006] The terminal device receives a data synchronization request, which includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0007] Based on this first sequence number, the data synchronization method is determined;

[0008] When the synchronization method is incremental synchronization and the first sequence number is less than the second sequence number, the data of the target node is sent to the terminal device in ascending order of the sequence number. The target node is the node to be synchronized on the server whose sequence number is greater than the first sequence number and less than or equal to the second sequence number, and whose indication information indicates that it is reserved.

[0009] Secondly, this application provides a data synchronization method, which is applied to a terminal device and includes:

[0010] Send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0011] Receive data from the target node sent by the server. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is reserved for synchronization.

[0012] The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number;

[0013] The data of the target node is merged and stored with the first data of the node to be synchronized that has been received locally.

[0014] Thirdly, this application provides a data synchronization device, which is a server, comprising:

[0015] The receiving unit is used to receive a data synchronization request sent by the terminal device. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0016] The determining unit is used to determine the data synchronization method based on the first sequence number;

[0017] The sending unit is used to send data of the target node to the terminal device in ascending order of the sequence number when the synchronization mode is incremental synchronization and the first sequence number is less than the second sequence number. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is to be reserved for synchronization.

[0018] Fourthly, this application provides a data synchronization device, which is a terminal device, comprising:

[0019] The sending unit is used to send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0020] The receiving unit is used to receive data from the target node sent by the server. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is a node to be synchronized and is reserved.

[0021] The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number;

[0022] The merging unit is used to merge and store the data of the target node with the first data of the node to be synchronized that has been received locally.

[0023] Fifthly, this application provides an electronic device, comprising:

[0024] A processor, adapted to execute computer programs;

[0025] A computer-readable storage medium storing a computer program, which is loaded by the processor and performs the methods of the first or second aspect described above.

[0026] In a sixth aspect, this application provides a computer-readable storage medium storing computer instructions that, when read and executed by a processor of a computer device, cause the computer device to perform the methods described in the first or second aspect.

[0027] In this embodiment, the data synchronization method is determined by the first sequence number. This is because, considering scenarios where data changes frequently and there may be a large number of data deletion operations, if incremental synchronization is used directly, a large amount of indication information would need to be synchronized to indicate nodes that should not be retained, which would lead to performance degradation and waste of synchronization resources. Therefore, by using the first sequence number, incremental data can be clearly identified, and then the data synchronization method can be determined by comparing the incremental data with the full data. In other words, by using the first sequence number, the server can select the optimal synchronization method based on the actual situation of data synchronization.

[0028] Furthermore, by introducing a second sequence number and synchronizing data in ascending order of sequence number during incremental synchronization, it is equivalent to considering that nodes to be synchronized on the server side that are greater than the first sequence number and less than or equal to the second sequence number are definitely nodes that have not been synchronized to the terminal. Therefore, during incremental synchronization, there is no need to consider the impact of node data that the indication information indicates is not to be retained on the terminal's local data. That is, only the nodes to be synchronized that the indication information indicates is retained within the range need to be synchronized, and the nodes to be synchronized that the indication information indicates is not to be retained need to be synchronized are not synchronized. This can reduce the amount of data during incremental synchronization, improve synchronization efficiency, and save synchronization time and traffic. Attached Figure Description

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

[0030] Figure 1 This is a scenario example diagram provided in the embodiments of this application.

[0031] Figure 2 This is a schematic flowchart of the data synchronization method provided in the embodiments of this application.

[0032] Figure 3 This is a schematic diagram of incremental synchronization provided in an embodiment of this application.

[0033] Figure 4 This is a schematic diagram of another incremental synchronization provided in an embodiment of this application.

[0034] Figure 5 This is another illustrative flowchart of the data synchronization method provided in the embodiments of this application.

[0035] Figure 6 This is another illustrative flowchart of the data synchronization method provided in the embodiments of this application.

[0036] Figure 7 This is a schematic block diagram of the data synchronization device provided in the embodiments of this application.

[0037] Figure 8 This is another schematic block diagram of the data synchronization device provided in the embodiments of this application.

[0038] Figure 9 This is a schematic structural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0039] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0040] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.

[0041] The solutions provided in this application also relate to data processing technology in the field of network media. Network media differs from traditional audio and video devices in its operating method; it relies on technologies and equipment provided by information technology (IT) equipment developers to transmit, store, and process audio and video signals. Traditional Serial Digital Induction (SDI) transmission lacks true network switching characteristics. Significant work is required to utilize SDI to create some of the network functions provided by Ethernet and Internet Protocol (IP). Therefore, network media technology has emerged. Furthermore, data processing technology for network media can include the transmission, storage, and processing of audio and video signals.

[0042] Figure 1 This is an example of scenario 100 provided in the embodiments of this application.

[0043] Scenario 100 can be an application system, and this application embodiment does not limit the specific type of the application. Scenario 100 includes: a terminal device 110 and a server 120. The terminal device 110 can be connected to the server 120 via a wireless or wired network.

[0044] Terminal device 110 can be one of a smartphone, game console, desktop computer, tablet computer, e-book reader, MP4 player, or laptop computer. Terminal device 110 has an application installed and running. This application can be any of the following: online video application, short video application, image sharing application, audio social application, animation application, wallpaper application, news push application, supply and demand information push application, academic exchange application, technical exchange application, policy exchange application, application with a comment mechanism, application with an opinion posting mechanism, or knowledge sharing application. Terminal device 110 can be a terminal used by user 130, and a user account is logged in within the application running on terminal device 110.

[0045] Server 120 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms. Servers can be connected directly or indirectly through wired or wireless communication, and this application does not impose any restrictions on this.

[0046] Optionally, taking scenario 100 as an example of a data synchronization scenario, the server 120 is used to provide data of nodes to be synchronized to the application (e.g., an application on the terminal device 110). The server 120 is used to receive a data synchronization request sent by the terminal device 110, determine the data to be synchronized based on the parameters in the data synchronization request, and send the data to be synchronized to the terminal device.

[0047] Currently, redundant data exists in the data that the server sends to the terminal device for synchronization, resulting in a waste of bandwidth and synchronization time.

[0048] Based on this, this application provides a data synchronization method, apparatus, device, and storage medium that enables the server to select the optimal synchronization method according to the actual situation of data synchronization. Moreover, by introducing the concept of a second sequence number and synchronizing data in ascending order of the sequence number, the amount of data during incremental synchronization can be reduced, synchronization efficiency can be improved, and synchronization time and bandwidth can be saved.

[0049] To facilitate understanding of the solutions in this application, the relevant terms used in this application will be explained below.

[0050] 1. Synchronization: This refers to sending data from the backend to the frontend via a protocol to ensure data consistency between the frontend and backend.

[0051] 2. Incremental Synchronization: This refers to a synchronization process where, after the last full or incremental synchronization, subsequent data synchronizations only need to update the data that has been added or modified compared to the previous synchronization. In other words, incremental synchronization only sends out the changed data during data synchronization. It should be understood that incremental synchronization can quickly update the terminal's data to the latest version when the differences between the terminal data and the backend data are small.

[0052] 3. Full synchronization: This refers to sending all data during each data synchronization. It should be understood that full synchronization is mostly used when the terminal has too much outdated data or no data at all.

[0053] It should be noted that the application scenarios of this application include, but are not limited to, data synchronization in the inspection and reporting of an enterprise's internal information platform. Inspection and reporting can be based on grid-based governance work orders. Members can report problems discovered during inspections to the grid, which is then uniformly assigned and processed by the grid center leader. This streamlined work order classification mechanism helps enterprises improve management efficiency. Specifically, the inspection and reporting grid can be a tree-like data structure, where work orders can flow to parent grid nodes, and each parent grid node can view the data of its child grid nodes. It should be understood that the terminal needs to persistently store the entire grid structure, and each time relevant data is needed, the terminal data must first be aligned with the backend data through a synchronization protocol.

[0054] Figure 2 This is a schematic flowchart of a data synchronization method 200 provided in an embodiment of this application. The method 200 can be executed by a server, for example... Figure 1 The server shown is 120.

[0055] S201, Receive a data synchronization request sent by a terminal device. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0056] S202, Based on the first sequence number, determine the data synchronization method;

[0057] S203, when the synchronization method is incremental synchronization and the first sequence number is less than the second sequence number, the target node data is sent to the terminal device in ascending order of sequence number. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is to be kept and synchronized.

[0058] In other words, the server receives a data synchronization request sent by the terminal device and determines whether the data synchronization method is incremental synchronization or full synchronization based on the first sequence number in the data synchronization request. When the synchronization method is determined to be incremental synchronization and the first sequence number is less than the second sequence number, the server sends data of nodes to be synchronized that have a sequence number greater than the first sequence number, less than or equal to the second sequence number, and an indication message indicating that the nodes are to be retained, to the terminal device in ascending order of sequence number.

[0059] It should be understood that if a full synchronization has not occurred before local data synchronization, then this is the first data synchronization, meaning that the second sequence number in this data synchronization request is equal to 0.

[0060] For example, each node to be synchronized on the server stores its own business data, as well as sequence number information and indication information; wherein, the sequence number information is used to uniquely correspond to the sequence number of the node to be synchronized, and the indication information is used to indicate whether the node to be synchronized should be retained; it should be understood that the sequence number of each node to be synchronized on the server is different.

[0061] For example, the sequence number of the node to be synchronized on the server can be incremented based on the first timestamp of the node to be synchronized.

[0062] If the information of the node to be synchronized is updated, the timestamp at which the information is updated will be determined as the first timestamp of the node to be synchronized; if the node to be synchronized is a newly added node, the timestamp at which the node to be synchronized is first stored will be determined as the first timestamp of the node to be synchronized.

[0063] For example, an incremental sequence number can be generated for each node to be synchronized based on the millisecond timestamp and the operation order. For instance, if different nodes to be synchronized have different millisecond timestamps, a monotonically increasing sequence number can be configured for each node directly along the timeline. If different nodes to be synchronized have the same millisecond timestamp, the node that operates earlier in the sequence will have a smaller sequence number, and the node that operates later in the sequence will have a larger sequence number.

[0064] It should be noted that the sequence number of the node to be synchronized can be generated in other ways, as long as the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized. This application does not impose specific restrictions on this.

[0065] Since the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized, the efficiency of obtaining incremental or full data during the data synchronization process is improved.

[0066] In this embodiment, the data synchronization method is determined by the first sequence number. This is because, considering scenarios where data changes frequently and there may be a large number of data deletion operations, if incremental synchronization is used directly, a large amount of indication information would need to be synchronized to indicate nodes that should not be retained, which would lead to performance degradation and waste of synchronization resources. Therefore, by using the first sequence number, incremental data can be clearly identified, and then the data synchronization method can be determined by comparing the incremental data with the full data. In other words, by using the first sequence number, the server can select the optimal synchronization method based on the actual situation of data synchronization.

[0067] Furthermore, by introducing a second sequence number and synchronizing data in ascending order of sequence number during incremental synchronization, it is equivalent to considering that nodes to be synchronized on the server side that are greater than the first sequence number and less than or equal to the second sequence number are definitely nodes that have not been synchronized to the terminal. Therefore, during incremental synchronization, there is no need to consider the impact of node data that the indication information indicates is not to be retained on the terminal's local data. That is, only the nodes to be synchronized that the indication information indicates is retained within the range need to be synchronized, and the nodes to be synchronized that the indication information indicates is not to be retained need to be synchronized are not synchronized. This can reduce the amount of data during incremental synchronization, improve synchronization efficiency, and save synchronization time and traffic.

[0068] The following will combine Figures 3 to 4 The incremental synchronization provided in this application is illustrated.

[0069] Figure 3 This is a schematic diagram of incremental synchronization provided in an embodiment of this application.

[0070] like Figure 3 As shown, the nodes to be synchronized include node 1 and node 2, which are received by the terminal; where the sequence number of node 1 is 1 and the sequence number of node 2 is 2.

[0071] The nodes to be synchronized on the server are Node 1, Node 2, Node 3, and Node 4; among them, the sequence number of Node 1 is 1, the sequence number of Node 2 is 2, the sequence number of Node 3 is 3, and the sequence number of Node 4 is 4.

[0072] For example, the terminal sends a data synchronization request to the server, including a first sequence number (such as...). Figure 3 As shown, the first sequence number equals 2). After receiving the data synchronization request, the server determines the data synchronization method. If the synchronization method is incremental synchronization, then data from nodes with sequence numbers greater than the first sequence number are sent to the terminal in ascending order of sequence number (e.g., ...). Figure 3 As shown, the nodes to be synchronized with sequence numbers greater than the first sequence number are node 3 and node 4. Data from node 3 and node 4 are sent to the terminal in ascending order of sequence number; where the sequence number of node 3 is 3 and the sequence number of node 4 is 4.

[0073] It should be noted that, Figure 3 The sequence numbers of nodes 1 to 4 are only illustrative and can be other monotonically increasing sequence numbers. This application does not impose any specific restrictions on them.

[0074] It should be noted that the sequence number is crucial for incremental synchronization. If a new node to be synchronized exists on the server, an incrementing sequence number needs to be assigned to the new node. If the data or indication information of an existing node to be synchronized is modified, the sequence number of the modified node needs to be updated and reconfigured with an incrementing sequence number. Based on this, during each incremental data synchronization, the server only needs to send the data of the node to be synchronized with a sequence number greater than the first sequence number to the terminal, thus improving the data synchronization efficiency.

[0075] Figure 4 This is a schematic diagram of another incremental synchronization provided in an embodiment of this application.

[0076] like Figure 4 As shown, the nodes to be synchronized include node 1 and node 2, which are received by the terminal; wherein, the sequence number of node 1 is 1 and the indication information indicates that it is reserved, and the sequence number of node 2 is 2 and the indication information indicates that it is reserved.

[0077] The nodes to be synchronized on the server are 1, 3, 4, and 2. Among them, the sequence number of node 1 is 1 and the indication information indicates that it should be retained; the sequence number of node 3 is 3 and the indication information indicates that it should be retained; the sequence number of node 4 is 4 and the indication information indicates that it should be retained; and the sequence number of node 2 is 5 and the indication information indicates that it should not be retained. It should be noted that since the indication information of node 2 has been modified, its incrementing sequence number 5 has been reconfigured.

[0078] For example, the terminal sends a data synchronization request to the server, including a first sequence number (such as...). Figure 4 As shown, the first sequence number equals 2). After receiving the data synchronization request, the server determines the data synchronization method. If the synchronization method is incremental synchronization, then data from nodes with sequence numbers greater than the first sequence number are sent to the terminal in ascending order of sequence number (e.g., ...). Figure 4 As shown, the nodes to be synchronized with sequence numbers greater than the first sequence number are node 3, node 4, and node 2. Data from node 3, node 4, and node 2 are sent to the terminal in ascending order of sequence number; where the sequence number of node 3 is 3, the sequence number of node 4 is 4, and the sequence number of node 2 is 5.

[0079] Accordingly, after receiving data from node 3, node 4, and node 2, the terminal will merge the data from node 3, node 4, and node 2 with its local data based on the indication information from node 3, node 4, and node 2, respectively (e.g., ...). Figure 4 As shown, if the indication information for node 2 indicates that it is not retained, then when the terminal merges the data, it will delete all data of node 2 in the local data.

[0080] It should be noted that, Figure 4 The sequence number of node 2 is merely illustrative; any sequence number greater than 4 can be configured for node 2, and this application does not impose any specific restrictions on this.

[0081] In some embodiments of this application, method 200 may further include:

[0082] When the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there is a node to be synchronized with a sequence number greater than the second sequence number, the data of the node to be synchronized with a sequence number greater than the second sequence number is sent to the terminal device in ascending order of sequence number.

[0083] In this embodiment, considering that among the nodes to be synchronized on the server with serial numbers greater than the second serial number, there may be nodes that have already sent data to the terminal and whose indication information or data has been modified, the indication information is disregarded, and the data of all nodes to be synchronized with serial numbers greater than the second serial number is sent to the terminal device in ascending order of serial numbers, which can ensure the integrity and correctness of data synchronization.

[0084] In some embodiments of this application, method 200 may further include:

[0085] When the synchronization method is incremental synchronization and the first sequence number is greater than or equal to the second sequence number, data of nodes to be synchronized with a sequence number greater than the first sequence number are sent to the terminal device in ascending order of sequence number.

[0086] In this embodiment, since the first sequence number is greater than or equal to the second sequence number, it means that all the data of the nodes to be synchronized on the server side with sequence numbers less than the second sequence number has been sent to the terminal. At this time, any modification to the data of the nodes to be synchronized on the server side with sequence numbers greater than the second sequence number must be sent to the terminal. In addition, considering that the synchronization method is incremental synchronization and the first sequence number is greater than or equal to the second sequence number, sending the data of the nodes to be synchronized with sequence numbers greater than the first sequence number to the terminal device can ensure the integrity and correctness of data synchronization.

[0087] In some embodiments of this application, method 200 may further include:

[0088] When the synchronization mode is full synchronization, obtain the maximum sequence number of the nodes to be synchronized at the start of this full synchronization.

[0089] Send an instruction to the terminal device, which instructs the terminal device to clear the data of the nodes to be synchronized received locally. The instruction includes the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization.

[0090] In ascending order of sequence number, an indication message is sent to the terminal device to indicate the data of the nodes to be synchronized.

[0091] In this embodiment, when the synchronization mode is full synchronization, since the terminal does not need to merge the data of the node to be synchronized with the local data after receiving the data, an instruction is sent to the terminal before sending the full data, instructing the terminal to clear the data of the node to be synchronized received locally. In addition, since the data synchronization scheme of this application synchronizes data in ascending order of sequence number, the maximum sequence number (second sequence number) of the node to be synchronized at the start of this full synchronization is sent to the terminal for recording. This lays the groundwork for determining as little incremental data as possible based on the second sequence number saved by the terminal during subsequent incremental synchronization, while ensuring data integrity.

[0092] Of course, in other alternative embodiments, the server may also save the maximum sequence number of the nodes to be synchronized at the start of each full synchronization, and when the synchronization method is determined, retrieve the saved second sequence number from the database.

[0093] In some embodiments of this application, S202 may include:

[0094] The determination instruction information indicates a first number of nodes to be synchronized and a second number of nodes whose sequence number is greater than the first sequence number;

[0095] If the first quantity is greater than or equal to the second quantity, then the synchronization method is incremental synchronization;

[0096] If the first quantity is less than the second quantity, then the synchronization method is full synchronization.

[0097] In other words, among all the nodes to be synchronized on the server, determine the number of nodes to be synchronized that the indication information indicates is retained (the number of nodes to be fully synchronized) and the number of nodes to be synchronized with a sequence number greater than the first sequence number (the number of nodes to be synchronized incrementally). If the indication information indicates that the number of nodes to be synchronized that the indication information indicates is greater than or equal to the number of nodes to be synchronized with a sequence number greater than the first sequence number, then the synchronization method is incremental synchronization; otherwise, the synchronization method is full synchronization.

[0098] For example, if only one of the nodes to be synchronized on the server indicates that the information should be retained, while the information of the other nodes (at least two nodes to be synchronized) indicates that the information should not be retained, then full synchronization is the optimal synchronization method.

[0099] In this embodiment, by comparing the number of nodes that need to be synchronized during full synchronization with the number of nodes that need to be synchronized during incremental synchronization, the synchronization method with the smallest data volume is selected. This avoids the problems that occur in scenarios where data changes frequently and there may be a large number of data deletion operations. If incremental synchronization is used directly, a large number of indication information indicating nodes to be synchronized that should not be retained will be synchronized, which will lead to performance degradation and waste of synchronization resources. Alternatively, when data changes are infrequent, synchronizing all data each time will cause synchronization timeouts and low synchronization efficiency.

[0100] In some embodiments of this application, S200 may further include:

[0101] Send the data of the nodes to be synchronized on the server to the terminal device in pages;

[0102] Wherein, when the synchronization method is incremental synchronization and the number of first nodes to be synchronized corresponding to the data sent to the terminal device by the current page is equal to a preset threshold, the maximum sequence number of the first node to be synchronized is determined as the new first sequence number;

[0103] When the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to the data sent to the terminal device on the current page is equal to the preset threshold, the maximum sequence number of the second node to be synchronized is determined as the new first sequence number.

[0104] If the new first sequence number is less than the maximum sequence number of the current node to be synchronized on the server, the synchronization method for the next page of data is determined again based on the new first sequence number.

[0105] For example, the preset threshold can be 1000 or 2000, and this application does not impose a specific limitation on it.

[0106] In this embodiment, the data of the node to be synchronized is synchronized in pages. Before the synchronization of each page begins, the data synchronization method is re-determined based on the new first sequence number. On the one hand, by using the new first sequence number to determine the data synchronization method, it can be ensured that each page synchronizes the minimum amount of valid data. On the other hand, since the data is always synchronized in ascending order of the sequence number, the correctness of the data synchronization can be guaranteed.

[0107] Furthermore, since the data of the nodes to be synchronized is always sent to the terminal in ascending order of sequence number during data synchronization, the characteristic of ascending sequence number can be used to easily perform paginated data update operations based on sequence number, which improves the efficiency of data acquisition and avoids timeout issues.

[0108] Figure 5 This is another illustrative flowchart of the data synchronization method 300 provided in this application embodiment. The method 300 can be executed by a server, for example... Figure 1The server shown is 120.

[0109] S301, Server requests data synchronization.

[0110] S302, Does the server determine if the first sequence number in the data synchronization request is equal to 0?

[0111] S303, if the first serial number is not equal to 0, the server determines whether the first quantity is less than the second quantity.

[0112] It should be noted that the first quantity is the number of nodes to be synchronized that are reserved as indicated by the indication information, that is, the number of nodes to be synchronized corresponding to the full data; the second quantity is the number of nodes to be synchronized with a sequence number greater than the first sequence number, that is, the number of nodes to be synchronized corresponding to the incremental data.

[0113] S304, if the first quantity is greater than or equal to the second quantity, determine whether the first sequence number is less than the second sequence number.

[0114] It should be noted that if the first quantity is greater than or equal to the second quantity, then incremental synchronization is the optimal synchronization method.

[0115] S305, if the first sequence number is less than the second sequence number, the initial value of i is set to 0, and the initial value of j is set to the smallest sequence number among all sequence numbers corresponding to all nodes to be synchronized on the server that is greater than the first sequence number. Determine whether i is less than the preset threshold, whether j is greater than the second sequence number, and whether the indication information of the node to be synchronized with sequence number j is indicated to be retained.

[0116] S306, if all conditions in S305 are met, then the data of the node to be synchronized with sequence number j is sent out, and the smallest sequence number greater than j among all sequence numbers corresponding to all nodes to be synchronized on the server is redefined as the new j, and i is defined as the sum of i and 1.

[0117] In short, the execution process of S305 to S306 is as follows: if the first sequence number is less than the second sequence number, the server sends the target node data to the terminal in ascending order of the sequence number and records the number of target nodes, and the number of target nodes does not exceed the preset threshold.

[0118] It should be noted that the preset threshold is the maximum amount of data that can be synchronized per page during pagination synchronization. The target node is a node on the server whose sequence number is greater than the first sequence number and less than or equal to the second sequence number, and whose indication information indicates that it should be reserved for synchronization.

[0119] S307, Determine whether i is less than a preset threshold and whether the server has a node to be synchronized with a sequence number j greater than the second sequence number.

[0120] S308, if all conditions in S307 are met, then the data of the node to be synchronized with sequence number j is sent out, and the smallest sequence number greater than j among all sequence numbers corresponding to all nodes to be synchronized on the server is redefined as the new j, and i is defined as the sum of i and 1.

[0121] In short, the execution process of S307 to S308 is as follows: if the first sequence number is less than the second sequence number, and the number of nodes to be synchronized that have been sent is less than a preset threshold, and there are nodes to be synchronized on the server with a sequence number greater than the second sequence number, then data of nodes to be synchronized with a sequence number greater than the second sequence number are sent to the terminal device in ascending order of sequence number.

[0122] S309, if there are no nodes to be synchronized on the server, or if the number of i is equal to the preset threshold, then the maximum sequence number of the nodes to be synchronized that have been sent is determined as the new first sequence number.

[0123] S310, if the first sequence number is greater than or equal to the second sequence number, the initial value of i is set to 0, and the initial value of j is set to the smallest sequence number among all sequence numbers corresponding to all nodes to be synchronized on the server that is greater than the first sequence number, and it is determined whether i is less than the preset threshold and whether j exists.

[0124] S311, if all conditions in S310 above are met, then the data of the node to be synchronized with sequence number j is sent out, and the smallest sequence number greater than j among all sequence numbers corresponding to all nodes to be synchronized on the server is re-determined as the new j, and i is determined as the sum of i and 1.

[0125] In short, the execution process of S310 to S311 is as follows: when the synchronization mode is incremental synchronization, the first sequence number is greater than or equal to the second sequence number, and the number of nodes to be synchronized that have been sent is less than a preset threshold, data of nodes to be synchronized with a sequence number greater than the first sequence number are sent to the terminal device in ascending order of sequence number.

[0126] S312, if the first sequence number is equal to 0 or the first quantity is less than the second quantity, then obtain the maximum sequence number of the node to be synchronized at the start of this full synchronization, and send an instruction to the terminal device to instruct the terminal device to clear the data of the node to be synchronized received locally.

[0127] S313, set the initial value of i to 0, and the initial value of j to the minimum sequence number among all sequence numbers corresponding to all nodes to be synchronized on the server. Determine whether i is less than the preset threshold and whether there is a node to be synchronized on the server with sequence number j.

[0128] S314, if all conditions in S313 above are met, then the data of the node to be synchronized with sequence number j is sent out, and the smallest sequence number greater than j among all sequence numbers corresponding to all nodes to be synchronized on the server is re-determined as the new j, and i is determined as the sum of i and 1.

[0129] S315, Determine whether the new first sequence number is less than the maximum sequence number of the node currently to be synchronized on the server.

[0130] It should be noted that if the first sequence number is less than the maximum sequence number of the node to be synchronized on the server, the synchronization method for the next page of data will be determined based on the new first sequence number.

[0131] S316. If the first sequence number is equal to the maximum sequence number of the node to be synchronized on the server, then data synchronization ends.

[0132] In this embodiment, the number of nodes to be synchronized corresponding to incremental data and the number of nodes to be synchronized corresponding to full data are determined by the first sequence number. Then, by comparing the two numbers, the optimal data synchronization method is determined. That is, by using the first sequence number, the server can select the optimal synchronization method according to the actual situation of data synchronization, so as to improve synchronization efficiency.

[0133] Furthermore, by introducing a second sequence number and synchronizing data in ascending order of sequence number during incremental synchronization, it is equivalent to considering that nodes to be synchronized on the server side that are greater than the first sequence number and less than or equal to the second sequence number are definitely nodes that have not been synchronized to the terminal. Therefore, during incremental synchronization, there is no need to consider the impact of node data that the indication information indicates is not to be retained on the terminal's local data. That is, only the nodes to be synchronized that the indication information indicates is retained within the range need to be synchronized, and the nodes to be synchronized that the indication information indicates is not to be retained need to be synchronized are not synchronized. This can reduce the amount of data during incremental synchronization, improve synchronization efficiency, and save synchronization time and traffic.

[0134] Furthermore, during data synchronization, the data of the nodes to be synchronized is synchronized in pages. Before each page synchronization begins, the data synchronization method is redefined based on a new first sequence number. On the one hand, using the new first sequence number to determine the data synchronization method ensures that each page synchronizes the minimum amount of valid data; on the other hand, since data synchronization always follows an ascending sequence number order, the correctness of data synchronization is guaranteed. In other words, by utilizing the ascending sequence number characteristic, page-based data updates can be performed simply based on the sequence number, improving the efficiency of data retrieval and thus avoiding timeout issues.

[0135] Figure 6 This is another illustrative flowchart of the data synchronization method 400 provided in this application embodiment. The method 400 can be executed by a terminal device, for example... Figure 1The terminal device 110 shown.

[0136] S401, Send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0137] S402, Receive data from the server for the target node, wherein the target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is a node to be synchronized and is reserved;

[0138] The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number;

[0139] S403, merge and store the data of the target node with the first data of the node to be synchronized that has been received locally.

[0140] In other words, the terminal device sends a data synchronization request to the server, which includes a first sequence number and a second sequence number. It receives data from the target node whose sequence number increments as sent by the server, and merges and stores the received data from the target node with the first data of the node to be synchronized that it has already received locally.

[0141] In this embodiment, based on the fact that the data received by the terminal meets the data integrity requirements, the amount of data to be synchronized by the terminal is reduced, thereby improving the efficiency of the terminal merging data.

[0142] In some embodiments of this application, method 400 may further include:

[0143] Receive data from the server for nodes whose sequence number is greater than the second sequence number;

[0144] Specifically, data from nodes whose sequence number is greater than the second sequence number is sent in ascending order of sequence number when the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there are nodes on the server whose sequence number is greater than the second sequence number.

[0145] The data of the node to be synchronized with the sequence number greater than the second sequence number is merged and stored with the second data of the node to be synchronized that has been received locally.

[0146] In this embodiment, receiving data from nodes to be synchronized whose sequence numbers are incremented and greater than the second sequence number ensures the integrity and correctness of the received data.

[0147] In some embodiments of this application, method 400 may further include:

[0148] The terminal device receives an instruction from the server, which instructs the terminal device to clear the data of the nodes to be synchronized locally. The instruction includes the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization.

[0149] In response to this instruction, the data of the nodes to be synchronized received locally is cleared, and the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization is determined as the new second sequence number;

[0150] The server sends an indication message indicating the data of the nodes to be retained and synchronized.

[0151] The indication information indicates that the data of the nodes to be synchronized is sent when the synchronization mode is full synchronization;

[0152] This instruction information is used to instruct the data of the nodes to be synchronized to be stored.

[0153] In this embodiment, the maximum sequence number of the node to be synchronized on the server at the start of this full synchronization is received and stored as a new second sequence number. This is equivalent to using the new second sequence number to determine as little incremental data as possible for subsequent incremental synchronization while ensuring data integrity.

[0154] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, they should also be considered as the content disclosed in this application.

[0155] It should also be understood that, in the various method embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0156] The methods provided in the embodiments of this application have been described above. The apparatus provided in the embodiments of this application will be described below.

[0157] Figure 7 This is a schematic block diagram of the data synchronization device 500 provided in the embodiments of this application.

[0158] It should be noted that this device is a server.

[0159] The device 500 includes:

[0160] The receiving unit 510 is used to receive a data synchronization request sent by the terminal device. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0161] The determining unit 520 is used to determine the data synchronization method based on the first sequence number;

[0162] The sending unit 530 is used to send data of a target node to the terminal device in ascending order of sequence number when the synchronization mode is incremental synchronization and the first sequence number is less than the second sequence number. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is a node to be synchronized.

[0163] In some embodiments of this application, the sending unit 530 may also be used for:

[0164] When the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there is a node to be synchronized with a sequence number greater than the second sequence number, the data of the node to be synchronized with a sequence number greater than the second sequence number is sent to the terminal device in ascending order of sequence number.

[0165] In some embodiments of this application, the sending unit 530 may also be used for:

[0166] When the synchronization method is incremental synchronization and the first sequence number is greater than or equal to the second sequence number, data of nodes to be synchronized with a sequence number greater than the first sequence number are sent to the terminal device in ascending order of sequence number.

[0167] In some embodiments of this application, the sending unit 530 may also be used for:

[0168] When the synchronization mode is full synchronization, obtain the maximum sequence number of the nodes to be synchronized at the start of this full synchronization.

[0169] Send an instruction to the terminal device, which instructs the terminal device to clear the data of the nodes to be synchronized received locally. The instruction includes the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization.

[0170] In ascending order of sequence number, an indication message is sent to the terminal device to indicate the data of the nodes to be synchronized.

[0171] In some embodiments of this application, the determining unit 520 is used for:

[0172] The determination instruction information indicates a first number of nodes to be synchronized and a second number of nodes whose sequence number is greater than the first sequence number;

[0173] If the first quantity is greater than or equal to the second quantity, then the synchronization method is incremental synchronization;

[0174] If the first quantity is less than the second quantity, then the synchronization method is full synchronization.

[0175] In some embodiments of this application, the sending unit 530 may also be used for:

[0176] Send the data of the nodes to be synchronized on the server to the terminal device in pages;

[0177] Wherein, when the synchronization method is incremental synchronization and the number of first nodes to be synchronized corresponding to the data sent to the terminal device by the current page is equal to a preset threshold, the maximum sequence number of the first node to be synchronized is determined as the new first sequence number;

[0178] When the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to the data sent to the terminal device on the current page is equal to the preset threshold, the maximum sequence number of the second node to be synchronized is determined as the new first sequence number.

[0179] If the new first sequence number is less than the maximum sequence number of the current node to be synchronized on the server, the synchronization method for the next page of data is determined again based on the new first sequence number.

[0180] In some embodiments of this application, the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized;

[0181] If the information of the node to be synchronized is updated, the timestamp at which the information is updated will be determined as the first timestamp of the node to be synchronized; if the node to be synchronized is a newly added node, the timestamp at which the node to be synchronized is first stored will be determined as the first timestamp of the node to be synchronized.

[0182] Figure 8 This is another schematic block diagram of the data synchronization device 600 provided in the embodiments of this application.

[0183] It should be noted that this device is a terminal device.

[0184] The device 600 includes:

[0185] The sending unit 610 is used to send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started.

[0186] The receiving unit 620 is used to receive data from the target node sent by the server. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is a node to be synchronized and is reserved.

[0187] The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number;

[0188] The merging unit 630 is used to merge and store the data of the target node and the first data of the node to be synchronized that has been received locally.

[0189] In some embodiments of this application, the receiving unit 620 may also be used for:

[0190] Receive data from the server for nodes whose sequence number is greater than the second sequence number;

[0191] Specifically, data from nodes whose sequence number is greater than the second sequence number is sent in ascending order of sequence number when the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there are nodes on the server whose sequence number is greater than the second sequence number.

[0192] The data of the node to be synchronized with the sequence number greater than the second sequence number is merged and stored with the second data of the node to be synchronized that has been received locally.

[0193] In some embodiments of this application, the receiving unit 620 may also be used for:

[0194] The terminal device receives an instruction from the server, which instructs the terminal device to clear the data of the nodes to be synchronized locally. The instruction includes the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization.

[0195] In response to this instruction, the data of the nodes to be synchronized received locally is cleared, and the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization is determined as the new second sequence number;

[0196] The server sends an indication message indicating the data of the nodes to be retained and synchronized.

[0197] The indication information indicates that the data of the nodes to be synchronized is sent when the synchronization mode is full synchronization;

[0198] This instruction information is used to instruct the data of the nodes to be synchronized to be stored.

[0199] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, they will not be repeated here. Specifically, the data synchronization device 500 can correspond to the corresponding subject in executing method 200 or method 300 of the embodiments of this application, and the data synchronization device 600 can correspond to the corresponding subject in executing method 400 of the embodiments of this application. Each unit in the data synchronization device 500 implements the corresponding process in method 200 or method 300, and each unit in the device 600 implements the corresponding process in method 400. For simplicity, they will not be repeated here.

[0200] It should also be understood that the various units in the data synchronization device 500 or 600 involved in the embodiments of this application can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This can achieve the same operation without affecting the technical effect of the embodiments of this application. The above-mentioned units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the data synchronization device 500 or 600 may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by multiple units working together. According to another embodiment of this application, the data synchronization device 500 or 600 involved in the embodiments of this application, and the data synchronization method of the embodiments of this application, can be constructed by running a computer program (including program code) capable of performing the steps involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), random access storage medium (RAM), and read-only storage medium (ROM). Computer programs can be recorded on, for example, a computer-readable storage medium, loaded into an electronic device via the computer-readable storage medium, and run therein to implement the corresponding methods provided in the embodiments of this application.

[0201] In other words, the units mentioned above can be implemented in hardware, in software instructions, or in a combination of hardware and software. Specifically, the steps of the method embodiments in this application can be completed by the integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software in the decoding processor. Optionally, the software can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads the information in the memory and completes the steps in the above method embodiments in conjunction with its hardware.

[0202] Figure 9 This is a schematic structural diagram of the electronic device 700 provided in the embodiments of this application.

[0203] like Figure 9 As shown, the electronic device 700 includes at least a processor 710 and a computer-readable storage medium 720. The processor 710 and the computer-readable storage medium 720 can be connected via a bus or other means. The computer-readable storage medium 720 stores a computer program 721, which includes computer instructions. The processor 710 executes the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing and control core of the electronic device 700, and is suitable for implementing one or more computer instructions, specifically for loading and executing one or more computer instructions to achieve a corresponding method flow or function.

[0204] As an example, processor 710 may also be referred to as a central processing unit (CPU). Processor 710 may include, but is not limited to: general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0205] As an example, the computer-readable storage medium 720 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage device; optionally, it may also be at least one computer-readable storage medium located remotely from the aforementioned processor 710. Specifically, the computer-readable storage medium 720 includes, but is not limited to, volatile memory and / or non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0206] In one implementation, the electronic device 700 may be Figure 7 or Figure 8 The data synchronization device 500 or 600 shown; the computer-readable storage medium 720 stores computer instructions; the processor 710 loads and executes the computer instructions stored in the computer-readable storage medium 720 to implement the corresponding steps in the method embodiment; in specific implementation, the computer instructions in the computer-readable storage medium 720 are loaded and executed by the processor 710 to implement the corresponding steps, which will not be described again here to avoid repetition.

[0207] According to another aspect of this application, embodiments of this application also provide a computer-readable storage medium (Memory), which is a memory device in electronic device 700 for storing programs and data. For example, a computer-readable storage medium 720. It is understood that the computer-readable storage medium 720 here may include both the built-in storage medium in electronic device 700 and extended storage media supported by electronic device 700. The computer-readable storage medium provides storage space that stores the operating system of electronic device 700. Furthermore, the storage space also stores one or more computer instructions suitable for loading and execution by processor 710, which may be one or more computer programs 721 (including program code).

[0208] The electronic device 700 may further include a transceiver 730, which can be connected to the processor 710 or the computer-readable storage medium 720.

[0209] The computer-readable storage medium 720 can control the transceiver 730 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 730 may include a transmitter and a receiver. The transceiver 730 may further include antennas, and the number of antennas may be one or more.

[0210] According to another aspect of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. For example, computer program 721. In this case, electronic device 700 may be a computer, and processor 710 reads the computer instructions from computer-readable storage medium 720, executes the computer instructions, causing the computer to perform the data synchronization methods provided in the various alternative embodiments described above.

[0211] In other words, when implemented using software, it can be implemented entirely or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes of the embodiments of this application are run or the functions of the embodiments of this application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.

[0212] Those skilled in the art will recognize that the units and process steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0213] Finally, it should be noted that the above embodiments are only specific implementations of this application, but the protection scope of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application.

Claims

1. A data synchronization method, characterized in that, The method is applied to a server and includes: The terminal device receives a data synchronization request, which includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started. Based on the first sequence number, determine the data synchronization method; When the synchronization method is incremental synchronization and the first sequence number is less than the second sequence number, the data of the target node is sent to the terminal device in ascending order of the sequence number. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is to be reserved for synchronization. The step of determining the data synchronization method based on the first sequence number includes: determining a first number of nodes to be synchronized that are reserved and a second number of nodes to be synchronized whose sequence number is greater than the first sequence number; if the first number is greater than or equal to the second number, the synchronization method is incremental synchronization; if the first number is less than the second number, the synchronization method is full synchronization. The method further includes: sending data of nodes to be synchronized on the server to the terminal device in pages; wherein, when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to the data already sent to the terminal device on the current page is equal to a preset threshold, the maximum sequence number of the first nodes to be synchronized is determined as a new first sequence number; when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to the data already sent to the terminal device on the current page is equal to the preset threshold, the maximum sequence number of the second nodes to be synchronized is determined as a new first sequence number; when the new first sequence number is less than the maximum sequence number of the nodes to be synchronized on the server, the synchronization mode of the data on the next page is re-determined based on the new first sequence number.

2. The method according to claim 1, characterized in that, The method further includes: When the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there is a node to be synchronized with a sequence number greater than the second sequence number, the data of the node to be synchronized with a sequence number greater than the second sequence number is sent to the terminal device in ascending order of sequence number.

3. The method according to claim 1, characterized in that, The method further includes: When the synchronization method is incremental synchronization and the first sequence number is greater than or equal to the second sequence number, data of nodes to be synchronized with a sequence number greater than the first sequence number are sent to the terminal device in ascending order of sequence number.

4. The method according to claim 1, characterized in that, The method further includes: When the synchronization mode is full synchronization, obtain the maximum sequence number of the node to be synchronized at the start of this full synchronization; Send an instruction to the terminal device, the instruction being used to instruct the terminal device to clear the data of the nodes to be synchronized received locally, the instruction including the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization; The system sends an indication message to the terminal device in ascending order of sequence number to indicate the data of the nodes to be synchronized.

5. The method according to any one of claims 1 to 4, characterized in that, The sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized; If the information of the node to be synchronized is updated, the timestamp when the information is updated is determined as the first timestamp of the node to be synchronized; if the node to be synchronized is a newly added node, the timestamp when the node to be synchronized is first stored is determined as the first timestamp of the node to be synchronized.

6. A data synchronization method, characterized in that, The method is applied to a terminal device and includes: Send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started. Receive data from the target node sent by the server, wherein the target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is to be reserved for synchronization; The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number; The data of the target node and the first data of the node to be synchronized that has been received locally are merged and stored. The data synchronization method is determined by the server based on the following: determining the first number of nodes to be synchronized and the second number of nodes with sequence numbers greater than the first sequence number; if the first number is greater than or equal to the second number, the synchronization method is incremental synchronization; if the first number is less than the second number, the synchronization method is full synchronization. The method further includes: receiving data of nodes to be synchronized sent by the server in pages; wherein, when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to the data already received by the terminal device on the current page is equal to a preset threshold, the server determines the maximum sequence number of the first nodes to be synchronized as a new first sequence number; when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to the data already received by the terminal device on the current page is equal to the preset threshold, the server determines the maximum sequence number of the second nodes to be synchronized as a new first sequence number; when the new first sequence number is less than the maximum sequence number of the nodes to be synchronized by the server, the server re-determines the synchronization mode of the data on the next page based on the new first sequence number.

7. The method according to claim 6, characterized in that, The method further includes: Receive data from the server for nodes whose sequence number is greater than the second sequence number; Specifically, the data of the node to be synchronized with a sequence number greater than the second sequence number is sent in ascending order of sequence number when the synchronization method is incremental synchronization, the first sequence number is less than the second sequence number, and there is a node to be synchronized with a sequence number greater than the second sequence number on the server. The data of the node to be synchronized with the sequence number greater than the second sequence number is merged and stored with the second data of the node to be synchronized that has been received locally.

8. The method according to claim 6, characterized in that, The method further includes: The terminal device receives an instruction sent by the server, which instructs the terminal device to clear the data of the nodes to be synchronized received locally. The instruction includes the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization. In response to the instruction, the data of the nodes to be synchronized received locally is cleared, and the maximum sequence number of the nodes to be synchronized on the server at the start of this full synchronization is determined as the new second sequence number; Receive the indication information sent by the server indicating the data of the nodes to be retained for synchronization; The indication information indicates that the data of the nodes to be synchronized is reserved and sent when the synchronization mode is full synchronization; The instruction information indicates that the data of the nodes to be synchronized should be stored.

9. A data synchronization device, characterized in that, The device is a server, comprising: A receiving unit is used to receive a data synchronization request sent by a terminal device. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started. The determining unit is used to determine the data synchronization method based on the first sequence number; The sending unit is configured to send data of a target node to the terminal device in ascending order of the sequence number when the synchronization mode is incremental synchronization and the first sequence number is less than the second sequence number. The target node is a node to be synchronized on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is reserved. Specifically, the determining unit is used to: determine a first number of nodes to be synchronized that are indicated by the indication information and a second number of nodes to be synchronized whose sequence number is greater than the first sequence number; if the first number is greater than or equal to the second number, the synchronization method is incremental synchronization; if the first number is less than the second number, the synchronization method is full synchronization. The sending unit is further configured to: send data of nodes to be synchronized on the server to the terminal device in pages; wherein, when the synchronization method is incremental synchronization and the number of first nodes to be synchronized corresponding to the data already sent to the terminal device on the current page is equal to a preset threshold, the maximum sequence number of the first nodes to be synchronized is determined as a new first sequence number; when the synchronization method is full synchronization and the number of second nodes to be synchronized corresponding to the data already sent to the terminal device on the current page is equal to the preset threshold, the maximum sequence number of the second nodes to be synchronized is determined as a new first sequence number; when the new first sequence number is less than the maximum sequence number of the nodes to be synchronized on the server, the synchronization method of the next page of data is re-determined based on the new first sequence number.

10. A data synchronization device, characterized in that, The device is a terminal equipment, including: The sending unit is used to send a data synchronization request to the server. The data synchronization request includes a first sequence number and a second sequence number. The first sequence number is the maximum sequence number of the node to be synchronized received by the terminal device, and the second sequence number is the maximum sequence number of the node to be synchronized on the server when the last full synchronization started. The receiving unit is used to receive data from the target node sent by the server. The target node is a node on the server whose sequence number is greater than the first sequence number, less than or equal to the second sequence number, and whose indication information indicates that it is to be reserved for synchronization. The data of the target node is sent in ascending order of sequence number when the data synchronization method is incremental synchronization and the first sequence number is less than the second sequence number; The merging unit is used to merge and store the data of the target node and the first data of the node to be synchronized that has been received locally. The data synchronization method is determined by the server based on the following: determining the first number of nodes to be synchronized and the second number of nodes with sequence numbers greater than the first sequence number; if the first number is greater than or equal to the second number, the synchronization method is incremental synchronization; if the first number is less than the second number, the synchronization method is full synchronization. The device is further configured to: receive data of nodes to be synchronized sent by the server in pages; wherein, when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to the data already received by the terminal device on the current page is equal to a preset threshold, the server determines the maximum sequence number of the first nodes to be synchronized as a new first sequence number; when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to the data already received by the terminal device on the current page is equal to the preset threshold, the server determines the maximum sequence number of the second nodes to be synchronized as a new first sequence number; when the new first sequence number is less than the maximum sequence number of the nodes to be synchronized by the server, the server re-determines the synchronization mode of the data on the next page based on the new first sequence number.

11. An electronic device, characterized in that, include: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 5 or the method as described in any one of claims 6 to 8.

12. A computer-readable storage medium, characterized in that, Used to store computer programs that cause a computer to perform the method as claimed in any one of claims 1 to 5 or the method as claimed in any one of claims 6 to 8.

13. A computer program product comprising a computer program and / or instructions, characterized in that, When the computer program and / or instructions are executed by a processor, they implement the method as described in any one of claims 1 to 5 or the method as described in any one of claims 6 to 8.