Summary of the invention
Problem to be solved by this invention is, a kind of method, system, server and client that realizes multi-client data synchronization is provided, can guarantees the data sync between the multi-client, save time simultaneously, systematic function is improved in the EMS memory occupation space of minimizing system.
In order to address the above problem, the embodiment of the invention discloses a kind of method that realizes multi-client data synchronization, this method comprises:
Client receives user's application request, determines the type of the application data that described application request is asked;
According to the type of described application data, described client reads the latest update time T 1 that the application data of described type is updated from server;
Described client is the final updating time T 2 of T1 and the application data of the described type of self storage relatively, according to result relatively, and the application data of synchronous described type, and, respond described application request according to the application data of the described type after synchronously.
Correspondingly, the embodiment of the invention also discloses a kind of client, comprising:
Receiving element is used to receive user's application request;
Determining unit, the type of the application data that is used for determining that described application request is asked;
Reading unit is used for the type according to described application data, reads the latest update time T 1 that the application data of described type is updated from server;
Comparing unit is used for the final updating time T 2 of application data of the described type of comparison T1 and described client self storage;
Lock unit is used for according to described comparing unit result relatively, the application data of synchronous described type;
Response unit is used for the application data according to the described type of described lock unit after synchronously, responds described application request.
Correspondingly, the embodiment of the invention also discloses a kind of server, comprising:
Memory cell is used to store all types of application datas, and stores client is upgraded operation to described all types of application data the latest update time;
Data synchronisation unit, the type that is used for the application data of asking according to client, the latest update time T 1 of the application data of the described type of described cell stores is sent to described client, and when T1 is later than the final updating time T 2 of application data of described type of described client stores, the application data of described type is sent to described client, so that the application data of the synchronous described type of described client.
Correspondingly, the embodiment of the invention also discloses a kind of system that realizes multi-client data synchronization, comprise server and at least two clients,
Described server is used to store all types of application datas, and stores client is upgraded operation to described all types of application data the latest update time; When described client has application request, send latest update time T 1 that application data that described application request asks is updated to described client, and when described client is carried out described application data synchronous, described application data is sent to described client;
Described client is used for the application request according to the user who receives, and determines the type of the application data that described application request is asked; From server, read the latest update time T 1 that the application data of described type is updated; The final updating time T 2 of T1 and the application data of the described type of self preserving relatively, the application data of synchronous described type, and, respond described application request according to the application data of the described type after synchronous.
The embodiment of the invention compared by the latest update time to the data type of client application, and do Synchronous Processing according to comparative result, make client obtain data as required, can guarantee data sync between multi-client, guarantee that each visit all can get access to latest data, save time simultaneously, reduce the EMS memory occupation space of system, improve systematic function.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
With reference to Fig. 1, be the structural representation of the embodiment of a kind of system that realizes multi-client data synchronization of the present invention; As shown in Figure 1, described system comprises: server 20, and at least two clients 10 (because each client terminal structure is all basic identical, only client 1 has been made mark among the figure, in this explanation, N is a natural number among the figure, and the expression client can have a plurality of).
Described server 20 is used to store all types of application datas, and stores the latest update time that 10 pairs of described all types of application datas of client are upgraded operation; When described client 10 has application request, send latest update time T 1 that application data that described application request asks is updated to described client 10, and when described client 10 is carried out described application data synchronous, described application data is sent to described client 10;
In the specific implementation, because server 20 provides network necessary resource for client 10, therefore, there is mass data in the server 20, various data can be classified, the standard of its classification can be used employed application data according to each of client 10, such as, when described client 10 needed inquiry good friend address, the type of the application data that need use this moment can be address book managing application data class (Table A A); For another example, when described client 10 needed the inquiry chat record, the application data that needs to use can be divided into chat record managing application data class (table BB) or the like.
Particularly, described server 20 can be a database, and a table can be set in database, and described table can be established three fields, id, key, value.Wherein id represents from increasing field, promptly can be used for representing the sequence number of each operation, such as, client is designated as 1 when operating for the first time, and operation for the second time is designated as 2 or the like; Key represents the various classification of application data, and the form that every class application data can be shown is stored in the database, and key has promptly stored the table name of all kinds of tables, such as: stored the table name of address book managing application data table among the key, promptly represented with Table A A; Or the table name of chat record managing application data table, promptly represent or the like with table BB; What Value represented is the latest update time that all types of application datas is updated, such as, when client 10 has been upgraded application data among the Table A A, Value is composed the current time, be that the key value is in the record of " AA " in the database, corresponding Value value is the latest update time of " AA " class application data; Particularly, the table name of all types of application data in the described key field is corresponding one by one with the time value in the described value field, such as, the key value is the record of " AA ", a corresponding unique Value value, the key value is the record of " BB ", a corresponding unique Value value etc.Particularly, the corresponding relation of key and Value such as following table:
??Key |
??Value |
??AA |
The latest update time that application data among the Table A A is updated |
??BB |
The latest update time that application data among the table BB is updated |
??...... |
??...... |
Be understandable that, last table is only for giving an example, it has reflected the corresponding relation between key field and the Value field, application scenario at other can similarly be set, in the key field, may also have other application data sheet, as CC, then in its corresponding Value field, should be corresponding " the latest update time that the application data among the table CC is updated "; When the table name of the application data classification chart of storing in the key field changed, its corresponding Value field was done corresponding the variation, does not give unnecessary details at this.
Described client 10 is used for the application request according to the user who receives, and determines the type of the application data that described application request is asked; From server 20, read the latest update time T 1 that the application data of described type is updated; The final updating time T 2 of T1 and the application data of the described type of self preserving relatively, the application data of synchronous described type, and, respond described application request according to the application data of the described type after synchronous.
The embodiment of the invention compared by the latest update time to the data type of client application, and do Synchronous Processing according to comparative result, make client obtain data as required, can guarantee data sync between multi-client, guarantee that each visit all can get access to latest data, save time simultaneously, reduce the EMS memory occupation space of system, improve systematic function.
With reference to Fig. 2, be the structural representation of the embodiment of a kind of server of the present invention; Server embodiment illustrated in fig. 2 can be the server among the system shown in Figure 1 embodiment 20, and as shown in Figure 2, described server 20 comprises: memory cell 201 and data synchronisation unit 202.
Described memory cell 201 is used to store all types of application datas, and stores client is upgraded operation to described all types of application data the latest update time;
In the specific implementation, as previously mentioned, because server 20 provides network necessary resource for client 10, therefore, there is mass data in the server 20, can be with various data qualifications, the standard of its classification can be used employed application data according to each of client 10, such as, when described client 10 needed inquiry good friend address, the application data that need to use this moment can be divided into address book managing application data class (Table A A); For another example, when described client 10 needed the inquiry chat record, the application data that needs to use can be divided into chat record managing application data class (table BB) or the like.
Particularly, described server 20 can be a database, and a table can be set in database, and described table can be established three fields, id, key, value.Wherein id represents from increasing field, promptly can be used for representing the sequence number of each operation, such as, client is designated as 1 when operating for the first time, and operation for the second time is designated as 2 or the like; Key represents the various classification of application data, and the form that every class application data can be shown is stored in the database, and key has promptly stored the table name of all kinds of tables, such as: stored the table name of address book managing application data table among the key, promptly represented with Table A A; Or the table name of chat record managing application data table, promptly represent or the like with table BB; What Value represented is the latest update time that all types of application datas is updated, such as, when client 10 has been upgraded application data among the Table A A, Value is composed the current time, be that the key value is in the record of " AA " in the database, corresponding Value value is the latest update time of " AA " class application data; Particularly, the table name of all types of application data in the described key field is corresponding one by one with the time value in the described value field, such as, the key value is the record of " AA ", a corresponding unique Value value, the key value is the record of " BB ", a corresponding unique Value value etc.Particularly, the corresponding relation of key and Value such as following table:
??Key |
??Value |
??AA |
The latest update time that application data among the Table A A is updated |
??BB |
The latest update time that application data among the table BB is updated |
??...... |
??...... |
Be understandable that, last table is only for giving an example, it has reflected the corresponding relation between key field and the Value field, application scenario at other can similarly be set, in the key field, may also have other application data sheet, as CC, then in its corresponding Value field, should be corresponding " the latest update time that the application data among the table CC is updated "; When the table name of the application data classification chart of storing in the key field changed, its corresponding Value field was done corresponding the variation, does not give unnecessary details at this.
Accordingly, the table name that writes down in the key field for all types of application datas, application data in the table of each table name correspondence then is stored in the described memory cell 201, in addition, Value value in the Value field of the table name correspondence of all types of application data that writes down among the key, be stored in simultaneously in the described memory cell 201, its Value value shows under the table name in the described key field of its correspondence, the latest update time that the application data in the table is updated.
Described data synchronisation unit 202, the type that is used for the application data of asking according to client, the latest update time T 1 of the application data of the described type of described memory cell 201 storages is sent to described client, and when T1 is later than the final updating time T 2 of application data of described type of described client stores, the application data of described type is sent to described client, so that the application data of the synchronous described type of described client.
The embodiment of the invention can guarantee data sync between multi-client, guarantees that each visit all can get access to latest data, saves time simultaneously, reduces the EMS memory occupation space of system, improves systematic function.
With reference to Fig. 3, be the structural representation of the embodiment of a kind of client of the present invention; Client embodiment illustrated in fig. 3 can be the client among the system shown in Figure 1 embodiment 10, as shown in Figure 3, described client 10 comprises: receiving element 101, determining unit 102, reading unit 103, comparing unit 104, lock unit 105 and response unit 106.
Described receiving element 101 is used to receive user's application request;
Described determining unit 102, the type of the application data that is used for determining that described application request is asked;
Further as shown in Figure 3, described client 10 also comprises: memory cell 107.
Described memory cell 107 is used to store final updating time of all types of application datas and described all types of application data.In the specific implementation, be analogous to the mode classification of the application data in the server, also there is mass data in the client, can corresponding in the server to the mode classification of described application data, client also can be with various data qualifications, and the standard of its classification can be used employed application data according to each of client equally, such as, when the user need inquire about the good friend address, the application data that need to use this moment can be divided into address book managing application data class (Table A A); For another example, when described user need inquire about chat record, the application data that needs to use can be divided into chat record managing application data class (table BB) or the like.In addition, the application data in the client also can be stored with the form of table, and its mode is analogous to the storage mode of the application data in the server, does not give unnecessary details at this.
From the above, described receiving element 101 receives the application request of the inquiry good friend address of described user's transmission, described determining unit 102 determines that promptly this type of using the application data of being asked is: address book managing application data class, i.e. AA class application data.
Described reading unit 103 is used for the type according to described application data, reads the latest update time T 1 that the application data of described type is updated from server; In the specific implementation, after described determining unit 102 determines that this type of using used application data is AA, described reading unit 103 promptly from the memory cell 201 of server 20 the key value for reading the Value value of AA in the pairing Value field of record of " AA ", be the latest update time that AA class application data is updated, available T1 represents.
Described comparing unit 104 is used for the final updating time T 2 of application data of the described type of comparison T1 and described client self storage; Particularly, after described reading unit 103 reads T1, described T1 is sent to described comparing unit 104, described comparing unit 104 reads the final updating time T 2 of the application data of described type from memory cell 107, afterwards, described comparing unit 104 compares T1 and T2.
Described lock unit 105 is used for according to described comparing unit 104 result relatively, the application data of synchronous described type;
With reference to Fig. 4, be the lock unit structural representation of the embodiment of a kind of client of the present invention; As shown in Figure 4, described lock unit 105 comprises: first lock unit 51 and second lock unit 52.
Described first lock unit 51 is used for when T1 is later than T2, visits the application data of the described type of described server, upgrades the application data of the described type of described client according to the application data of the described type of described server, and gives T2 with the value of T1;
Described second lock unit 52, be used for as T1 during early than T2, the application data of described type of self storage is sent to described server, and give T1 in the described server with the value of T2, so that described server upgrades the application data of the described type of described server according to the application data of the described type of described client.
Described response unit 106 is used for the application data according to the described type of described lock unit 105 after synchronously, responds described application request.In the specific implementation, after the application data of described type was carried out synchronously through described first lock unit 51, described response unit 106 used the application data of the described type after the described renewal to go to respond described application request; After the application data of described type was carried out synchronously through described second lock unit 52, described response unit 106 used the application data of the described type of described memory cell 107 storages to respond described application request.
1 application table AA is an example with client, if after described comparing unit 104 comparisons, described T1 is later than T2, promptly show after the final updating time T 2 of the AA class application data that described client 1 self is stored, be carved with Data Update during the T1 of Table A A after T2, then described first lock unit 51 is promptly visited the application data of the described type of described server, upgrade the application data of the AA class in the memory cell 107 of described client 1 according to the application data of the described type of described server, give T2 with the value of T1, and respond described application request according to the application data of the AA class of the described client 1 after upgrading; If after described comparing unit 104 comparisons, described T1 is early than T2, the application data that shows the AA class of self storing in described client 1 is newer than the application data of the AA class in the described server, promptly need to upgrade the application data of AA class in the described server, then described second lock unit 52 sends to described server with the application data of the AA class that described client 1 self is stored, and give T1 in the described server with the value of T2, described server upgrades the application data of the AA class of described server according to the application data of the AA class of described client 1, and described client 1 responds described application request according to the application data of the AA class of self storage.
In addition, if client has been upgraded the data of table BB, the data of showing BB have been upgraded such as client 2 or other clients N, and described client 1 determines that this application can not use the application data of table BB, be that described client 1 his-and-hers watches BB does not have relevant application to handle, the renewal of then described client 1 his-and-hers watches BB is lost interest in, and his-and-hers watches BB is left intact.
The embodiment of the invention compared by the latest update time to the data type of client application; and do Synchronous Processing according to comparative result; make client obtain data as required; can guarantee data sync between multi-client; guarantee that each visit all can get access to latest data; save time simultaneously, the protection system internal memory improves systematic function.
With reference to Fig. 5, be the flow chart of the embodiment of a kind of method that realizes multi-client data synchronization of the present invention; As shown in Figure 5, described method comprises:
S101, client receives user's application request, determines the type of the application data that described application request is asked;
In the specific implementation, be analogous to the mode classification of the application data in the server, also there is mass data in the client, can corresponding in the server to the mode classification of described application data, client also can be with various data qualifications, and the standard of its classification can be used employed application data according to each of client equally, such as, when the user need inquire about the good friend address, the application data that need to use this moment can be divided into address book managing application data class (Table A A); For another example, when described user need inquire about chat record, the application data that needs to use can be divided into chat record managing application data class (table BB) or the like.In addition, the application data in the client also can be stored with the form of table, and its mode is analogous to the storage mode of the application data in the server, does not give unnecessary details at this.
From the above, described client receives the application request of the inquiry good friend address of user's transmission, determines that promptly this type of using the application data of being asked is: address book managing application data class, i.e. AA class application data.
S102, according to the type of described application data, described client reads the latest update time T 1 that the application data of described type is updated from server; In the specific implementation, the executive agent of described S102 can be the reading unit 103 of the embodiment of client 10 shown in Figure 3.Particularly, the type of the application data of being asked according to determined this application request of S101 is AA, then among the S102, the reading unit 103 of described client 10 promptly from the memory cell 201 of server 20 the key value for reading the Value value of AA in the pairing Value field of record of " AA ", be the latest update time that AA class application data is updated, available T1 represents.
S103, the final updating time T 2 of the application data of the described type of described client comparison T1 and self storage, according to the result of described comparison, the application data of synchronous described type, and, respond described application request according to the application data of the described type after synchronously.
In the specific implementation, the executive agent of described S103 can be comparing unit 104, the lock unit 105 of client embodiment illustrated in fig. 3 10, and response unit 106.Concrete, described S103 comprises:
If T1 is later than T2, the application data of the described type of the described server of described client-access, upgrade the application data of the described type of described client according to the application data of the described type of described server, give T2 with the value of T1, and respond described application request according to the application data of the described type of the described client after upgrading;
If T1 is early than T2, described client sends to described server with the application data of the described type that self stores, and give T1 in the described server with the value of T2, described server upgrades the application data of the described type of described server according to the application data of the described type of described client, and described client responds described application request according to the application data of the described type of self storage.
1 application table AA is an example with client, if after relatively, described T1 is later than T2, promptly show after the final updating time T 2 of the AA class application data that described client 1 self is stored, be carved with Data Update during the T1 of Table A A after T2, then described client is promptly visited the application data of the described type of described server, upgrade the application data of the AA class in the described client 1 according to the application data of the described type of described server, give T2 with the value of T1, and respond described application request according to the application data of the AA class of the described client 1 after upgrading; If after relatively, described T1 is early than T2, the application data that shows the AA class of self storing in described client 1 is newer than the application data of the AA class in the described server, promptly need to upgrade the application data of AA class in the described server, then described client 1 sends to described server with the application data of the AA class that self stores, and give T1 in the described server with the value of T2, described server upgrades the application data of the AA class of described server according to the application data of the AA class of described client 1, and described client 1 responds described application request according to the application data of the AA class of self storage.
In addition, if client has been upgraded the data of table BB, the data of showing BB have been upgraded such as client 2 or other clients N, and described client 1 determines that this application can not use the application data of table BB, be that described client 1 his-and-hers watches BB does not have relevant application to handle, the renewal of then described client 1 his-and-hers watches BB is lost interest in, and his-and-hers watches BB is left intact.
The embodiment of the invention compared by the latest update time to the data type of client application, and do Synchronous Processing according to comparative result, make client obtain data as required, can guarantee data sync between multi-client, guarantee that each visit all can get access to latest data, save time simultaneously, reduce the EMS memory occupation space of system, improve systematic function.
Above disclosed only is a kind of preferred embodiment of the present invention, certainly can not limit the present invention's interest field with this, one of ordinary skill in the art will appreciate that all or part of flow process that realizes the foregoing description, and, still belong to the scope that invention is contained according to the equivalent variations that claim of the present invention is done.