Detailed Description
The present application describes embodiments, but the description is illustrative rather than limiting and it will be apparent to those of ordinary skill in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are possible. Any feature or element of any embodiment may be used in combination with or instead of any other feature or element in any other embodiment, unless expressly limited otherwise.
The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive concept as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive aspects to form yet another unique inventive aspect, as defined by the claims. Thus, it should be understood that any of the features shown and/or discussed in this application may be implemented alone or in any suitable combination. Accordingly, the embodiments are not limited except as by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
Further, in describing representative embodiments, the specification may have presented the method and/or process as a particular sequence of steps. However, to the extent that the method or process does not rely on the particular order of steps set forth herein, the method or process should not be limited to the particular sequence of steps described. Other orders of steps are possible as will be understood by those of ordinary skill in the art. Therefore, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. Further, the claims directed to the method and/or process should not be limited to the performance of their steps in the order written, and one skilled in the art can readily appreciate that the sequences may be varied and still remain within the spirit and scope of the embodiments of the present application.
As shown in fig. 1, a data synchronization method according to an embodiment of the present application includes the following operations:
s1, the mobile terminal determines first incremental data uploaded to the cloud server according to the timestamp stored in the local database;
s2, when a preset condition is met, the mobile terminal sends a synchronization request to a cloud server; the synchronization request is used for instructing the cloud server to save the first incremental data;
and S3, after the mobile terminal receives the feedback message of the completion of the operation of the cloud server, acquiring the current timestamp of the cloud server, and updating the timestamp of the local database.
The mobile terminal can acquire the incremental data of the cloud server from the cloud server, and achieves data synchronization with the cloud server.
The pre-stored data in the local database of the mobile terminal is obtained by storing all data acquired by the mobile terminal from the cloud server into the local database when the mobile terminal is communicated with the cloud server;
in an exemplary embodiment, the mobile terminal in the present application may be a mobile phone, a computer, a PAD, a notebook computer, or the like.
In one exemplary embodiment, the predetermined condition may be every time the mobile terminal detects an operation of updating data of the local database; it may also be that, at intervals of a predetermined length of time, that is: periodic synchronization; or may be whenever a predetermined indication is received, such as an indication to download incremental data; in the following description, new data may be written into the synchronization database, and the monitoring program may find that the synchronization database has new data.
According to the method and the device, the mobile terminal can determine the first incremental data uploaded to the cloud server according to the timestamp stored in the local database, and indicates the cloud server to store the first incremental data for synchronization, so that the mobile terminal can still enter data or check the data in an off-line state. In an exemplary embodiment, the operation S1, where the determining, by the mobile terminal, the first incremental data uploaded to the cloud server according to the timestamp stored in the local database includes:
s11, when the mobile terminal detects the operation of updating the pre-stored data in the local database, modifying the time field of the updated data; the time field of each piece of data in the local database is used for recording the last updating time of the piece of data;
s12, comparing the time stamp stored in the local database with the time fields of all the data in the local database;
and S13, determining the data of which the time represented by the time field in the local data is later than the time stamp in the local database as the first incremental data uploaded to the cloud server.
In an exemplary embodiment, the operation of updating the pre-stored data in the local database may be an operation of adding, deleting, modifying, and the like to the data in the local database.
In one exemplary embodiment, the method further comprises the operations of:
s4, after the mobile terminal sends a synchronization request to the cloud server or receives an indication of a user to download incremental data, the mobile terminal sends a timestamp stored in a local database to the cloud server;
s5, when second incremental data exist in the cloud server, downloading the second incremental data from the cloud server, and storing the second incremental data in a local database; the second incremental data is data updated by the cloud server determined by the cloud server according to the received timestamp sent by the mobile terminal;
and S6, acquiring the current time stamp of the cloud server, and updating the time stamp of the local database.
According to the embodiment of the application, the incremental data of the cloud service can be acquired from the cloud server to achieve synchronization with the cloud. Generally, there may be a plurality of terminals connected to the cloud servers, and when data of each cloud server is updated, the data is synchronized to the cloud server. And the data synchronization of a plurality of terminals is realized by synchronizing the newly added data of the cloud server to the terminals.
In an exemplary embodiment, operation S2, when the predetermined condition is satisfied, the mobile terminal sending a synchronization request to the cloud server, before comprising:
s7, the mobile terminal writes the determined first incremental data uploaded to the cloud server into a synchronous database;
and S8, after the synchronization database monitors that the first incremental data is written in, executing the operation that the mobile terminal sends a synchronization request to a cloud server when the predetermined condition is met.
By storing and sending the incremental data in the synchronous database, the embodiment of the application can manage the incremental data and prevent the influence of the repetition or error of the synchronous data on the local database.
In an exemplary embodiment, the obtaining the current timestamp of the cloud server and updating the timestamp of the local database in operation S3 includes:
and S9, deleting the data in the synchronous database which is earlier than the updated time stamp of the local database.
As shown in fig. 2, a data synchronization method according to an embodiment of the present application includes the following operations:
m1, when the cloud server receives a data synchronization request sent by the mobile terminal, downloading first incremental data uploaded by the mobile terminal and storing the first incremental data in a cloud database;
m2, feeding back the operation completion message to the mobile terminal;
m3, acquiring a current system time updating timestamp and sending the current system time updating timestamp to the mobile terminal;
m4, the first incremental data uploaded by the mobile terminal is the data updated by the local database of the mobile terminal determined by the mobile terminal according to the timestamp stored in the local database.
The cloud server can download the incremental data of the mobile terminal from the mobile terminal to achieve data synchronization with the mobile terminal.
In an exemplary embodiment, the operation M2, the feeding back the message of operation completion to the mobile terminal, includes the following operations:
m5, the cloud server determines whether second incremental data exist in the cloud server according to the received timestamp stored in the local database sent by the mobile terminal;
m6, when the second incremental data exists, sending a synchronization request to the mobile terminal; the synchronization request is used for instructing the mobile terminal to save the second incremental data.
In an exemplary embodiment, the operation M5, where the cloud server determines whether the second incremental data exists in the cloud server according to the received timestamp stored in the local database sent by the mobile terminal, includes operations of:
m50, comparing the time stamp stored in the local database with the time fields of all the data in the cloud database;
m51, determining that second incremental data exists in the cloud server if data exists in the cloud database whose time represented by the time field is later than the time stamp in the local database.
According to the embodiment of the application, the incremental data of the cloud can be determined through the timestamp uploaded by the mobile terminal, and the incremental data are synchronously sent to the mobile terminal.
As shown in fig. 3, in an interaction process between the mobile terminal and the cloud server, a local database is first set at the mobile terminal to store data that can be used and checked by a currently logged-in user, and when the user logs in the mobile terminal for the first time, because the local database is not synchronized with the data from the cloud, the data that can be used and checked by the currently logged-in user must be obtained from the cloud database in full under a condition that the user can be connected to a network. And acquiring the time stamp of the cloud server while acquiring the full data, and storing the time stamp into a local database of the mobile terminal. The timestamp is used for judging which data in the cloud database belong to the newly added data.
After the local database of the mobile terminal obtains the data, various operations of the login user at the mobile terminal are based on the local database, so that whether the network connection exists or not does not influence the operation of the mobile terminal. The data viewed by the user are all data in the local database. The addition, deletion and modification of the data are also completed in the local database. The addition, deletion and modification of data are all data updating operations, each piece of data has a field of the latest updating time, and once the data is updated, the field of the latest updating time is modified by using the system time.
The mobile terminal is additionally provided with a synchronous database which is specially used for data synchronization between the mobile terminal and the cloud terminal. Once the local data is updated, the updated data is written into the synchronous database at the same time.
The mobile terminal is locally provided with a program which has two mechanisms for triggering the synchronous request to be sent to the cloud terminal.
1) Mechanism 1: once the data of the synchronous database is updated (added, deleted or changed), the program is triggered to send a synchronous request to the cloud. This mechanism is used to trigger a synchronization request if the mobile can connect to the network.
2) Mechanism 2: every 3 minutes or other time, the program will automatically send a synchronization request to the cloud. This mechanism is used to trigger a synchronization request if the mobile cannot connect to the network.
After the terminal performs the input operation, when the local database is updated; and determining newly added data according to the timestamp stored in the local database, specifically comparing the time recorded by the field of the data with the timestamp, considering the data after the timestamp as newly added data, and considering the data before the timestamp as non-newly added data. And the mobile terminal writes the newly added data into the synchronous database, and the monitoring program starts an uploading process periodically or uploads the locally stored time stamps together after finding that the synchronous database has new data or receiving an indication of a user to download incremental data. When the cloud end has the new data, receiving the new data sent by the cloud end; receiving an operation completion message and a timestamp sent by the cloud end, and updating the locally stored timestamp; and deleting all data in the synchronous database before the updated time stamp.
After receiving the synchronization request, a cloud interface program of the cloud server firstly inquires whether new data exists in a cloud database according to the uploaded time stamp, and if the new data exists, the new data is selected out to be used as incremental data to be synchronized to the terminal. And after the increment query of the cloud is completed, the newly uploaded increment data is written into the cloud database. And finally, acquiring a latest timestamp from the cloud, and transmitting the latest timestamp and the new incremental data of the cloud back to the terminal.
As shown in fig. 4, a mobile terminal according to an embodiment of the present application includes: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for: the mobile terminal determines first incremental data uploaded to a cloud server according to the timestamp stored in the local database; when a preset condition is met, the mobile terminal sends a synchronization request to a cloud server; the synchronization request is used for instructing the cloud server to save the first incremental data; and when the mobile terminal receives the feedback message of the completion of the operation of the cloud server, acquiring the current timestamp of the cloud server, and updating the timestamp of the local database.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.