Data synchronization method, data synchronization device, electronic equipment and storage medium
By creating asynchronous synchronization tasks on the smart terminal, the data to be synchronized is directly synchronized to the target device, solving the problem of difficult to take into account both timeliness and efficiency of data synchronization, and achieving efficient data transmission and storage management.
Patent Information
- Application Number
- CN202310785749.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2024-12-31
AI Technical Summary
Existing data synchronization technology is difficult to take into account timeliness and efficiency, especially when smart terminals generate large amounts of data, the synchronization process is easy to occupy storage space and is inefficient.
Create synchronization tasks when the data to be synchronized is written, and perform synchronization tasks asynchronously, directly synchronizing the data to the target electronic device, avoiding notifications waiting for synchronization completion, thereby improving synchronization efficiency and timeliness.
Synchronizing data by asynchronously, the timeliness and efficiency of data synchronization is achieved, reducing storage space usage, and improving the speed of data transmission.
Smart Images

Figure CN119226299A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data synchronization, and more specifically, to a data synchronization method, a data synchronization device, an electronic device, and a non-volatile computer-readable storage medium. Background Art
[0002] With the rapid development of the Internet and the popularization of terminals, smart terminals have become an indispensable tool in our daily lives. For example, users can use smart terminals to take pictures or videos, or play games, chat, and other operations; these actions will generate a large amount of data. In order not to occupy the storage space of the terminal, data synchronization can be performed. However, it is difficult to balance the timeliness and efficiency of data synchronization. Summary of the invention
[0003] Embodiments of the present application provide a data synchronization method, a data synchronization device, an electronic device, and a non-volatile computer-readable storage medium.
[0004] The data synchronization method of the embodiment of the present application includes creating a synchronization task when the data to be synchronized is written; and executing the synchronization task to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
[0005] The data synchronization device of the implementation mode of the present application includes a creation module and an execution module. The creation module is used to create a synchronization task when the data to be synchronized is written; and the execution module is used to execute the synchronization task to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
[0006] The electronic device of the embodiment of the present application includes a processor, a memory; and a computer program, wherein the computer program is stored in the memory and executed by the processor, and the computer program includes instructions for executing the data synchronization method. The data synchronization method includes creating a synchronization task when the data to be synchronized is written; and executing the synchronization task to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
[0007] The computer-readable storage medium of the embodiment of the present application includes a computer program, and when the computer program is executed by a processor, the processor executes the data synchronization method. The data synchronization method includes creating a synchronization task when the data to be synchronized is written; and executing the synchronization task to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
[0008] The data synchronization method, data synchronization device, electronic device and computer-readable storage medium of the implementation mode of the present application ensure the timeliness of synchronization by creating a synchronization task in the electronic device and executing the created synchronization task when the data to be synchronized is written into the memory of the electronic device; and compared with synchronizing the data to be synchronized in a synchronous manner, which requires waiting for the target electronic device to send back a notification of completion of the synchronization of the data to be synchronized before synchronizing the next data to be synchronized, synchronizing one or more data to be synchronized in the synchronization task to the target electronic device in an asynchronous manner can improve the synchronization efficiency of the data to be synchronized, and further improve the timeliness of synchronizing the data to be synchronized to the target electronic device, taking into account both the timeliness and efficiency of data synchronization.
[0009] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0011] Figure 1 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0012] Figure 2 is a schematic plan view of an electronic device according to some embodiments of the present application;
[0013] Figure 3 It is a scenario diagram of a data synchronization method in certain implementation modes of the present application;
[0014] Figure 4 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0015] Figure 5 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0016] Figure 6 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0017] Figure 7 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0018] Figure 8 is a flowchart of a data synchronization method in certain implementation modes of the present application;
[0019] Fig. 9 is a module schematic diagram of a data synchronization device in certain embodiments of the present application;
[0020] Fig.10 It is a schematic diagram of the connection status of a non-volatile computer-readable storage medium and a processor in certain embodiments of the present application. DETAILED DESCRIPTION
[0021] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.
[0022] See also Figure 1 and Figure 2 , the embodiment of the present application provides a data synchronization method, the data synchronization method comprising:
[0023] Step 011: When the data to be synchronized is written, create a synchronization task;
[0024] Specifically, the data to be synchronized may be data generated during the operation of the electronic device 100, for example, picture data or video data generated during shooting by the electronic device 100, game data and chat information data generated during gaming or chatting by the electronic device 100, etc. A large amount of data may be generated during the operation of the electronic device 100, which may occupy a large amount of storage space of the electronic device 100, or the data generated by the electronic device 100 may need to be backed up to prevent data loss, etc., and the data generated by the electronic device 100 may need to be synchronized, wherein the electronic device 100 includes a processor 30 and a memory 40, and the electronic device 100 may be a smart phone, a server, a computer, a tablet computer, a smart watch, a smart wearable device, etc.
[0025] When the data to be synchronized generated by the electronic device 100 is written into the memory 40 of the electronic device 100, the processor 30 of the electronic device 100 can create a synchronization task based on the written data to be synchronized. For example, when the game data generated by the smartphone is written into the memory 40 of the smartphone, the processor 30 in the smartphone can create a synchronization task for synchronizing the game data; or, when the application data generated by the application in the server is written into the memory 40, the processor 30 in the server can create a synchronization task for synchronizing the application data.
[0026] Step 012: Execute a synchronization task to synchronize the data to be synchronized to the target electronic device 200 in an asynchronous manner.
[0027] The target electronic device 200 is a device that stores data to be synchronized. For example, the target electronic device 200 may also be a smart phone, a server, a computer, a tablet computer, a smart watch, a smart wearable device, etc.
[0028] Specifically, after the synchronization task of the data to be synchronized is created, the processor 30 can execute the created synchronization task, and synchronize the data to be synchronized in the synchronization task to the target electronic device 200 in an asynchronous manner.
[0029] For example, the electronic device 100 is a smart phone, and the target electronic device 200 is a server. When the processor 30 of the smart phone executes a synchronization task to synchronize game data, the processor 30 of the smart phone synchronizes the game data in the synchronization task in an asynchronous manner. That is, when the processor 30 of the smart phone synchronizes each game data in the synchronization task to the server, there is no need to wait for the notification of whether the synchronization of the game data is completed to be transmitted to the processor 30 of the smart phone. The processor 30 of the smart phone can then synchronize the next game data to the server, and synchronize the remaining game data in sequence.
[0030] For another example, the electronic device 100 is a server and the target electronic device 200 is a smart phone. When the server's processor 30 executes a synchronization task to synchronize application data, the server's processor 30 synchronizes the application data in the synchronization task in an asynchronous manner. That is, when the server's processor 30 synchronizes each application data in the synchronization task to the smart phone, there is no need to wait for the notification of whether the synchronization of the application data is completed to be transmitted to the server's processor 30. The server's processor 30 can then synchronize the next application data to the smart phone, and synchronize the remaining application data in sequence.
[0031] In this way, by creating a synchronization task in the electronic device 100 and executing the created synchronization task when the data to be synchronized is written into the memory 40 of the electronic device 100, the timeliness of the synchronization is guaranteed; and compared with synchronizing the data to be synchronized in a synchronous manner, it is necessary to wait for the target electronic device 200 to send back a notification that the synchronization of the data to be synchronized is completed before the next synchronization of the data to be synchronized can be performed, synchronizing one or more data to be synchronized in the synchronization task to the target electronic device 200 in an asynchronous manner can improve the synchronization efficiency of the data to be synchronized, and further improve the timeliness of synchronizing the data to be synchronized to the target electronic device 200, taking into account both the timeliness and efficiency of data synchronization.
[0032] See also Figure 4 In some implementations, before executing the synchronization task, the data synchronization method further includes:
[0033] Step 013: Determine whether the preset synchronization task queue is empty;
[0034] Step 014: If yes, add the synchronization task to the synchronization task queue, and update the target synchronization timestamp of the synchronization task queue according to the maximum timestamp corresponding to all the data to be synchronized of the synchronization task. The data to be synchronized of the synchronization task includes all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp. The local synchronization timestamp is the maximum timestamp of the synchronized data.
[0035] Step 015: If not, update the target synchronization timestamp of the synchronization task queue according to the maximum timestamp.
[0036] Specifically, before executing a synchronization task, the processor 30 of the electronic device 100 needs to determine whether the previous synchronization task is completed. If it is determined that the previous synchronization task is completed, the processor 30 can execute the steps of the current synchronization task; if the previous synchronization task is not completed, the electronic device 100 needs to wait for the previous synchronization task to be completed before executing the steps of the current synchronization task.
[0037] Optionally, the processor 30 can add the created synchronization task to the synchronization task queue, and different synchronization task queues can correspond to different types of data to be synchronized. For example, the data to be synchronized can be game data, chat data, or shooting data, etc. Game data, chat data, or shooting data each correspond to a different synchronization task queue, thereby achieving classified data synchronization of different data. Before executing a synchronization task, the processor 30 of the electronic device 100 needs to judge the preset synchronization task queue to determine whether the preset synchronization task queue is empty, that is, whether there is an unfinished synchronization task.
[0038] When the processor 30 determines that the synchronization task queue is empty, the processor 30 can add the current synchronization task to the synchronization task queue, and update the target synchronization timestamp of the synchronization task queue according to the maximum timestamp of all the timestamps corresponding to the data to be synchronized in the current synchronization task. Each piece of data to be synchronized has a timestamp, and the timestamp corresponding to the data to be synchronized can be the time information when the data to be synchronized is written into the electronic device 100, and the target synchronization timestamp can be the writing time of the last data to be synchronized in the current synchronization task (i.e., the maximum timestamp of all the timestamps corresponding to the data to be synchronized).
[0039] When executing a synchronization task, the data to be synchronized can be sorted in order from small to large timestamps, and then the part that needs to be synchronized in the synchronization task is all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp, wherein the local synchronization timestamp can be the maximum timestamp of the synchronized data in the previous synchronization task, or the timestamp of the data to be synchronized that has been synchronized by the electronic device 100 the most recently. For electronic devices 100 (such as smart phones and servers), there are corresponding local synchronization timestamps.
[0040] When the processor 30 determines that the preset synchronization task queue is not empty, that is, there are unfinished synchronization tasks, the processor 30 can determine the maximum timestamp of all the data to be synchronized of the current synchronization task, and use the maximum timestamp to update the target synchronization timestamp of the current synchronization task queue. Since the synchronization task queue synchronizes all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp when performing data synchronization, the current synchronization task and the unfinished synchronization tasks are merged into the same synchronization task, and data synchronization is performed centrally, thereby improving synchronization efficiency.
[0041] In this way, by determining whether the preset synchronization task queue is empty, and when the preset synchronization task queue is not empty, merging the previous synchronization task and the current synchronization task into the same synchronization task for processing, the synchronization efficiency of the data to be synchronized can be improved.
[0042] See also Figure 5 In some implementations, step 012: executing a synchronization task includes:
[0043] Step 0121: Transmit all the data to be synchronized of the synchronization task to the target electronic device 200 through one or more synchronization operations.
[0044] Specifically, when the processor 30 is executing a synchronization task, when the number of data to be synchronized is large enough, because the number of synchronized data to be synchronized is restricted by the hardware of the electronic device 100, all the data to be synchronized in the synchronization task cannot be synchronized to the target electronic device 200 at one time, so the processor 30 needs to synchronize the data to be synchronized multiple times. At this time, the number of synchronized data to be synchronized by the processor 30 is synchronized according to the maximum number of synchronized data that the electronic device 100 can synchronize. For example, the number of data to be synchronized in the synchronization task is 100, and the maximum number of synchronized data to be synchronized by the electronic device 100 is 30. Then the processor 30 synchronizes 30 data to be synchronized each time, and completes the synchronization task through 4 synchronization operations. When the number of data to be synchronized is small enough, the processor 30 can synchronize all the data to be synchronized in the synchronization task to the target electronic device 200 at one time. For example, the number of data to be synchronized in the synchronization task is 10, and the maximum number of synchronized data to be synchronized by the electronic device 100 is 30. Then the processor 30 synchronizes 10 data to be synchronized, and completes the synchronization task through 1 synchronization operation.
[0045] In this way, by performing one or more synchronization operations on the data to be synchronized and transmitting all the data to be synchronized of the synchronization task to the target electronic device 200, the synchronization efficiency of synchronizing the data to be synchronized to the target electronic device 200 can be improved.
[0046] See also Figure 6 In some embodiments, the data synchronization method further includes:
[0047] Step 016: Upon receiving a notification that each piece of data to be synchronized has been synchronized successfully, the synchronization task is determined to be completed, and the local synchronization timestamp is updated according to the maximum timestamp corresponding to all the data to be synchronized of the synchronization task. The local synchronization timestamp is the maximum timestamp of the synchronized data.
[0048] When the processor 30 synchronizes all the data to be synchronized in the synchronization task queue, each time a piece of data to be synchronized completes the synchronization operation, the target electronic device 200 will form a notification of successful synchronization for the data to be synchronized that has completed the synchronization operation, and after the synchronization of the current data to be synchronized is completed, the target electronic device 200 will send the notification to the memory 40 of the current electronic device 100 for storage.
[0049] When a notification that each piece of data to be synchronized in the current synchronization task has been successfully synchronized is stored in the memory 40 of the current electronic device 100, the processor 30 of the current electronic device 100 can determine that the current synchronization task is completed, and the processor 30 needs to update the local synchronization timestamp of the current electronic device 100 based on the corresponding maximum timestamp of all the data to be synchronized in the synchronization task, wherein the local timestamp can be the maximum timestamp of the synchronized data.
[0050] For example, taking the electronic device 100 as a smart phone, the target electronic device 200 as a server, and the smart phone synchronizing chat data to the server as an example, when all the data to be synchronized in the current synchronization task queue of the smart phone are synchronized in multiple synchronization operations, each time when one or more chat data corresponding to the synchronization operation is successfully synchronized to the server, the server will form a synchronization success notification based on the successfully synchronized chat data, and send the notification to the smart phone for storage. After all the chat data in the current synchronization task queue have corresponding synchronization success notifications, the processor 30 of the smart phone can determine that the current synchronization task is completed, and update the local synchronization timestamp of the smart phone based on the maximum timestamp corresponding to all the chat data in the server.
[0051] For another example, let the electronic device 100 be a smart phone, the target electronic device 200 be a server, and take the synchronization of game data from the server to the smart phone as an example. When the smart phone receives the data to be synchronized transmitted by the server, it will also send a notification to the server that the transmitted data to be synchronized has been successfully synchronized. Specifically, when all the data to be synchronized in the current synchronization task queue of the server are synchronized in multiple synchronization operations, when one or more game data corresponding to each synchronization operation are successfully synchronized to the smart phone, the smart phone will form a notification of successful synchronization for the successfully synchronized game data, and send the notification to the server for storage. After all the game data in the current synchronization task queue have corresponding notifications of successful synchronization, the server's processor 30 can determine that the current synchronization task is completed, and update the local synchronization timestamp of the server according to the maximum timestamp corresponding to all the game data in the smart phone.
[0052] In this way, when a notification is received that each piece of data to be synchronized is synchronized successfully, the synchronization task is determined to be completed, and the local synchronization timestamp is updated according to the maximum timestamp corresponding to all the data to be synchronized in the synchronization task, thereby ensuring the accuracy of data synchronization.
[0053] See also Figure 7 In some embodiments, the data synchronization method further includes:
[0054] Step 017: upon receiving a notification of synchronization failure of any data to be synchronized, determining that the synchronization task is not completed, and sorting the write timestamps of all the data to be synchronized of the synchronization task to determine the maximum timestamp that is smaller than the write timestamp of the data to be synchronized that failed to be synchronized;
[0055] Step 018: Update the local synchronization timestamp according to the maximum timestamp. The local synchronization timestamp is the maximum timestamp of the synchronized data. The data to be synchronized of the synchronization task includes all data to be synchronized between the local synchronization timestamp and the target synchronization timestamp.
[0056] Specifically, when the target electronic device 200 receives the data to be synchronized, and any of the data to be synchronized fails to synchronize, the target electronic device 200 can determine that the current synchronization task is not completed. At this time, the processor 30 of the current electronic device 100 sorts the write timestamps of all the data to be synchronized in the synchronization task in a small to large manner, so as to determine the maximum timestamp of the write timestamp of the data to be synchronized that fails to synchronize in the current synchronization task. For example, the data to be synchronized can be [5, 7, 9, 12, 15], wherein the data to be synchronized [5, 7, 12, 15] is synchronized and completed, and the data to be synchronized 9 is synchronized and failed. At this time, it can be determined that the current synchronization task has failed, and the write timestamps of the data to be synchronized are sorted in a small to large manner, and the processor 30 can determine that the maximum timestamp of the data to be synchronized 9 that fails to synchronize is 7; when the data to be synchronized [7, 9, 15] is synchronized and completed, and the data to be synchronized 5 fails to synchronize, there is no maximum timestamp of the data to be synchronized 5 that fails to synchronize in the current synchronization task, and at this time, it can be determined that the maximum timestamp in the previous synchronization task is less than the maximum timestamp of the data to be synchronized that fails to synchronize.
[0057] When the processor 30 determines that the maximum timestamp of the data to be synchronized in the current synchronization task is less than the maximum timestamp of the data to be synchronized that failed to synchronize, the local synchronization timestamp of the current electronic device 100 is updated according to the maximum timestamp. The data to be synchronized in the current synchronization task includes all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp, and the target synchronization timestamp may be the write timestamp of the last data to be synchronized in the current synchronization task.
[0058] See also Figure 8 In some embodiments, the data synchronization method further includes:
[0059] Step 019: Obtain the time difference between the local time and the time of the target electronic device 200; and
[0060] Step 020: Adjust the write timestamp of the synchronized data according to the time difference so that the write timestamp of the synchronized data matches the time of the electronic device 100 .
[0061] Specifically, because the timing accuracy of the current electronic device 100 and the target electronic device 200 is different, there may be an error between the time of the electronic device 100 and the time of the target electronic device 200, and the write timestamp of the data to be synchronized on the current electronic device 100 is not accurate on the target electronic device 200. Therefore, the processor 30 of the current electronic device 100 needs to obtain the local time of the current electronic device 100 and the time of the target electronic device 200, and calculate the time difference between the local time of the current electronic device 100 and the time of the target electronic device 200.
[0062] After obtaining the time difference between the current electronic device 100 and the target electronic device 200, the current electronic device 100 adjusts the write timestamp of each data to be synchronized according to the time difference when performing data synchronization, so that the write timestamp of the synchronized data matches the time of the target electronic device 200.
[0063] For example, taking the current electronic device 100 as a smart phone, the target electronic device 200 as a server, and the smart phone synchronizing the data to be synchronized with the server as an example, by calculating the time difference between the smart phone and the server, the write timestamp of the data to be synchronized for data synchronization of the smart phone is adjusted, so that the write timestamp of the synchronized data received by the server (the data to be synchronized of the smart phone becomes synchronized data after being transmitted to the server) matches the time of the server. The adjustment method is to add the time difference to the write timestamp of the data to be synchronized, or, taking the current electronic device 100 as a server, the target electronic device 200 as a smart phone, and the server synchronizing the data to be synchronized with the smart phone as an example, by calculating the time difference between the smart phone and the server, the write timestamp of the data to be synchronized for data synchronization of the server is adjusted, so that the write timestamp of the synchronized data in the smart phone matches the time of the smart phone.
[0064] Optionally, the server may perform data synchronization in the same manner as step 011 and step 012, taking into account both the timeliness and efficiency of synchronization; or, the server may also transmit the data to be synchronized at a regular interval, for example, the server transmits the data to be synchronized to other electronic devices 100 every 30 minutes, one hour, etc., to avoid frequent data synchronization occupying too many resources; or, the server may perform data synchronization upon receiving a synchronization instruction sent by other electronic devices 100; or, the server may perform data synchronization by triggering a threshold, for example, when a threshold (such as a threshold of half an hour, one hour, etc.) is reached between the local synchronization timestamp of the server and the target synchronization timestamp (the maximum timestamp of the data to be synchronized), data synchronization is performed, thereby performing data synchronization when a large amount of data to be synchronized has accumulated, thereby maximizing the efficiency of data synchronization.
[0065] See also Fig. 9 The data synchronization device 10 of the implementation mode of the present application includes a creation module 11 and an execution module 12. The creation module 11 is used to create a synchronization task when the data to be synchronized is written; and the execution module 12 is used to execute the synchronization task to synchronize the data to be synchronized to the target electronic device 200 in an asynchronous manner.
[0066] The data synchronization device 10 also includes a judgment module 13, which is used to judge whether the previous synchronization task is completed; if so, wait until the previous synchronization task is completed before entering the step of executing the synchronization task; if not, enter the step of executing the synchronization task.
[0067] The execution module 12 is specifically used to transmit all the to-be-synchronized data of the synchronization task to the target electronic device 200 through one or more synchronization operations.
[0068] The data synchronization device 10 also includes a first determination module 14, which is used to determine that the synchronization task is completed when receiving a notification that each data to be synchronized is successfully synchronized, and update the local synchronization timestamp according to the maximum timestamp corresponding to all the data to be synchronized of the synchronization task. The local synchronization timestamp is the maximum timestamp of the synchronized data.
[0069] The data synchronization device 10 also includes a second determination module 15, which is used to determine that the synchronization task is not completed when receiving a notification of synchronization failure of any data to be synchronized, and sort the write timestamps of all the data to be synchronized of the synchronization task to determine the maximum timestamp of the write timestamp of the data to be synchronized that is less than the synchronization failure.
[0070] The data synchronization device 10 also includes an update module 16, which is used to update the local synchronization timestamp according to the maximum timestamp. The local synchronization timestamp is the maximum timestamp of the synchronized data. The data to be synchronized of the synchronization task includes all data to be synchronized between the local synchronization timestamp and the target synchronization timestamp.
[0071] The data synchronization device 10 further includes an acquisition module 17 , which is used to acquire the time difference between the local time and the time of the target electronic device 200 .
[0072] The data synchronization device 10 further includes an adjustment module 18 , which is configured to adjust the write timestamp of the synchronized data according to the time difference, so that the write timestamp of the synchronized data matches the time of the electronic device 100 .
[0073] The data synchronization device 10 further includes a receiving module 19 , which is used to send a notification of successful synchronization of the transmitted data to be synchronized to the target electronic device 200 when receiving the data to be synchronized transmitted by the target electronic device 200 .
[0074] See also Figure 2 and Figure 3 The electronic device 100 of an embodiment of the present application includes a processor 30, a memory 40 and a computer program, wherein the computer program 50 is stored in the memory 40 and executed by the processor 30, and the computer program 50 includes instructions for executing the data synchronization method of any of the above-mentioned embodiments.
[0075] Specifically, the electronic device 100 may be a smart phone, a server, glasses, a television, a robot, etc. The electronic device 100 may also be a tablet computer, a display device, a laptop computer, a teller machine, a gate machine, a smart watch, a head-mounted display device, a game console, etc. The embodiment of the present application is described by taking the electronic device 100 as a mobile phone as an example. It is understood that the specific form of the electronic device 100 is not limited to a mobile phone.
[0076] Optionally, the electronic device 100 includes a processor 30 and a memory 40, and the memory 40 stores a computer program 50. When the computer program 50 is executed by the processor 30, the processor 30 can also execute the data synchronization method of any of the above-mentioned embodiments, which will not be described in detail here for the sake of brevity.
[0077] See also Fig.10 The embodiment of the present application also provides a computer-readable storage medium 300 on which a computer program 310 is stored. When the computer program 310 is executed by a processor 320, the steps of the data synchronization method of any of the above-mentioned embodiments are implemented. For the sake of brevity, they are not repeated here.
[0078] In the description of this specification, the descriptions with reference to the terms "certain embodiments", "in an example", "exemplarily", etc., mean that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0079] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0080] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A data synchronization method, characterized in that: include: When the data to be synchronized is written, a synchronization task is created; and The synchronization task is executed to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
2. The data synchronization method according to claim 1, characterized in that: Before executing the synchronization task, the method further includes: Determine whether the preset synchronization task queue is empty; If so, add the synchronization task to the synchronization task queue, and update the target synchronization timestamp of the synchronization task queue according to the maximum timestamp corresponding to all the data to be synchronized of the synchronization task, the data to be synchronized of the synchronization task includes all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp, and the local synchronization timestamp is the maximum timestamp of the synchronized data; If not, the target synchronization timestamp of the synchronization task queue is updated according to the maximum timestamp.
3. The data synchronization method according to claim 1 or 2, characterized in that: The executing the synchronization task includes: Through one or more synchronization operations, all the data to be synchronized of the synchronization task are transmitted to the target electronic device.
4. The data synchronization method according to claim 3, characterized in that: Also includes: When receiving a notification that each of the data to be synchronized is synchronized successfully, the synchronization task is determined to be completed, and the local synchronization timestamp is updated according to the maximum timestamp corresponding to all the data to be synchronized of the synchronization task, and the local synchronization timestamp is the maximum timestamp of the synchronized data.
5. The data synchronization method according to claim 3, characterized in that: Also includes: In the case of receiving a notification of synchronization failure of any of the data to be synchronized, determining that the synchronization task is not completed, and sorting the write timestamps of all the data to be synchronized of the synchronization task to determine a maximum timestamp that is smaller than the write timestamp of the data to be synchronized that failed to synchronize; According to the maximum timestamp, the local synchronization timestamp is updated, the local synchronization timestamp is the maximum timestamp of the synchronized data, and the data to be synchronized of the synchronization task includes all the data to be synchronized between the local synchronization timestamp and the target synchronization timestamp.
6. The data synchronization method according to claim 1, characterized in that: Also includes: Acquire the time difference between the local time and the time of the target electronic device; and The write timestamp of the synchronized data is adjusted according to the time difference so that the write timestamp of the synchronized data matches the time of the electronic device where the synchronized data is located.
7. The data synchronization method according to claim 1, characterized in that: Also includes: In case of receiving the data to be synchronized transmitted by the target electronic device, a notification of successful synchronization of the transmitted data to be synchronized is sent to the target electronic device.
8. A data synchronization device, characterized in that: The data synchronization device comprises: A creation module, used to create a synchronization task when the data to be synchronized is written; and The execution module is used to execute the synchronization task to synchronize the data to be synchronized to the target electronic device in an asynchronous manner.
9. An electronic device, characterized in that: include: Processor, memory; and A computer program, wherein the computer program is stored in the memory and executed by the processor, and the computer program includes instructions for executing the data synchronization method according to any one of claims 1 to 7.
10. A non-volatile computer-readable storage medium containing a computer program, wherein when the computer program is executed by a processor, the processor executes the data synchronization method according to any one of claims 1 to 7.
