Data synchronization method and device, terminal equipment and storage medium
By defining the reported data structure and data synchronization interface of the data to be synchronized, the synchronization delay and out-of-synchronization problems between local devices and cloud devices are solved, the data transmission and processing process is optimized, and the accuracy and consistency of data exchange is ensured. Improve synchronization efficiency.
Patent Information
- Application Number
- CN202411093959.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-22
AI Technical Summary
Data synchronization delay or out-of-synchronization problems between local devices and cloud devices affect user experience.
By defining the data structure and data synchronization interface to be synchronized, the data transmission and processing process can be optimized, ensuring the consistency and accuracy of local terminals and cloud devices during data exchange, and reducing the results of format mismatch or interface incompatibility. Synchronization delay and data out-synchronization issues.
Effectively reduce synchronization delay caused by format mismatch or interface incompatibility, ensure the consistency and accuracy of data exchange, and improve the efficiency and reliability of data synchronization.
Smart Images

Figure CN119003658A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of big data storage technology, and in particular, relates to a data synchronization method, apparatus, terminal device and storage medium. Background Art
[0002] With the continuous development of cloud server technology, more and more users are starting to store data in the cloud. Storing data in the cloud can meet the needs of modern users to access and manage data on multiple devices, achieve seamless synchronization of data between different devices, and greatly improve the work and life efficiency of users. Secondly, storing data in the cloud can effectively avoid data loss caused by local device failures and improve data reliability and security. At the same time, multi-terminal access to cloud storage also supports real-time collaboration across devices, bringing new possibilities for scenarios such as enterprise collaboration and online education. In addition, cloud storage has the advantage of unlimited expansion capacity, which can meet the needs of rapid growth in user data volume and reduce user operation and maintenance costs. Finally, users can make full use of the advantages of high security and high reliability of cloud storage services to further improve the overall quality of multi-terminal data synchronization. In summary, accessing cloud storage to synchronize data is an important solution to meet user needs and improve system performance.
[0003] In the related art, data between local devices and cloud devices often have synchronization delays or asynchrony, which affects the user experience. Summary of the invention
[0004] The embodiments of the present application provide a data synchronization method, apparatus, terminal device and storage medium, which can solve the problem of frequent synchronization delay or asynchrony between local devices and cloud devices in the related art.
[0005] In a first aspect, an embodiment of the present application provides a data synchronization method, which is applied to a local terminal, wherein a data synchronization system where the local terminal is located also includes a cloud device, and the method includes:
[0006] Agree on the reporting data structure of the data to be synchronized;
[0007] Define data synchronization interface;
[0008] According to the data synchronization interface and the reported data structure, the data to be synchronized is synchronized with the cloud device.
[0009] In a second aspect, an embodiment of the present application provides a data synchronization device, which is applied to a local terminal, wherein the data synchronization system where the local terminal is located also includes a cloud device, and the device includes:
[0010] The agreement module is used to agree on the reporting data structure of the data to be synchronized;
[0011] Definition module, used to define data synchronization interface;
[0012] A synchronization module is used to synchronize the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure.
[0013] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data synchronization method when executing the computer program.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned data synchronization method are implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the above-mentioned data synchronization method.
[0016] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: the embodiments of the present application synchronize the data to be synchronized with the cloud device by agreeing on the reporting data structure of the data to be synchronized and defining the data synchronization interface, and then synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reporting data structure. The embodiments of the present application can optimize the data transmission and processing flow through clear data structure and interface definitions, and reduce synchronization delays caused by format mismatch or interface incompatibility. By setting a unified data structure and interface, the consistency and accuracy of data exchange between local terminals and cloud devices can be ensured, reducing data asynchrony problems caused by data format errors or improper processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0018] Figure 1 This is a schematic diagram of an implementation flow of a data synchronization method provided in an embodiment of the present application;
[0019] Figure 2 It is a structural diagram of a data synchronization device provided in an embodiment of the present application;
[0020] Figure 3It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0022] It should be noted that the terms "include", "comprises" and "have" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specification and drawings of the present application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.
[0023] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0024] With the continuous development of cloud server technology, more and more users are starting to store data in the cloud. Storing data in the cloud can meet the needs of modern users to access and manage data on multiple devices, achieve seamless synchronization of data between different devices, and greatly improve the work and life efficiency of users. Secondly, storing data in the cloud can effectively avoid data loss caused by local device failures and improve data reliability and security. At the same time, multi-terminal access to cloud storage also supports real-time collaboration across devices, bringing new possibilities for scenarios such as enterprise collaboration and online education. In addition, cloud storage has the advantage of unlimited expansion capacity, which can meet the needs of rapid growth in user data volume and reduce user operation and maintenance costs. Finally, users can make full use of the advantages of high security and high reliability of cloud storage services to further improve the overall quality of multi-terminal data synchronization. In summary, accessing cloud storage to synchronize data is an important solution to meet user needs and improve system performance.
[0025] In the related art, data between local devices and cloud devices often have synchronization delays or asynchrony, which affects the user experience.
[0026] In view of this, the embodiments of the present application can optimize data transmission and processing processes through clear data structure and interface definitions, and reduce synchronization delays caused by format mismatch or interface incompatibility. By setting a unified data structure and interface, the consistency and accuracy of data exchange between local terminals and cloud devices can be ensured, reducing data asynchrony problems caused by incorrect data format or improper processing.
[0027] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0028] Figure 1 The present invention provides a data synchronization method according to an embodiment of the present invention, which can be applied to a local terminal. The local terminal refers to a terminal device that a user directly operates or interacts with locally, and can be a smart phone, tablet computer, laptop computer, ultra-mobile personal computer (UMPC), netbook, etc.
[0029] The data synchronization system of the local terminal also includes cloud devices, which can be remote servers or server clusters that provide data storage and processing services. User data can be uploaded to the cloud for storage, enabling cross-device access and sharing.
[0030] Specifically, the above data synchronization method may include the following steps S101 to S103.
[0031] Step S101, agreeing on a reporting data structure for data to be synchronized.
[0032] The data to be synchronized refers to the data that needs to be synchronized between the local terminal and the cloud device. It can be files, pictures, videos, etc. created by users, or the running status and settings of applications. The reported data structure is a specification for describing the format and content of the data to be synchronized.
[0033] In the implementation mode of the present application, for the data that needs to be synchronized, the local terminal can design one or more data structures to describe the data. These data structures contain enough information so that the cloud device can accurately understand and process the received data. Specifically, the local terminal can define the file's name, size, type, creation time and other attributes as the data structure for file synchronization. By defining a unified data structure, it can be ensured that the local terminal and the cloud device can correctly parse and process the data when exchanging data.
[0034] Step S102, defining a data synchronization interface.
[0035] The data synchronization interface is an interface or protocol used to implement data exchange between the local terminal and the cloud device. Through the data synchronization interface, the local terminal can send the data to be synchronized to the cloud device, and can also receive data updates from the cloud device.
[0036] In the implementation mode of the present application, after determining the reported data structure of the data to be synchronized, the local terminal can define one or more data synchronization interfaces. The data synchronization interface specifies the request format, response format, error handling mechanism, etc. of data synchronization. Exemplarily, a RESTful API interface can be defined to implement data upload, download and update operations through HTTP requests.
[0037] Step S103: synchronize the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure.
[0038] In the implementation mode of the present application, the local terminal can write corresponding code logic to trigger the data synchronization operation according to the defined data synchronization interface and reported data structure. When new data is generated or the data changes, the local terminal can send the data to be synchronized to the cloud device according to the agreed data structure and interface. After receiving the data, the cloud device can perform corresponding processing and feedback the updated data status to the local terminal. At the same time, the cloud device can also actively push the latest data changes to the local terminal to achieve two-way synchronization of data.
[0039] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: the embodiments of the present application synchronize the data to be synchronized with the cloud device by agreeing on the reporting data structure of the data to be synchronized and defining the data synchronization interface, and then synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reporting data structure. The embodiments of the present application can optimize the data transmission and processing flow through clear data structure and interface definitions, and reduce synchronization delays caused by format mismatch or interface incompatibility. By setting a unified data structure and interface, the consistency and accuracy of data exchange between local terminals and cloud devices can be ensured, reducing data asynchrony problems caused by data format errors or improper processing.
[0040] In some implementations of the present application, before synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure, the method may further include the following steps:
[0041] Create a database in the local terminal.
[0042] In the implementation mode of the present application, the local terminal can install and configure database software (such as SQLite, MySQL, etc.) on the local terminal. And design the database table structure according to business requirements, including table name, field name, field type, etc. And write code logic to create a database instance on the local terminal and initialize the necessary tables and data. By creating a database on the local terminal, the data to be uploaded can be efficiently managed and synchronized, improving the efficiency and accuracy of data processing.
[0043] In some embodiments of the present application, the data synchronization interface includes a data upload interface, and the data to be synchronized includes data to be uploaded. The above-mentioned synchronization of the data to be synchronized with the cloud device based on the data synchronization interface and the reported data structure may specifically include steps S401 to S405.
[0044] Step S401, signing the data to be uploaded to obtain signature data.
[0045] In an implementation manner of the present application, the local terminal may sign the data to be uploaded, specifically by performing encryption (eg, HMAC, RSA, etc.) or hashing to obtain signature data.
[0046] Step S402: Upload the signature data to the cloud device through the data upload interface.
[0047] Among them, the data upload interface is used to send the data to be uploaded from the local terminal to the cloud device.
[0048] In an implementation manner of the present application, the local terminal may upload the signature data to the cloud device through a data upload interface.
[0049] Step S403, query the UUID of the signature data in the database.
[0050] In an implementation manner of the present application, the local terminal may query the UUID corresponding to the signature data in a database of the local terminal.
[0051] Step S404: If the data corresponding to the UUID does not exist in the database, the data corresponding to the UUID is verified according to the signature.
[0052] In an implementation manner of the present application, if the UUID does not exist in the database, the local terminal may use the signature data to verify the data corresponding to the UUID, which may specifically include decryption, hash comparison, etc.
[0053] Step S405: If the verification is successful, the data corresponding to the UUID is added to the database, and the corresponding adding time is recorded.
[0054] In an implementation manner of the present application, if the verification is successful, the local terminal may add the data corresponding to the UUID to the database and record the adding time.
[0055] The implementation method of this application can ensure the integrity and source reliability of the data uploaded to the cloud through signature data verification. Using UUID as the unique identifier of the data facilitates the rapid location and management of data in the database. Recording the time when the data was added helps with subsequent data version control and conflict detection.
[0056] In some specific implementations of the present application, after querying the UUID of the signature data in the database, the method may further include step S501 and step S502.
[0057] Step S501: If there is data corresponding to the UUID in the database, it is determined whether there is a conflict between the data corresponding to the UUID and the signature data according to the first timestamp of the data corresponding to the UUID and the second timestamp of the signature data.
[0058] In the implementation mode of the present application, the local terminal can query the UUID of the signature data in the database and check whether the data corresponding to the UUID already exists. If it does, the first timestamp of the data (i.e. the time recorded in the database) is compared with the second timestamp of the signature data (i.e. the time when the signature was signed).
[0059] Step S502: If it is determined that there is a conflict between the data corresponding to the UUID and the signature data, the data corresponding to the UUID or the signature data is updated according to a preset conflict resolution strategy, and the corresponding update time is recorded.
[0060] In the implementation manner of the present application, if there is a conflict between the two timestamps (eg, the second timestamp is earlier than the first timestamp), the local terminal may update according to a preset conflict resolution strategy, and after the update, record the corresponding update time.
[0061] In some specific implementations of the present application, the conflict resolution strategy includes one or more of an automatic merge strategy, a conflict marking strategy, and a priority strategy.
[0062] Specifically, the automatic merge strategy applies to changes that can be automatically merged, such as adding or deleting list data. Depending on the type and content of the changes, you can try to automatically merge changes from different ends. For example, if both ends add different elements to the same list, then you can add all of these elements to the list.
[0063] The conflict marking strategy is suitable for complex changes that cannot be merged automatically. When a conflict is detected, the data is not merged automatically, but the conflicting data items are marked and the user or administrator is notified to manually resolve the conflict, such as displaying the conflicting data items through the interface and letting the user choose which version to keep or merge the two versions.
[0064] Priority policy is used to determine which version of data should be retained based on preset priority rules. Priority rules are predefined, such as the reliability of the data source, the user's permission level, etc. When a conflict is detected, the final data version is selected based on the priority rules.
[0065] The implementation method of the present application effectively reduces the inconsistency of data between the local database and the cloud device through timestamp comparison and conflict resolution strategy, improves the accuracy and reliability of data, and takes timely measures to resolve conflicts when they are detected, avoiding unnecessary network transmission and data overwriting, and improving the efficiency of data synchronization.
[0066] In some specific implementations of the present application, the data synchronization interface includes a data deletion interface, and the data to be synchronized includes data to be deleted. The above-mentioned data synchronization with the cloud device is performed based on the data synchronization interface and the reported data structure, and specifically may also include steps S601 to S603.
[0067] Step S601: According to the data deletion interface, the UUID of the data to be deleted is added to the List collection.
[0068] The data deletion interface is a specific part of the data synchronization interface, which is used to support the function of deleting data from a cloud device or a local database. The data to be deleted refers to the data that the user or system wants to remove from the cloud device or the local database.
[0069] In an implementation manner of the present application, the local terminal may first determine which data needs to be deleted (ie, data to be deleted), and then obtain the UUIDs of the data to be deleted and add them to a List set.
[0070] Step S602: perform a batch query on the UUIDs in the List collection, and determine whether the corresponding data to be deleted is deleted based on the queried isDeleted field.
[0071] In the implementation mode of the present application, the local terminal can use the data deletion interface or the related database query function to perform batch query on each UUID in the List collection to obtain the status of the data corresponding to these UUIDs in the database, especially the value of the isDeleted field. And according to the query result, check the value of the isDeleted field, if the isDeleted field is false or not set (indicating that the data has not been logically deleted), proceed to the next step.
[0072] Step S603: If it is determined that the data to be deleted corresponding to the isDeleted field has not been deleted, the data to be deleted is deleted from the database, and the isDeleted field is modified to record the corresponding deletion time.
[0073] In an embodiment of the present application, if it is confirmed that the data has not been deleted, the local terminal can perform a deletion operation. Specifically, the data record can be removed from the database, or the isDeleted field can be set to true to indicate that the data has been logically deleted. At the same time, the time when the data was deleted can also be recorded (or the timestamp of the isDeleted field can be updated) for subsequent tracking and auditing.
[0074] The implementation method of the present application reduces the number of single data deletion operations by batch querying and processing UUIDs, thereby improving the efficiency of data deletion. At the same time, the UUID and isDeleted fields are used to identify and track the data to be deleted, reducing the possibility of accidental deletion or omission.
[0075] In some implementations of the present application, the above method may further include steps S701 to S704.
[0076] Step S701, obtaining the data to be received from the cloud device according to the data receiving interface.
[0077] The data receiving interface is a specific part of the data synchronization interface, which is used to receive data from the cloud device. The data to be received refers to the data that is transmitted from the cloud device to the local system or database but has not yet been processed or stored by the local system.
[0078] In an embodiment of the present application, the local terminal may establish a connection with the cloud device through a data receiving interface, and receive the data to be received sent by the cloud device. Specifically, the data to be received may be encoded in a certain format (such as JSON, XML, etc.) and contain information that needs to be synchronized to the local system.
[0079] Step S702, obtaining local data in the database.
[0080] Among them, local data refers to data stored in the local system or database, which corresponds to cloud data.
[0081] In the implementation of the present application, the local terminal can access the local database and query the table or collection that needs to be synchronized to obtain the local data currently stored in the database. Specifically, this can be achieved by querying a specific field, record or the entire data set.
[0082] Step S703, determine whether the List of local data is empty.
[0083] In the implementation manner of the present application, the local terminal may convert or map the acquired local data into a List set, and check whether the List set is empty, specifically, checking whether the set contains any elements.
[0084] Step S704: if the List of local data is empty, the data to be received is added to the database.
[0085] In the implementation manner of the present application, if the List of local data is empty, it can be considered that the local database has not yet stored relevant data or data that needs to be updated. In this case, the local terminal can add the data to be received to the database. Specifically, it can be inserting a new record, updating an existing record, or performing other database operations, depending on the nature of the data to be received and the business requirements.
[0086] The implementation method of the present application simplifies the process of receiving data from cloud devices and synchronizing it to the local database through a clear data receiving interface and simple judgment logic. By allowing the data to be received to be directly added when the local database is empty, the flexibility of data synchronization is improved, especially in initialization or data migration scenarios. In addition, by checking whether the List of local data is empty, it is possible to avoid repeatedly adding the data to be received when the local database already contains relevant data, thereby reducing the risk of data conflicts and redundancy. Moreover, since the implementation method of the present application is implemented based on the data receiving interface, it can be easily expanded to support different types of data and synchronization requirements without making major changes to the overall architecture.
[0087] In some specific implementations of the present application, after determining whether the List of local data is empty, steps S801 to S803 may also be included.
[0088] Step S801: If the List of local data is not empty, the update time of the local data and the timestamp of the data to be received are obtained.
[0089] In the implementation of the present application, if it is not empty, the local terminal can traverse the List of local data (or query the database to obtain relevant data), obtain the update time of each record, and extract the timestamp information from the data to be received. This can be achieved by parsing the data format to find the timestamp field.
[0090] Step S802: determine whether the local data needs to be updated according to the update time and timestamp.
[0091] In an embodiment of the present application, the local terminal may compare the update time of each piece of local data with the timestamp of the data to be received. If the timestamp of the data to be received is later than (ie, greater than) the update time of the local data, it may be considered that the local data needs to be updated.
[0092] Step S803: if it is determined that the local data needs to be updated, the local data is updated according to the data to be received.
[0093] In an embodiment of the present application, if it is determined that the local data needs to be updated, the local terminal can use the information in the data to be received to update the local data. Specifically, it can be to replace the entire record, update a specific field, or perform a more complex logical operation. After the update is completed, the update time of the local data can be updated to reflect the latest changes.
[0094] By comparing the update time and timestamp, the implementation method of the present application can ensure that the local data is always synchronized with the cloud data, thereby improving the consistency and accuracy of the data. And only when the local data really needs to be updated, will the new data be received from the cloud and updated, which helps to reduce unnecessary data transmission and save bandwidth and computing resources. In addition, the implementation method of the present application allows real-time judgment on whether the data needs to be updated based on the timestamp, so it can support real-time or near real-time data synchronization requirements.
[0095] Figure 2 The schematic diagram of the structure of a data synchronization device provided by an embodiment of the present application is shown. The data synchronization device 2 can be configured on a local terminal. The data synchronization system where the local terminal is located also includes a cloud device. Specifically, the data synchronization device 2 can include:
[0096] The agreement module 201 is used to agree on the reporting data structure of the data to be synchronized;
[0097] A definition module 202, used to define a data synchronization interface;
[0098] The synchronization module 203 is used to synchronize the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure.
[0099] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: the embodiments of the present application synchronize the data to be synchronized with the cloud device by agreeing on the reporting data structure of the data to be synchronized and defining the data synchronization interface, and then synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reporting data structure. The embodiments of the present application can optimize the data transmission and processing flow through clear data structure and interface definitions, and reduce synchronization delays caused by format mismatch or interface incompatibility. By setting a unified data structure and interface, the consistency and accuracy of data exchange between local terminals and cloud devices can be ensured, reducing data asynchrony problems caused by data format errors or improper processing.
[0100] In some implementations of the present application, the data synchronization device 2 further includes a creation module, which is used to: create a database in a local terminal.
[0101] In some embodiments of the present application, the data synchronization interface includes a data upload interface, the data to be synchronized includes data to be uploaded, and the synchronization module 203 is also used to: sign the data to be uploaded to obtain signature data; upload the signature data to the cloud device through the data upload interface; query the UUID of the signature data in the database; if the data corresponding to the UUID does not exist in the database, verify the data corresponding to the UUID according to the signature; if the verification passes, add the data corresponding to the UUID to the database, and record the corresponding addition time.
[0102] In some embodiments of the present application, the synchronization module 203 is also used to: if there is data corresponding to the UUID in the database, then determine whether there is a conflict between the data corresponding to the UUID and the signature data based on the first timestamp of the data corresponding to the UUID and the second timestamp of the signature data; if it is determined that there is a conflict between the data corresponding to the UUID and the signature data, then update the data corresponding to the UUID or the signature data according to a preset conflict resolution strategy, and record the corresponding update time.
[0103] In some embodiments of the present application, the data synchronization interface includes a data deletion interface, the data to be synchronized includes data to be deleted, and the synchronization module 203 is also used to: add the UUID of the data to be deleted to the List collection according to the data deletion interface; perform batch queries on the UUIDs in the List collection, and determine whether the corresponding data to be deleted is deleted based on the queried isDeleted field; if it is determined that the data to be deleted corresponding to the isDeleted field has not been deleted, delete the data to be deleted from the database, modify the isDeleted field, and record the corresponding deletion time.
[0104] In some embodiments of the present application, the data synchronization interface includes a data receiving interface, the data to be synchronized includes data to be received, and the synchronization module 203 is also used to: obtain the data to be received from the cloud device according to the data receiving interface; obtain the local data in the database; determine whether the List of local data is empty; if the List of local data is empty, add the data to be received to the database.
[0105] In some embodiments of the present application, the synchronization module 203 is also used to: if the List of local data is not empty, obtain the update time of the local data and the timestamp of the data to be received; determine whether the local data needs to be updated based on the update time and timestamp; if it is determined that the local data needs to be updated, update the local data based on the data to be received.
[0106] like Figure 3 FIG. 3 is a schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 3 may include: a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301, such as a data synchronization program. When the processor 301 executes the computer program 303, the steps in the above-mentioned data synchronization method embodiment are implemented, such as Figure 1 Alternatively, when the processor 301 executes the computer program 303, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 2 The illustrated module includes a convention module 201 , a definition module 202 , and a synchronization module 203 .
[0107] The computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 302 and executed by the processor 301 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0108] The terminal device may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that Figure 3 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0109] The processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0110] The memory 302 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 302 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Further, the memory 302 may also include both an internal storage unit of the terminal device and an external storage device. The memory 302 is used to store computer programs and other programs and data required by the terminal device. The memory 302 may also be used to temporarily store data that has been output or is to be output.
[0111] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0112] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0113] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned data synchronization method can be implemented.
[0114] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the steps in the above-mentioned data synchronization method can be implemented when the mobile terminal executes the computer program product.
[0115] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0116] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0117] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0118] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0119] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0120] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0121] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data synchronization method, characterized in that: Applied to a local terminal, the data synchronization system where the local terminal is located also includes a cloud device, and the method includes: Agree on the reporting data structure of the data to be synchronized; Define data synchronization interface; According to the data synchronization interface and the reported data structure, the data to be synchronized is synchronized with the cloud device.
2. The data synchronization method according to claim 1, characterized in that: Before synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure, the method further includes: A database is created in the local terminal.
3. The data synchronization method according to claim 2, characterized in that: The data synchronization interface includes a data upload interface, the data to be synchronized includes data to be uploaded, and synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure includes: Signing the data to be uploaded to obtain signature data; Uploading the signature data to the cloud device through the data upload interface; Query the UUID of the signature data in the database; If the data corresponding to the UUID does not exist in the database, verifying the data corresponding to the UUID according to the signature; If the verification is successful, the data corresponding to the UUID is added to the database, and the corresponding adding time is recorded.
4. The data synchronization method according to claim 3, characterized in that: After querying the UUID of the signature data in the database, the method further includes: If data corresponding to the UUID exists in the database, judging whether there is a conflict between the data corresponding to the UUID and the signature data according to the first timestamp of the data corresponding to the UUID and the second timestamp of the signature data; If it is determined that there is a conflict between the data corresponding to the UUID and the signature data, the data corresponding to the UUID or the signature data is updated according to a preset conflict resolution strategy, and the corresponding update time is recorded.
5. The data synchronization method according to claim 2, characterized in that: The data synchronization interface includes a data deletion interface, the data to be synchronized includes data to be deleted, and synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure includes: According to the data deletion interface, add the UUID of the data to be deleted to the List collection; Perform batch query on the UUIDs in the List set, and determine whether the corresponding data to be deleted is deleted according to the queried isDeleted field; If it is determined that the data to be deleted corresponding to the isDeleted field has not been deleted, the data to be deleted is deleted from the database, and the isDeleted field is modified to record the corresponding deletion time.
6. The data synchronization method according to claim 2, characterized in that: The data synchronization interface includes a data receiving interface, the data to be synchronized includes data to be received, and synchronizing the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure includes: According to the data receiving interface, obtaining the data to be received from the cloud device; Acquire local data in the database; Determine whether the List of local data is empty; If the List of local data is empty, the data to be received is added to the database.
7. The data synchronization method according to claim 6, characterized in that: After determining whether the List of local data is empty, the method further includes: If the List of the local data is not empty, obtaining the update time of the local data and the timestamp of the data to be received; Determining whether the local data needs to be updated according to the update time and the timestamp; If it is determined that the local data needs to be updated, the local data is updated according to the data to be received.
8. A data synchronization device, characterized in that: Applied to a local terminal, the data synchronization system where the local terminal is located also includes a cloud device, and the device includes: The agreement module is used to agree on the reporting data structure of the data to be synchronized; Definition module, used to define data synchronization interface; A synchronization module is used to synchronize the data to be synchronized with the cloud device according to the data synchronization interface and the reported data structure.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data synchronization method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data synchronization method according to any one of claims 1 to 7 are implemented.
