WO2022228125A1 - Data synchronization method and apparatus - Google Patents

Data synchronization method and apparatus Download PDF

Info

Publication number
WO2022228125A1
WO2022228125A1 PCT/CN2022/086611 CN2022086611W WO2022228125A1 WO 2022228125 A1 WO2022228125 A1 WO 2022228125A1 CN 2022086611 W CN2022086611 W CN 2022086611W WO 2022228125 A1 WO2022228125 A1 WO 2022228125A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
user
social
version number
change
Prior art date
Application number
PCT/CN2022/086611
Other languages
French (fr)
Chinese (zh)
Inventor
谭谦
林�源
王儒林
陈晓斌
董燕萍
代磊
Original Assignee
支付宝(杭州)信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022228125A1 publication Critical patent/WO2022228125A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Systems or methods specially adapted for specific business sectors, e.g. utilities or tourism
    • G06Q50/01Social networking

Definitions

  • the embodiments of this specification relate to the field of computer technologies, and in particular, to a data synchronization method.
  • One or more embodiments of this specification simultaneously relate to a data synchronization apparatus, a computing device, and a computer-readable storage medium.
  • An instant messaging tool is a tool for online chatting and communication through instant messaging technology.
  • instant messaging tools also play an important role in the operation of e-commerce websites.
  • the user's social data is usually stored on the server. After a user modifies his social data (such as nickname, avatar, etc.), the server needs to synchronize the modification result of the user's social data to other associations.
  • the user terminal may have many influencing factors such as network traffic, uncertain signal quality, etc., making it difficult to synchronize and manage social data. If the user's friends If the number is large and the social relationship is more complex, it will face the problems of large amount of data to be updated, slow processing speed, and untimely data update.
  • the embodiments of this specification provide a data synchronization method.
  • One or more embodiments of this specification simultaneously relate to a data synchronization apparatus, a computing device, and a computer-readable storage medium, so as to solve the technical defects existing in the prior art.
  • a data synchronization method including: collecting social change data of a first user, and updating a data version number corresponding to the social change data to generate a target data version number; Collect the data version number corresponding to the social data associated with the social change data of the second user; compare the data version number corresponding to the social data with the target data version number; if the comparison is inconsistent, The target data version number and the social change data are synchronized to the second user as incremental data.
  • the data synchronization method further includes: receiving a data modification instruction submitted by a first user for the social data to be modified; updating the social data to be modified according to the data modification information carried in the data modification instruction; Synchronizing the update result of the data to be modified to the second user.
  • the method further includes: updating the first user's first user's social data based on an update result of the social data to be modified.
  • a data version number corresponding to the social data is updated to generate a first data version number corresponding to the first social data of the first user.
  • the data synchronization method further includes: determining at least one second user who has a social relationship with the first user; There is second social sub-data with an associated relationship, and the second data sub-version number corresponding to the second social sub-data is determined; it is determined that the first social data of the first user is associated with the second social sub-data the first social sub-data of the relationship, and determine the first data sub-version number corresponding to the first social sub-data; compare the first data sub-version number with the second data sub-version number; In the case of inconsistency, the first data sub-version number and the first social sub-data corresponding to the first data sub-version number are synchronized to the second user as incremental data.
  • the method further includes: determining at least one second user that has a social relationship with the first user; detecting all the first login status of the at least one second user; if the first login status of the at least one second user is logged in, execute the process of converting the target data version number and all and the step of synchronizing the social change data to the second user as incremental data.
  • the data synchronization method further includes: if the login status of the at least one second user is not logged in, in the case of inconsistency in the comparison, changing the version number of the target data and the social change data. Store as incremental data; detect the second login status of the at least one second user; if the second login status of the at least one second user is logged in, synchronize the incremental data to the second login status of the at least one second user Two users.
  • the method further includes: if the second login status of the at least one second user is logged in, detecting the data of the incremental data. If the data amount of the incremental data is greater than the preset data amount threshold, send a data synchronization instruction to the at least one second user; in response to the data synchronization request sent by the at least one second user, the Incremental data is synchronized to the at least one second user.
  • the method further includes: determining a data change frequency of the first social data of the first user; if the If the data change frequency is greater than the preset change frequency threshold, the target data version number and the social change data are stored as incremental data; when it is detected that the data volume of the incremental data is greater than the preset data volume threshold Next, determine at least one second user that has a social relationship with the first user, and send a data synchronization instruction to the at least one second user; in response to the data synchronization request sent by the at least one second user, The incremental data is synchronized to the at least one second user.
  • the updating the data version number corresponding to the social change data includes: determining a change time corresponding to the social change data; and updating the data version number based on the change time.
  • the synchronizing the target data version number and the social change data to the second user as incremental data includes: establishing a long connection with the user terminal of the second user, The connection synchronizes the target data version number and the social change data to the user terminal to synchronize the target data version number and the social change data to the second user as incremental data.
  • a data synchronization apparatus including: a first collection module configured to collect social change data of a first user, and perform a data version number corresponding to the social change data. updating, generating a target data version number; a second collection module, configured to collect a data version number corresponding to the social data associated with the social change data of the second user; a comparison module, configured to correspond to the social data The data version number is compared with the target data version number; the synchronization module is configured to synchronize the target data version number and the social change data as incremental data to the second user.
  • a computing device including: a memory and a processor; the memory is used for storing computer-executable instructions, and the processor is used for executing the computer-executable instructions: collecting the first The social change data of a user, and the data version number corresponding to the social change data is updated to generate a target data version number; the data version number corresponding to the social data associated with the social change data of the second user is collected; The data version number corresponding to the social data is compared with the target data version number; if the comparison is inconsistent, the target data version number and the social change data are synchronized as incremental data to the Two users.
  • a computer-readable storage medium which stores computer-executable instructions, and when the instructions are executed by a processor, implements the steps of the data synchronization method.
  • An embodiment of this specification collects the social change data of the first user, updates the data version number corresponding to the social change data, generates a target data version number, and collects the social change data of the second user associated with the social change data.
  • the data version number corresponding to the data, the data version number corresponding to the social data is compared with the target data version number, and if the comparison is inconsistent, the target data version number and the social change data are used as Incremental data is synchronized to the second user.
  • a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
  • Fig. 1 is a processing flow chart of a data synchronization method provided by an embodiment of this specification
  • FIG. 2 is an interactive schematic diagram of a data synchronization process provided by an embodiment of this specification
  • FIG. 3 is a schematic diagram of a data synchronization apparatus provided by an embodiment of the present specification.
  • FIG. 4 is a structural block diagram of a computing device provided by an embodiment of the present specification.
  • IM refers to instant messaging (Instant Messaging)
  • IM service is to provide instant messaging services.
  • Social relationship mainly refers to friend relationship, group relationship.
  • IM function A very important function point in the IM function is the synchronization and management of social relations. Due to the presence of many influencing factors such as network traffic and uncertain signal quality on the client side, it is difficult to synchronize and manage social relationships.
  • an embodiment of this specification provides a data synchronization method, which is applied to a server, and generates a target data version number by collecting social change data of a first user, and updating the data version number corresponding to the social change data. Collect the data version number corresponding to the social data associated with the social change data of the second user, compare the data version number corresponding to the social data with the target data version number, and in the case of inconsistent comparison, The target data version number and the social change data are synchronized to the second user as incremental data.
  • the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user, which can take into account the network traffic and ensure that different The consistency of social data among users, the correctness of social relations, and the timeliness of social data updates.
  • a data synchronization method is provided, and this specification also relates to a data synchronization apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
  • FIG. 1 shows a processing flow chart of a data synchronization method provided according to an embodiment of the present specification, including steps 102 to 108 .
  • Step 102 Collect social change data of the first user, update the data version number corresponding to the social change data, and generate a target data version number.
  • the data synchronization method provided in the embodiment of this specification is applied to the server. Since the social relationship of the user is usually complicated, in order to ensure the social data of the first user stored in the user terminals of other users who have a social relationship with the first user If it is consistent with the real social data of the first user, the server needs to collect the social change data of the first user, and synchronize the change data to the relevant second user.
  • the social data described in the embodiments of this specification includes but is not limited to the user name, user avatar, user profile, and group data that the user joins in the user's social application; the social change data may include Modified and changed social data, as well as the modification time of social data and other information.
  • the user name, user avatar, user profile, and group data that the user joins included in the social data correspond to different data categories, that is, the user name corresponds to data category 1, and the user avatar corresponds to Data category 2 and user profile correspond to data category 3, etc.
  • the social data of each data category corresponds to an initial data version number.
  • the server After collecting the social change data of the first user, that is, the modified and changed social data, the server can set a data version number for the social change data, specifically, update the version number corresponding to the social change data ( The initial data version number corresponding to the data category of the social change data is updated), and the target data version number is generated.
  • the update of the initial data version number can be used to indicate that the social data of the user has changed, and the social change data
  • the target data version number can be used as the initial data version number, so that when the user modifies the social change data, the aforementioned data version number corresponding to the social change data is executed. process of updating.
  • the first user modifies the user name.
  • the user name of the first user is U10, and the corresponding initial data version number is V10.
  • the user name of the first user is U11, and the corresponding data version number is Can be updated to V11.
  • V11 can be used as the initial data version number of the data category corresponding to the user name.
  • the data version number corresponding to the social change data is updated, that is, the change time corresponding to the social change data is determined, and the data version number is updated based on the change time.
  • the change time (modification time) of the social change data may be used to update the data version number corresponding to the social change data, and specifically, the change time may be used as the target data version number corresponding to the social change data , wherein the change time can be obtained from the social change data.
  • a target algorithm (such as a hash algorithm) may also be used to process the social data, and the processing result may be used as the initial data version number of the social data, and the target algorithm may be used to process the social change data to generate The target data version number corresponding to the social change data.
  • Step 104 Collect the data version number of the second user corresponding to the social data associated with the social change data.
  • a second user associated with the social change data to be synchronized may be determined. For example, if the collected social change data is that the user name is changed to U11, it is determined that the second user associated with the social change data to be synchronized is all users who have social relations with the first user (the first user All friends and all groups joined by the first user); if the collected social change data is that the user joins the group G1, then it is determined that the second user associated with the social change data to be synchronized is the group Other users in G1 except the first user.
  • the data version number corresponding to the social data associated with the social change data of the second user can be collected. After a certain social data of the user is changed, in order to reduce the workload and resource consumption of the server, in practical applications, only the social data associated with the social change data in the social data of the second user can be selected to be updated, that is, the collection. The data version number of the second user corresponding to the social data associated with the social change data, and the data version number is compared with the target data version number to determine whether the social data of the second user needs to be updated.
  • the first user modifies the user name
  • the user name of the first user is U11
  • the corresponding data version number is updated to V11.
  • the data version number of the second user corresponding to the social data associated with the social change data may be collected, specifically collecting the user name of the first user stored in the user terminal of the second user, and collecting the first user's username.
  • a data version number corresponding to the user name of a user so as to compare the data version number with the update result V11 of the aforementioned data version number to determine whether it is necessary to update the first user stored in the user terminal of the second user user name to update.
  • Step 106 Compare the data version number corresponding to the social data with the target data version number.
  • the data version number corresponding to the social change data of the first user is updated, the target data version number is generated, and the data corresponding to the social data associated with the social change data of the second user is collected and obtained After the version number is obtained, the data version number can be compared with the target data version number corresponding to the social data of the same category to determine whether the social data of the second user needs to be updated.
  • Step 108 in the case of inconsistent comparison, synchronize the target data version number and the social change data to the second user as incremental data.
  • the data version number and the target data version number are compared to obtain a corresponding comparison result. If it is determined that the comparison between the two is inconsistent according to the comparison result, the social change data of the first user and the social change data are corresponding The version number of the target data is synchronized to the second user as incremental data; if it is determined according to the comparison result that the two are consistent, there is no need to synchronize the social change data to the second user.
  • the server can synchronize social change data to the second user through a persistent connection. Therefore, the synchronization of the target data version number and the social change data as incremental data to the second user is specifically: establishing a long connection with the user terminal of the second user, and synchronizing the target data version number and the social change data to the user terminal through the long connection, so that the target data version number and the social The change data is synchronized to the second user as incremental data, so that the social data of the first user stored in the user terminal of the second user is consistent with the actual social data of the first user.
  • a data version number is set for the user's social data, and the data version number corresponding to the social change data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category.
  • the server can also receive a data modification instruction submitted by the first user for the social data to be modified, update the social data to be modified according to the data modification information carried in the data modification instruction, and update the social data to be modified.
  • the update result of the data to be modified is synchronized to the second user.
  • the first user when the first user needs to modify his social data such as user name, user avatar, user profile and other social data in the social application, he can send a data modification instruction to the server, and the data carried in the data modification instruction is to modify the data.
  • the information may specifically include the social data to be modified and the data modification result of the social data to be modified; the server can update the social data to be modified of the first user according to the data modification information, and synchronize the update result to the second user.
  • User that is, the server actively synchronizes the social change data of the first user to the second user.
  • the method further includes: updating the first social data of the first user based on the update result of the social data to be modified.
  • the corresponding data version number is updated to generate a first data version number corresponding to the first social data of the first user.
  • the method further includes: determining at least one second user who has a social relationship with the first user; obtaining the at least one first user.
  • the second social sub-data associated with the first user in the second social data of the two users, and the second data sub-version number corresponding to the second social sub-data is determined;
  • a first social sub-data in social data that has an associated relationship with the second social sub-data, and a first data sub-version number corresponding to the first social sub-data is determined;
  • the first data sub-version number is combined with The second data sub-version number is compared; in the case of inconsistent comparison, the first data sub-version number and the first social sub-data corresponding to the first data sub-version number are synchronized as incremental data to the second user.
  • the server compares the target data version number corresponding to the social change data of the first user with the data version number corresponding to the social data associated with the social change data in the social data of the second user to determine whether the social change data needs to be synchronized to the second user.
  • the server chooses to actively synchronize the social change data of the first user to the second user who has a social relationship with the first user.
  • this synchronization process there may be network or other reasons.
  • data synchronization fails.
  • the server can update the data version number corresponding to the first social data of the first user based on the update result, and generate a corresponding version of the first social data of the first user. Specifically, based on the update result, the data version number corresponding to the social change data in the first social data of the first user is updated, and the update result of the data version number is removed from the first social data.
  • the data version numbers corresponding to other social data other than the social change data together form a first data version number corresponding to the first social data of the first user.
  • the server may determine a second user (a friend of the first user, or in the same group as the first user, etc.) who has a social relationship with the first user, and obtain the relationship between the second user and the first user.
  • the social data (second social sub-data, for example, the user name, user avatar, user profile and other information of the first user stored in the user terminal of the second user), and determine that these social data correspond to the data version numbers (No. 2 data subversion number).
  • a user's user name, user avatar, and user profile after determining the first social sub-data and the first data sub-version number corresponding to the first social sub-data, and comparing the first data sub-version number with the same category
  • the second data sub-version number corresponding to the second social sub-data is compared, and in the case of inconsistent comparison, the first data sub-version number and the first social sub-version number corresponding to the first data sub-version number are compared.
  • the data is synchronized to the second user as incremental data.
  • the premise that the server can successfully synchronize data to the second user is that the account of the social application of the second user is in a logged-in state (online).
  • the login status of the second user can be specifically implemented by: determining at least one second user that has a social relationship with the first user; detecting the first login status of the at least one second user; The first login status of the two users is logged in, and if the comparison is inconsistent, the target data version number and the social change data are synchronized to the second user as incremental data.
  • the target data version number and the social change data are stored as incremental data;
  • the social change data is synchronized to The second user is sufficient; if the login status of the second user is not logged in (offline), in this case, it is also necessary to determine whether data synchronization needs to be performed with the second user according to the comparison result. Then the social change data needs to be stored.
  • the social data may be processed using a target algorithm (eg, a hash algorithm), and the processing result may be used as an initial data version number of the social data, and the social change data may be processed using the target algorithm , and generate the target data version number corresponding to the social change data; or, the change time of the social change data may be used as the target data version number corresponding to the social change data.
  • a target algorithm eg, a hash algorithm
  • a target algorithm such as a hash algorithm
  • the target algorithm is used to compare the two The hash value (initial data version number and target data version number) generated by processing by the user will be consistent; or, if the change time of social data or social change data is used as the data version number, only the social change Only when the data and social data are changed at the same time will the comparison be consistent.
  • the comparison is inconsistent, it means that the social data associated with the social change data of the second user is inconsistent with the social change data of the first user, and data synchronization needs to be performed, that is, the social change data needs to be synchronized to the second user. user.
  • the social change data and the version number of the target data are directly synchronized to the second user; If the user's login status is not logged in (offline), if the comparison is inconsistent, the social change data and the version number of the target data need to be stored, and continue to detect the login status of the second user. The next time the user logs in, the stored social change data is synchronized to the second user.
  • the target data version number and the social change data are stored as incremental data, and the detection is continued.
  • the data volume of the stored incremental data can be detected; if the data volume of the incremental data is greater than the preset data volume threshold, sending a data synchronization instruction to the at least one second user; and synchronizing the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
  • the server can send the social change data to the second user through a persistent connection, but when the second user is not logged in, the server needs to store the social change data, and when the second user goes online again After that, the stored social change data is synchronized to the second user; however, when the data volume of the social change data stored by the server is greater than the preset data volume threshold, in order to reduce the data transmission pressure on the server, the server can send the data to the second user.
  • the second user sends a data synchronization instruction, and the second user actively pulls the social change data from the server.
  • the synchronization of the social change data may also be determined by determining the data change frequency of the first social data of the first user Specifically, it can be implemented in the following ways: determining the data change frequency of the first social data of the first user; if the data change frequency is greater than a preset change frequency threshold, then the target data version number and the social
  • the change data is stored as incremental data; when it is detected that the data volume of the incremental data is greater than the preset data volume threshold, determine at least one second user who has a social relationship with the first user, and report to all
  • the at least one second user sends a data synchronization instruction; and in response to a data synchronization request sent by the at least one second user, the incremental data is synchronized to the at least one second user.
  • the server can send the social change data to the second user through a long connection, but if the data change frequency of the first social data of the first user is higher than the preset threshold, if the server uses the long connection in batches Sending social change data to the second user has the defect of low data synchronization efficiency. Therefore, in the case where the data change frequency of the first social data of the first user is higher than the preset threshold, the server can choose to send the social change data Store it, and when the stored social change data reaches the preset data volume threshold, synchronize the stored social change data to the second user; or issue a pull instruction for the social change data to the second user. The second user does a full pull of social change data to achieve data synchronization.
  • the server when a user's social data changes, such as the addition of friends, the modification of friends' nicknames, the change of group members, etc., the server will incrementally push the changed data to other users through a long connection. To ensure the synchronization of social data of different users.
  • the combination of incremental data synchronization by the server and data pulling by the user is beneficial to ensure the correctness and timeliness of the data synchronization results, and is beneficial to reduce the data transmission pressure on the server.
  • a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
  • the data synchronization method is further described below by taking the application of the data synchronization method provided in this specification in a social scene as an example with reference to FIG. 2 .
  • 2 shows an interactive schematic diagram of a data synchronization process provided by an embodiment of the present specification, and the specific steps include steps 202 to 228 .
  • Step 202 the first client sends a data modification instruction to the server.
  • Step 204 The server updates the social data to be modified according to the data modification information carried in the data modification instruction, and updates the data version number corresponding to the social data to be modified based on the update result of the social data to be modified.
  • Step 206 the server synchronizes the update result of the data to be modified and the update result of the data version number to the second client.
  • Step 208 the second client stores the update result of the data to be modified and the update result of the data version number.
  • Step 210 The server collects the social change data of the first client, and updates the data version number corresponding to the social change data to generate a target data version number.
  • Step 212 the server collects the data version number corresponding to the social data associated with the social change data of the second client.
  • Step 214 the server compares the data version number corresponding to the social data with the target data version number.
  • Step 216 in the case of inconsistent comparison, the server synchronizes the target data version number and the social change data to the second user as incremental data.
  • Step 220 the server determines the data change frequency of the first social data of the first client, and in the case that the data change frequency is greater than the preset change frequency threshold, the target data version number and the social change data are used as Incremental data is stored.
  • Step 222 when detecting that the data volume of the incremental data is greater than a preset data volume threshold, the server determines at least one second user who has a social relationship with the first user, and reports to the at least one first user. Two users send data synchronization instructions.
  • Step 224 the server receives the data synchronization request sent by the second client.
  • a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
  • the present specification also provides an embodiment of a data synchronization apparatus
  • FIG. 3 shows a schematic diagram of a data synchronization apparatus provided by an embodiment of the present specification.
  • the device includes: a first collection module 302, configured to collect social change data of the first user, update the data version number corresponding to the social change data, and generate a target data version number;
  • the second collection module 304 is configured to collect the data version number corresponding to the social data associated with the social change data of the second user;
  • the comparison module 306 is configured to compare the data version number corresponding to the social data with the The target data version numbers are compared;
  • the synchronization module 308 is configured to synchronize the target data version numbers and the social change data to the second user as incremental data if the comparison is inconsistent.
  • the data synchronization device further includes: an instruction receiving module, configured to receive a data modification instruction submitted by the first user for the social data to be modified; an update module, configured to modify the instruction according to the data carried in the instruction The data modification information of the to-be-modified social data is updated; the update result synchronization module is configured to synchronize the update result of the to-be-modified data to the second user.
  • an instruction receiving module configured to receive a data modification instruction submitted by the first user for the social data to be modified
  • an update module configured to modify the instruction according to the data carried in the instruction
  • the data modification information of the to-be-modified social data is updated
  • the update result synchronization module is configured to synchronize the update result of the to-be-modified data to the second user.
  • the data synchronization apparatus further includes: a version number update module configured to update the data version number corresponding to the first social data of the first user based on the update result of the social data to be modified, A first data version number corresponding to the first social data of the first user is generated.
  • a version number update module configured to update the data version number corresponding to the first social data of the first user based on the update result of the social data to be modified, A first data version number corresponding to the first social data of the first user is generated.
  • the data synchronization apparatus further includes: a user determination module configured to determine at least one second user who has a social relationship with the first user; a data acquisition module configured to acquire the at least one first user The second social sub-data that is associated with the first user in the second social data of the two users, and the second data sub-version number corresponding to the second social sub-data is determined; the data determination module is configured to determine The first social sub-data that has an associated relationship with the second social sub-data in the first social data of the first user, and the first data sub-version number corresponding to the first social sub-data is determined; The pairing module is configured to compare the first data sub-version number with the second data sub-version number; the data synchronization module is configured to compare the first data sub-version number when the comparison is inconsistent. The version number and the first social sub-data corresponding to the first data sub-version number are synchronized to the second user as incremental data.
  • the data synchronization apparatus further includes: a second user determination module configured to determine at least one second user who has a social relationship with the first user; a first login status detection module configured to detect The first login state of the at least one second user; if the operation result of the first login state detection module is logged in, the synchronization module is executed.
  • the data synchronization device further includes: if the operation result of the first login status detection module is not logged in, then running a storage module; the storage module is configured to be in the case of inconsistent comparison, The target data version number and the social change data are stored as incremental data; the second login state detection module is configured to detect the second login state of the at least one second user; if the second login If the operation result of the status detection module is that the user is logged in, the first incremental data synchronization module is executed; the first incremental data synchronization module is configured to synchronize the incremental data to the second user.
  • the data synchronization device further includes: if the operation result of the second login status detection module is logged in, running a data volume detection module; the data volume detection module is configured to detect the increase If the data volume of the incremental data is greater than the preset data volume threshold, the synchronization command sending module is run; the synchronization command sending module is configured to send data synchronization to the at least one second user an instruction; a second incremental data synchronization module configured to synchronize the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
  • the data synchronization apparatus further includes: a data change frequency determination module configured to determine the data change frequency of the first social data of the first user; if the data change frequency is greater than a preset change frequency threshold , then run the storage module; the storage module is configured to store the target data version number and the social change data as incremental data; the instruction sending module is configured to detect the incremental data When the data volume is greater than the preset data volume threshold, determine at least one second user that has a social relationship with the first user, and send a data synchronization instruction to the at least one second user; a third incremental data synchronization module is configured to synchronize the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
  • a data change frequency determination module configured to determine the data change frequency of the first social data of the first user; if the data change frequency is greater than a preset change frequency threshold , then run the storage module; the storage module is configured to store the target data version number and the social change data as incremental data; the instruction
  • the first collection module includes: a determination sub-module configured to determine a change time corresponding to the social change data; an update sub-module configured to perform an update on the data version number based on the change time. renew.
  • the synchronization module includes: a synchronization sub-module configured to establish a long connection with the user terminal of the second user, and to synchronize the target data version number and the social change data through the long connection to the user terminal, so as to synchronize the target data version number and the social change data to the second user as incremental data.
  • a synchronization sub-module configured to establish a long connection with the user terminal of the second user, and to synchronize the target data version number and the social change data through the long connection to the user terminal, so as to synchronize the target data version number and the social change data to the second user as incremental data.
  • the above is a schematic solution of a data synchronization apparatus according to this embodiment. It should be noted that the technical solution of the data synchronization device and the technical solution of the above-mentioned data synchronization method belong to the same concept, and the details that are not described in detail in the technical solution of the data synchronization device can be referred to the description of the technical solution of the above-mentioned data synchronization method. .
  • FIG. 4 shows a structural block diagram of a computing device 400 provided according to an embodiment of the present specification.
  • Components of the computing device 400 include, but are not limited to, memory 410 and processor 420 .
  • the processor 420 is connected with the memory 410 through the bus 430, and the database 450 is used for saving data.
  • Computing device 400 also includes access device 440 that enables computing device 400 to communicate via one or more networks 460 .
  • networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet.
  • Access device 440 may include one or more of any type of network interface (eg, network interface card (NIC)), wired or wireless, such as IEEE 802.11 wireless local area network (WLAN) wireless interface, World Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and the like.
  • NIC network interface card
  • computing device 400 may also be connected to each other, such as through a bus.
  • bus may also be connected to each other, such as through a bus.
  • FIG. 4 the structural block diagram of the computing device shown in FIG. 4 is only for the purpose of example, rather than limiting the scope of this specification. Those skilled in the art can add or replace other components as required.
  • Computing device 400 may be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (eg, tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (eg, smart phones) ), wearable computing devices (eg, smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs.
  • Computing device 400 may also be a mobile or stationary server.
  • the memory 410 is used for storing computer-executable instructions
  • the processor 420 is used for executing the following computer-executable instructions: collecting social change data of the first user, and updating the data version number corresponding to the social change data, generating a target data version number; collecting a data version number corresponding to the social data associated with the social change data of the second user; comparing the data version number corresponding to the social data with the target data version number; In the case of inconsistency, the target data version number and the social change data are synchronized to the second user as incremental data.
  • the above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned data synchronization method belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned data synchronization method.
  • An embodiment of the present specification further provides a computer-readable storage medium, which stores computer instructions, which are used to implement the steps of the data synchronization method when the instructions are executed by a processor.
  • the above is a schematic solution of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the above-mentioned data synchronization method belong to the same concept, and the details not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the above-mentioned data synchronization method.
  • the computer instructions include computer program code, which may be in source code form, object code form, an executable file, some intermediate form, or the like.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable media may 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, the computer-readable media Electric carrier signals and telecommunication signals are not included.

Abstract

A data synchronization method and apparatus. The data synchronization method comprises: acquiring social change data of a first user, and updating a data version number corresponding to the social change data to generate a target data version number (102); acquiring a data version number of a second user corresponding to social data associated with the social change data (104); comparing the data version number corresponding to the social data with the target data version number (106); and if the two are inconsistent, synchronizing the target data version number and the social change data to the second user as incremental data (108).

Description

数据同步的方法以及装置Method and device for data synchronization 技术领域technical field
本说明书实施例涉及计算机技术领域,特别涉及一种数据同步方法。本说明书一个或者多个实施例同时涉及一种数据同步装置,一种计算设备,以及一种计算机可读存储介质。The embodiments of this specification relate to the field of computer technologies, and in particular, to a data synchronization method. One or more embodiments of this specification simultaneously relate to a data synchronization apparatus, a computing device, and a computer-readable storage medium.
背景技术Background technique
随着移动互联网的发展,很多即时通讯工具也随之出现在用户的生活中。即时通讯工具是通过即时通讯技术来实现在线聊天、交流的工具。目前,即时通讯工具除可用于存在社交关系的好友间的日常沟通外,其在电子商务网站运营过程中也起到了重要的作用。With the development of the mobile Internet, many instant messaging tools also appear in users' lives. An instant messaging tool is a tool for online chatting and communication through instant messaging technology. At present, in addition to being used for daily communication among friends who have social relationships, instant messaging tools also play an important role in the operation of e-commerce websites.
实际应用中,用户的社交数据通常会存储到于服务端,在某一用户修改自身的社交数据(例如,昵称、头像等)后,服务端需将该用户社交数据的修改结果同步至其他关联的用户,以保证不同用户间社交数据的一致性,但由于用户的用户终端可能存在网络流量、信号质量不确定等诸多影响因素,使得对社交数据的同步及管理存在一定难度,如果用户的好友数量较多,社交关系较为复杂,则会面临待更新数据量大、处理速度慢、数据更新不及时的问题。In practical applications, the user's social data is usually stored on the server. After a user modifies his social data (such as nickname, avatar, etc.), the server needs to synchronize the modification result of the user's social data to other associations. In order to ensure the consistency of social data among different users, the user terminal may have many influencing factors such as network traffic, uncertain signal quality, etc., making it difficult to synchronize and manage social data. If the user's friends If the number is large and the social relationship is more complex, it will face the problems of large amount of data to be updated, slow processing speed, and untimely data update.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本说明书实施例提供了一种数据同步方法。本说明书一个或者多个实施例同时涉及一种数据同步装置,一种计算设备,以及一种计算机可读存储介质,以解决现有技术中存在的技术缺陷。In view of this, the embodiments of this specification provide a data synchronization method. One or more embodiments of this specification simultaneously relate to a data synchronization apparatus, a computing device, and a computer-readable storage medium, so as to solve the technical defects existing in the prior art.
根据本说明书实施例的第一方面,提供了一种数据同步方法,包括:采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。According to a first aspect of the embodiments of this specification, a data synchronization method is provided, including: collecting social change data of a first user, and updating a data version number corresponding to the social change data to generate a target data version number; Collect the data version number corresponding to the social data associated with the social change data of the second user; compare the data version number corresponding to the social data with the target data version number; if the comparison is inconsistent, The target data version number and the social change data are synchronized to the second user as incremental data.
可选地,所述数据同步方法,还包括:接收第一用户针对待修改社交数据提交的数据修改指令;根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新;将所述待修改数据的更新结果同步至第二用户。Optionally, the data synchronization method further includes: receiving a data modification instruction submitted by a first user for the social data to be modified; updating the social data to be modified according to the data modification information carried in the data modification instruction; Synchronizing the update result of the data to be modified to the second user.
可选地,所述根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新之后,还包括:基于所述待修改社交数据的更新结果对所述第一用户的第一社交数据对应的数据版本号进行更新,生成所述第一用户的第一社交数据对应的第一数据版本号。Optionally, after updating the social data to be modified according to the data modification information carried in the data modification instruction, the method further includes: updating the first user's first user's social data based on an update result of the social data to be modified. A data version number corresponding to the social data is updated to generate a first data version number corresponding to the first social data of the first user.
可选地,所述数据同步方法,还包括:确定与所述第一用户存在社交关系的至少一个第二用户;获取所述至少一个第二用户的第二社交数据中与所述第一用户存在关联关系的第二社交子数据,并确定所述第二社交子数据对应的第二数据子版本号;确定所述第一用户的第一社交数据中与所述第二社交子数据存在关联关系的第一社交子数据,并确定所述第一社交子数据对应的第一数据子版本号;将所述第一数据子版本号与所述第二数据子版本号进行比对;在比对不一致的情况下,将所述第一数据子版本号以及所述第一数据子版本号对应的第一社交子数据作为增量数据同步至所述第二用户。Optionally, the data synchronization method further includes: determining at least one second user who has a social relationship with the first user; There is second social sub-data with an associated relationship, and the second data sub-version number corresponding to the second social sub-data is determined; it is determined that the first social data of the first user is associated with the second social sub-data the first social sub-data of the relationship, and determine the first data sub-version number corresponding to the first social sub-data; compare the first data sub-version number with the second data sub-version number; In the case of inconsistency, the first data sub-version number and the first social sub-data corresponding to the first data sub-version number are synchronized to the second user as incremental data.
可选地,所述将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后,还包括:确定与所述第一用户存在社交关系的至少一个第二用户;检测所述至少一个第二用户的第一登录状态;若所述至少一个第二用户的第一登录状态为已登录,则执行所述在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户的步骤。Optionally, after comparing the data version number corresponding to the social data with the target data version number, the method further includes: determining at least one second user that has a social relationship with the first user; detecting all the first login status of the at least one second user; if the first login status of the at least one second user is logged in, execute the process of converting the target data version number and all and the step of synchronizing the social change data to the second user as incremental data.
可选地,所述数据同步方法,还包括:若所述至少一个第二用户的登录状态为未登录,则在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;检测所述至少一个第二用户的第二登录状态;若所述至少一个第二用户的第二登录状态为已登录,则将所述增量数据同步至所述第二用户。Optionally, the data synchronization method further includes: if the login status of the at least one second user is not logged in, in the case of inconsistency in the comparison, changing the version number of the target data and the social change data. Store as incremental data; detect the second login status of the at least one second user; if the second login status of the at least one second user is logged in, synchronize the incremental data to the second login status of the at least one second user Two users.
可选地,所述检测所述至少一个第二用户的第二登录状态之后,还包括:若所述至少一个第二用户的第二登录状态为已登录,则检测所述增量数据的数据量;若所述增量数据的数据量大于预设数据量阈值,则向所述至少一个第二用户发送数据同步指令;响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。Optionally, after the detecting the second login status of the at least one second user, the method further includes: if the second login status of the at least one second user is logged in, detecting the data of the incremental data. If the data amount of the incremental data is greater than the preset data amount threshold, send a data synchronization instruction to the at least one second user; in response to the data synchronization request sent by the at least one second user, the Incremental data is synchronized to the at least one second user.
可选地,所述将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后,还包括:确定所述第一用户的第一社交数据的数据变更频率;若所述数据变更频率大于预设变更频率阈值,则将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;在检测到所述增量数据的数据量大于预设数据量阈值的情况下,确定与所述第一用户存在社交关系的至少一个第二用户,并向所述至少一个第二用户发送数据同步指令;响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。Optionally, after comparing the data version number corresponding to the social data with the target data version number, the method further includes: determining a data change frequency of the first social data of the first user; if the If the data change frequency is greater than the preset change frequency threshold, the target data version number and the social change data are stored as incremental data; when it is detected that the data volume of the incremental data is greater than the preset data volume threshold Next, determine at least one second user that has a social relationship with the first user, and send a data synchronization instruction to the at least one second user; in response to the data synchronization request sent by the at least one second user, The incremental data is synchronized to the at least one second user.
可选地,所述对所述社交变更数据对应的数据版本号进行更新,包括:确定所述社交变更数据对应的变更时间;基于所述变更时间对所述数据版本号进行更新。Optionally, the updating the data version number corresponding to the social change data includes: determining a change time corresponding to the social change data; and updating the data version number based on the change time.
可选地,所述将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户,包括:与所述第二用户的用户终端建立长连接,通过所述长连接将所述目标数据版本号以及所述社交变更数据同步至所述用户终端,以将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。Optionally, the synchronizing the target data version number and the social change data to the second user as incremental data includes: establishing a long connection with the user terminal of the second user, The connection synchronizes the target data version number and the social change data to the user terminal to synchronize the target data version number and the social change data to the second user as incremental data.
根据本说明书实施例的第二方面,提供了一种数据同步装置,包括:第一采集模块,被配置为采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;第二采集模块,被配置为采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;比对模块,被配置为将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;同步模块,被配置为在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。According to a second aspect of the embodiments of the present specification, there is provided a data synchronization apparatus, including: a first collection module configured to collect social change data of a first user, and perform a data version number corresponding to the social change data. updating, generating a target data version number; a second collection module, configured to collect a data version number corresponding to the social data associated with the social change data of the second user; a comparison module, configured to correspond to the social data The data version number is compared with the target data version number; the synchronization module is configured to synchronize the target data version number and the social change data as incremental data to the second user.
根据本说明书实施例的第三方面,提供了一种计算设备,包括:存储器和处理器;所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。According to a third aspect of the embodiments of this specification, a computing device is provided, including: a memory and a processor; the memory is used for storing computer-executable instructions, and the processor is used for executing the computer-executable instructions: collecting the first The social change data of a user, and the data version number corresponding to the social change data is updated to generate a target data version number; the data version number corresponding to the social data associated with the social change data of the second user is collected; The data version number corresponding to the social data is compared with the target data version number; if the comparison is inconsistent, the target data version number and the social change data are synchronized as incremental data to the Two users.
根据本说明书实施例的第四方面,提供了一种计算机可读存储介质,其存储有计算机可执行指令,该指令被处理器执行时实现所述数据同步方法的步骤。According to a fourth aspect of the embodiments of the present specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, implements the steps of the data synchronization method.
本说明书一个实施例通过采集第一用户的社交变更数据,并对所述社交变更数据对 应的数据版本号进行更新,生成目标数据版本号,采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号,将所述社交数据对应的数据版本号与所述目标数据版本号进行比对,在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。An embodiment of this specification collects the social change data of the first user, updates the data version number corresponding to the social change data, generates a target data version number, and collects the social change data of the second user associated with the social change data. The data version number corresponding to the data, the data version number corresponding to the social data is compared with the target data version number, and if the comparison is inconsistent, the target data version number and the social change data are used as Incremental data is synchronized to the second user.
本说明书实施例通过为用户的社交数据设置数据版本号,并通过将服务端中第一用户的社交数据对应的数据版本号与第二用户的同类别的社交数据对应的数据版本号进行比对,存在比对不一致的数据版本号的情况下,则可将第一用户的社交数据中比对不一致的数据版本号对应的社交数据同步至第二用户,在可以兼顾网络流量的同时,还可以保证不同用户间社交数据的一致性以及社交关系正确性,以及社交数据更新的及时性。In the embodiment of this specification, a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
附图说明Description of drawings
图1是本说明书一个实施例提供的一种数据同步方法的处理流程图;Fig. 1 is a processing flow chart of a data synchronization method provided by an embodiment of this specification;
图2是本说明书一个实施例提供的一种数据同步过程的交互示意图;2 is an interactive schematic diagram of a data synchronization process provided by an embodiment of this specification;
图3是本说明书一个实施例提供的一种数据同步装置的示意图;3 is a schematic diagram of a data synchronization apparatus provided by an embodiment of the present specification;
图4是本说明书一个实施例提供的一种计算设备的结构框图。FIG. 4 is a structural block diagram of a computing device provided by an embodiment of the present specification.
具体实施方式Detailed ways
在下面的描述中阐述了很多具体细节以便于充分理解本说明书。但是本说明书能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本说明书内涵的情况下做类似推广,因此本说明书不受下面公开的具体实施的限制。In the following description, numerous specific details are set forth in order to provide a thorough understanding of this specification. However, this specification can be implemented in many other ways different from those described herein, and those skilled in the art can make similar promotions without departing from the connotation of this specification. Therefore, this specification is not limited by the specific implementation disclosed below.
在本说明书一个或多个实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书一个或多个实施例。在本说明书一个或多个实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本说明书一个或多个实施例中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in one or more embodiments of this specification is for the purpose of describing a particular embodiment only and is not intended to limit the one or more embodiments of this specification. As used in the specification or embodiments and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used in this specification in one or more embodiments refers to and includes any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本说明书一个或多个实施例中可能采用术语第一、第二等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书一个或多个实施例范围的情况下,第一也可以被称为第二,类似地,第二也可以被称为第一。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It will be understood that although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited by these terms. These terms are only used to distinguish the same type of information from each other. For example, a first could be termed a second, and similarly, a second could be termed a first, without departing from the scope of one or more embodiments of this specification. Depending on the context, the word "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determining."
首先,对本说明书一个或多个实施例涉及的名词术语进行解释。First, the terminology involved in one or more embodiments of the present specification is explained.
IM,指即时通讯(Instant Messaging),IM服务就是提供即时通讯的服务。IM, refers to instant messaging (Instant Messaging), IM service is to provide instant messaging services.
社交关系:主要是指好友关系、群组关系。Social relationship: mainly refers to friend relationship, group relationship.
随着即时通讯的不断发展,越来越多的应用加入了IM功能。而IM功能中非常重要的一个功能点便是社交关系的同步及管理。由于客户端存在网络流量、信号质量不确定等诸多影响因素,使得社交关系的同步及管理存在一定难度。With the continuous development of instant messaging, more and more applications have added the IM function. A very important function point in the IM function is the synchronization and management of social relations. Due to the presence of many influencing factors such as network traffic and uncertain signal quality on the client side, it is difficult to synchronize and manage social relationships.
基于此,本说明书实施例提供一种数据同步方法,应用于服务端,通过采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号,采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号,将所述社交数据对应的数据版本号与所述目标数据版本号进行比对,在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。Based on this, an embodiment of this specification provides a data synchronization method, which is applied to a server, and generates a target data version number by collecting social change data of a first user, and updating the data version number corresponding to the social change data. Collect the data version number corresponding to the social data associated with the social change data of the second user, compare the data version number corresponding to the social data with the target data version number, and in the case of inconsistent comparison, The target data version number and the social change data are synchronized to the second user as incremental data.
具体即通过为用户的社交数据设置数据版本号,并通过将服务端中第一用户的社交数据对应的数据版本号与第二用户的同类别的社交数据对应的数据版本号进行比对,存在比对不一致的数据版本号的情况下,则可将第一用户的社交数据中比对不一致的数据版本号对应的社交数据同步至第二用户,在可以兼顾网络流量的同时,还可以保证不同用户间社交数据的一致性以及社交关系正确性,以及社交数据更新的及时性。Specifically, by setting a data version number for the user's social data, and by comparing the data version number corresponding to the first user's social data in the server with the data version number corresponding to the second user's social data of the same category, there is In the case of comparing inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user, which can take into account the network traffic and ensure that different The consistency of social data among users, the correctness of social relations, and the timeliness of social data updates.
在本说明书中,提供了一种数据同步方法,本说明书同时涉及一种数据同步装置,一种计算设备,以及一种计算机可读存储介质,在下面的实施例中逐一进行详细说明。In this specification, a data synchronization method is provided, and this specification also relates to a data synchronization apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
图1示出了根据本说明书一个实施例提供的一种数据同步方法的处理流程图,包括步骤102至步骤108。FIG. 1 shows a processing flow chart of a data synchronization method provided according to an embodiment of the present specification, including steps 102 to 108 .
步骤102,采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号。Step 102: Collect social change data of the first user, update the data version number corresponding to the social change data, and generate a target data version number.
具体的,本说明书实施例提供的数据同步方法应用于服务端,由于用户的社交关系通常较为复杂,为保证与第一用户存在社交关系的其他用户的用户终端所存储的第一用户的社交数据与所述第一用户的真实社交数据保持一致,则需由服务端采集第一用户的社交变更数据,并将所述变更数据同步至相关的第二用户。Specifically, the data synchronization method provided in the embodiment of this specification is applied to the server. Since the social relationship of the user is usually complicated, in order to ensure the social data of the first user stored in the user terminals of other users who have a social relationship with the first user If it is consistent with the real social data of the first user, the server needs to collect the social change data of the first user, and synchronize the change data to the relevant second user.
其中,本说明书实施例所述的社交数据,包括但不限于用户的社交应用中的用户名、用户头像、用户简介以及用户所加入的群组数据等;所述社交变更数据,即可包含被修改的、发生变更的社交数据,以及社交数据的修改时间等信息。The social data described in the embodiments of this specification includes but is not limited to the user name, user avatar, user profile, and group data that the user joins in the user's social application; the social change data may include Modified and changed social data, as well as the modification time of social data and other information.
另外,本说明书实施例中,所述社交数据所包含的用户名、用户头像、用户简介以及用户所加入的群组数据等分别对应不同的数据类别,即用户名对应数据类别1、用户头像对应数据类别2、用户简介对应数据类别3等,每个数据类别的社交数据均对应一个初始数据版本号。In addition, in the embodiment of this specification, the user name, user avatar, user profile, and group data that the user joins included in the social data correspond to different data categories, that is, the user name corresponds to data category 1, and the user avatar corresponds to Data category 2 and user profile correspond to data category 3, etc. The social data of each data category corresponds to an initial data version number.
服务端采集第一用户的社交变更数据,即被修改的、发生变更的社交数据后,可为所述社交变更数据设置数据版本号,具体即对所述社交变更数据对应的版本号进行更新(对所述社交变更数据的数据类别对应的初始数据版本号进行更新),生成目标数据版本号,对初始数据版本号的更新即可用于表征用户的社交数据发生了变更,并且在将社交变更数据同步至相关的第二用户后,即可将所述目标数据版本号作为初始数据版本号,以在用户对所述社交变更数据进行修改的情况下,执行前述对社交变更数据对应的数据版本号进行更新的过程。After collecting the social change data of the first user, that is, the modified and changed social data, the server can set a data version number for the social change data, specifically, update the version number corresponding to the social change data ( The initial data version number corresponding to the data category of the social change data is updated), and the target data version number is generated. The update of the initial data version number can be used to indicate that the social data of the user has changed, and the social change data After synchronizing to the relevant second user, the target data version number can be used as the initial data version number, so that when the user modifies the social change data, the aforementioned data version number corresponding to the social change data is executed. process of updating.
例如,所述第一用户修改了用户名,修改之前,第一用户的用户名为U10,对应的初始数据版本号为V10,修改之后第一用户的用户名为U11,对应的数据版本号则可以更新为V11。在将用户名U11同步至相关的第二用户后,即可将V11作为用户名对应数据类别的初始数据版本号。For example, the first user modifies the user name. Before the modification, the user name of the first user is U10, and the corresponding initial data version number is V10. After the modification, the user name of the first user is U11, and the corresponding data version number is Can be updated to V11. After the user name U11 is synchronized to the relevant second user, V11 can be used as the initial data version number of the data category corresponding to the user name.
具体实施时,对所述社交变更数据对应的数据版本号进行更新,即确定所述社交变更数据对应的变更时间,基于所述变更时间对所述数据版本号进行更新。During specific implementation, the data version number corresponding to the social change data is updated, that is, the change time corresponding to the social change data is determined, and the data version number is updated based on the change time.
具体的,本说明书实施例可利用社交变更数据的变更时间(修改时间)对社交变更数据对应的数据版本号进行更新,具体可将所述变更时间作为所述社交变更数据对应的目标数据版本号,其中,所述变更时间可从所述社交变更数据中获取。Specifically, in the embodiment of this specification, the change time (modification time) of the social change data may be used to update the data version number corresponding to the social change data, and specifically, the change time may be used as the target data version number corresponding to the social change data , wherein the change time can be obtained from the social change data.
或者,还可利用目标算法(例如哈希算法)对社交数据进行处理,并将处理结果作为所述社交数据的初始数据版本号,以及利用所述目标算法对所述社交变更数据进行处理,生成所述社交变更数据对应的目标数据版本号。Alternatively, a target algorithm (such as a hash algorithm) may also be used to process the social data, and the processing result may be used as the initial data version number of the social data, and the target algorithm may be used to process the social change data to generate The target data version number corresponding to the social change data.
步骤104,采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号。Step 104: Collect the data version number of the second user corresponding to the social data associated with the social change data.
具体的,采集第一用户的社交变更数据后,可确定与所述社交变更数据关联的待进行数据同步的第二用户。例如,若采集的社交变更数据为用户名变更为U11,则确定与所述社交变更数据关联的待进行数据同步的第二用户为与所述第一用户存在社交关系的全部用户(第一用户的全部好友以及第一用户加入的全部群组);若采集的社交变更数据为用户加入群组G1,则确定与所述社交变更数据关联的待进行数据同步的第二用户为所述群组G1中除第一用户外的其他用户。Specifically, after collecting the social change data of the first user, a second user associated with the social change data to be synchronized may be determined. For example, if the collected social change data is that the user name is changed to U11, it is determined that the second user associated with the social change data to be synchronized is all users who have social relations with the first user (the first user All friends and all groups joined by the first user); if the collected social change data is that the user joins the group G1, then it is determined that the second user associated with the social change data to be synchronized is the group Other users in G1 except the first user.
确定第二用户后,可采集所述第二用户的与所述社交变更数据关联的社交数据对应的数据版本号,由于每个用户的社交数据的数据量较多,因此,在确定第一用户的某个社交数据发生变更后,为减小服务端的工作量以及资源消耗量,实际应用中可选择仅对第二用户的社交数据中与所述社交变更数据关联的社交数据进行更新,即采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号,并将所述数据版本号与目标数据版本号进行比对,以确定是否需要对第二用户的社交数据进行更新。After the second user is determined, the data version number corresponding to the social data associated with the social change data of the second user can be collected. After a certain social data of the user is changed, in order to reduce the workload and resource consumption of the server, in practical applications, only the social data associated with the social change data in the social data of the second user can be selected to be updated, that is, the collection The data version number of the second user corresponding to the social data associated with the social change data, and the data version number is compared with the target data version number to determine whether the social data of the second user needs to be updated.
沿用上例,所述第一用户修改了用户名,修改之后第一用户的用户名为U11,对应的数据版本号更新为V11。接着可采集第二用户的、与所述社交变更数据关联的社交数据对应的数据版本号,具体即采集第二用户的用户终端所存储的所述第一用户的用户名,并采集所述第一用户的用户名对应的数据版本号,以将所述数据版本号与前述数据版本号的更新结果V11进行比对,以确定是否需要对第二用户的用户终端所存储的所述第一用户的用户名进行更新。Following the above example, the first user modifies the user name, after the modification, the user name of the first user is U11, and the corresponding data version number is updated to V11. Then, the data version number of the second user corresponding to the social data associated with the social change data may be collected, specifically collecting the user name of the first user stored in the user terminal of the second user, and collecting the first user's username. A data version number corresponding to the user name of a user, so as to compare the data version number with the update result V11 of the aforementioned data version number to determine whether it is necessary to update the first user stored in the user terminal of the second user user name to update.
步骤106,将所述社交数据对应的数据版本号与所述目标数据版本号进行比对。Step 106: Compare the data version number corresponding to the social data with the target data version number.
具体的,如前所述,对第一用户的社交变更数据对应的数据版本号进行更新,生成目标数据版本号,并采集获得第二用户的与所述社交变更数据关联的社交数据对应的数据版本号后,即可将所述数据版本号与同类别的社交数据对应的目标数据版本号进行比对,以确定是否需要对第二用户的社交数据进行更新。Specifically, as described above, the data version number corresponding to the social change data of the first user is updated, the target data version number is generated, and the data corresponding to the social data associated with the social change data of the second user is collected and obtained After the version number is obtained, the data version number can be compared with the target data version number corresponding to the social data of the same category to determine whether the social data of the second user needs to be updated.
步骤108,在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。 Step 108, in the case of inconsistent comparison, synchronize the target data version number and the social change data to the second user as incremental data.
具体的,将数据版本号与目标数据版本号进行比对获得对应的比对结果,若根据比对结果确定二者比对不一致,则将第一用户的社交变更数据以及所述社交变更数据对应的目标数据版本号作为增量数据同步至所述第二用户;若根据比对结果确定二者比对一致,则无需向第二用户同步所述社交变更数据。Specifically, the data version number and the target data version number are compared to obtain a corresponding comparison result. If it is determined that the comparison between the two is inconsistent according to the comparison result, the social change data of the first user and the social change data are corresponding The version number of the target data is synchronized to the second user as incremental data; if it is determined according to the comparison result that the two are consistent, there is no need to synchronize the social change data to the second user.
具体实施时,服务端可通过长连接向第二用户同步社交变更数据,因此,所述将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户,具体即与所述第二用户的用户终端建立长连接,通过所述长连接将所述目标数据版本号以及所述社交变更数据同步至所述用户终端,以将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户,以实现第二用户的用户终端中存储的所述第一用户的社交数据与第一用户的实际社交数据保持一致。During specific implementation, the server can synchronize social change data to the second user through a persistent connection. Therefore, the synchronization of the target data version number and the social change data as incremental data to the second user is specifically: establishing a long connection with the user terminal of the second user, and synchronizing the target data version number and the social change data to the user terminal through the long connection, so that the target data version number and the social The change data is synchronized to the second user as incremental data, so that the social data of the first user stored in the user terminal of the second user is consistent with the actual social data of the first user.
前述实施例通过为用户的社交数据设置数据版本号,并通过将服务端中第一用户的社交变更数据对应的数据版本号与第二用户的同类别的社交数据对应的数据版本号进行比对的方式,确定是否需向第二用户同步社交变更数据,以保证不同用户间社交数据的一致性以及社交关系的正确性,以及社交数据更新的及时性。In the foregoing embodiment, a data version number is set for the user's social data, and the data version number corresponding to the social change data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category. way to determine whether social change data needs to be synchronized with the second user to ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
本说明书提供的实施例中,还可由服务端接收第一用户针对待修改社交数据提交的数据修改指令,根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新,将所述待修改数据的更新结果同步至第二用户。In the embodiment provided in this specification, the server can also receive a data modification instruction submitted by the first user for the social data to be modified, update the social data to be modified according to the data modification information carried in the data modification instruction, and update the social data to be modified. The update result of the data to be modified is synchronized to the second user.
具体的,第一用户需对其在社交应用中的用户名、用户头像、用户简介等社交数据进行修改的情况下,可向服务端发送数据修改指令,所述数据修改指令中携带的数据修改信息具体可包含待修改社交数据、以及所述待修改社交数据的数据修改结果;服务端可根据所述数据修改信息对第一用户的待修改社交数据进行更新,并将更新结果同步至第二用户,即由服务端主动将第一用户的社交变更数据同步至第二用户。Specifically, when the first user needs to modify his social data such as user name, user avatar, user profile and other social data in the social application, he can send a data modification instruction to the server, and the data carried in the data modification instruction is to modify the data. The information may specifically include the social data to be modified and the data modification result of the social data to be modified; the server can update the social data to be modified of the first user according to the data modification information, and synchronize the update result to the second user. User, that is, the server actively synchronizes the social change data of the first user to the second user.
进一步的,根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新之后,还包括:基于所述待修改社交数据的更新结果对所述第一用户的第一社交数据对应的数据版本号进行更新,生成所述第一用户的第一社交数据对应的第一数据版本号。Further, after updating the social data to be modified according to the data modification information carried in the data modification instruction, the method further includes: updating the first social data of the first user based on the update result of the social data to be modified. The corresponding data version number is updated to generate a first data version number corresponding to the first social data of the first user.
更进一步的,生成所述第一用户的第一社交数据对应的第一数据版本号之后,还包括:确定与所述第一用户存在社交关系的至少一个第二用户;获取所述至少一个第二用户的第二社交数据中与所述第一用户存在关联关系的第二社交子数据,并确定所述第二社交子数据对应的第二数据子版本号;确定所述第一用户的第一社交数据中与所述第二社交子数据存在关联关系的第一社交子数据,并确定所述第一社交子数据对应的第一数据子版本号;将所述第一数据子版本号与所述第二数据子版本号进行比对;在比对不一致的情况下,将所述第一数据子版本号以及所述第一数据子版本号对应的第一社交子数据作为增量数据同步至所述第二用户。Further, after generating the first data version number corresponding to the first social data of the first user, the method further includes: determining at least one second user who has a social relationship with the first user; obtaining the at least one first user. The second social sub-data associated with the first user in the second social data of the two users, and the second data sub-version number corresponding to the second social sub-data is determined; A first social sub-data in social data that has an associated relationship with the second social sub-data, and a first data sub-version number corresponding to the first social sub-data is determined; the first data sub-version number is combined with The second data sub-version number is compared; in the case of inconsistent comparison, the first data sub-version number and the first social sub-data corresponding to the first data sub-version number are synchronized as incremental data to the second user.
具体的,前述实施例中,服务端将第一用户的社交变更数据对应的目标数据版本号与第二用户的社交数据中与所述社交变更数据关联的社交数据对应的数据版本号进行比对,以确定是否需将社交变更数据同步至第二用户。Specifically, in the foregoing embodiment, the server compares the target data version number corresponding to the social change data of the first user with the data version number corresponding to the social data associated with the social change data in the social data of the second user to determine whether the social change data needs to be synchronized to the second user.
而本说明书实施例中,服务端选择主动将第一用户的社交变更数据同步至与第一用户存在社交关系的第二用户,而这一同步过程中,可能存在因网络原因或其他原因导致的数据同步失败的情况。However, in the embodiment of this specification, the server chooses to actively synchronize the social change data of the first user to the second user who has a social relationship with the first user. In this synchronization process, there may be network or other reasons. When data synchronization fails.
因此,服务端对第一用户的待修改社交数据进行更新后,可基于更新结果对第一用户的第一社交数据对应的数据版本号进行更新,生成所述第一用户的第一社交数据对应的第一数据版本号,具体即基于更新结果对第一用户的第一社交数据中所述社交变更数据对应的数据版本号进行更新,并将数据版本号更新结果与第一社交数据中除所述社交变更数据外的其他社交数据对应的数据版本号共同组成所述第一用户的第一社交数据对应的第一数据版本号。Therefore, after updating the social data of the first user to be modified, the server can update the data version number corresponding to the first social data of the first user based on the update result, and generate a corresponding version of the first social data of the first user. Specifically, based on the update result, the data version number corresponding to the social change data in the first social data of the first user is updated, and the update result of the data version number is removed from the first social data. The data version numbers corresponding to other social data other than the social change data together form a first data version number corresponding to the first social data of the first user.
接着,服务端可确定与第一用户存在社交关系的第二用户(第一用户的好友,或与第一用户同在一个群组等),并获取第二用户的与第一用户存在关联关系的社交数据(第二社交子数据,例如,第二用户的用户终端存储的所述第一用户的用户名称、用户头像、用户简介等信息),并确定这些社交数据分别对应数据版本号(第二数据子版本号)。Next, the server may determine a second user (a friend of the first user, or in the same group as the first user, etc.) who has a social relationship with the first user, and obtain the relationship between the second user and the first user. The social data (second social sub-data, for example, the user name, user avatar, user profile and other information of the first user stored in the user terminal of the second user), and determine that these social data correspond to the data version numbers (No. 2 data subversion number).
然后确定所述第一用户的第一社交数据中与所述第二社交子数据存在关联关系的第一社交子数据,并确定所述第一社交子数据对应的第一数据子版本号;若第二社交子数据为第二用户的用户终端存储的所述第一用户的用户名称、用户头像、用户简介,则所述第一社交子数据即为第一用户的用户终端存储的所述第一用户的用户名称、用户头像、用户简介,确定所述第一社交子数据及所述第一社交子数据对应的第一数据子版本号后,将所述第一数据子版本号与同类别的第二社交子数据对应的第二数据子版本号进行比对,在比对不一致的情况下,将所述第一数据子版本号以及所述第一数据子版本号对应的第一社交子数据作为增量数据同步至所述第二用户。Then determine the first social sub-data that is associated with the second social sub-data in the first social data of the first user, and determine the first data sub-version number corresponding to the first social sub-data; if The second social sub-data is the user name, user avatar, and user profile of the first user stored in the user terminal of the second user, and the first social sub-data is the first social sub-data stored in the user terminal of the first user. A user's user name, user avatar, and user profile, after determining the first social sub-data and the first data sub-version number corresponding to the first social sub-data, and comparing the first data sub-version number with the same category The second data sub-version number corresponding to the second social sub-data is compared, and in the case of inconsistent comparison, the first data sub-version number and the first social sub-version number corresponding to the first data sub-version number are compared. The data is synchronized to the second user as incremental data.
另外,服务端能够成功向第二用户进行数据同步的前提为:第二用户的社交应用的账号处于已登录状态(在线状态),因此,在向第二用户进行数据同步之前,还需检测 第二用户的登录状态,具体可通过以下方式实现:确定与所述第一用户存在社交关系的至少一个第二用户;检测所述至少一个第二用户的第一登录状态;若所述至少一个第二用户的第一登录状态为已登录,则在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。In addition, the premise that the server can successfully synchronize data to the second user is that the account of the social application of the second user is in a logged-in state (online). The login status of the second user can be specifically implemented by: determining at least one second user that has a social relationship with the first user; detecting the first login status of the at least one second user; The first login status of the two users is logged in, and if the comparison is inconsistent, the target data version number and the social change data are synchronized to the second user as incremental data.
进一步的,若所述至少一个第二用户的登录状态为未登录,则在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;检测所述至少一个第二用户的第二登录状态;若所述至少一个第二用户的第二登录状态为已登录,则将所述增量数据同步至所述第二用户。Further, if the login status of the at least one second user is not logged in, in the case of inconsistent comparison, the target data version number and the social change data are stored as incremental data; The second login status of at least one second user; if the second login status of the at least one second user is logged in, the incremental data is synchronized to the second user.
具体的,将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后,需确定与第一用户存在社交关系的第二用户,并检测所述第二用户的登录状态;其中,若所述第二用户的登录状态为已登录(在线),则可根据比对结果确定是否需向第二用户进行数据同步,若需进行数据同步,则将所述社交变更数据同步至第二用户即可;若所述第二用户的登录状态为未登录(离线),这种情况下,同样需根据比对结果确定是否需向第二用户进行数据同步,若需进行数据同步,则需将所述社交变更数据进行存储。Specifically, after comparing the data version number corresponding to the social data with the target data version number, it is necessary to determine a second user who has a social relationship with the first user, and detect the login status of the second user; Wherein, if the login status of the second user is logged in (online), it can be determined whether data synchronization needs to be performed with the second user according to the comparison result, and if data synchronization is required, the social change data is synchronized to The second user is sufficient; if the login status of the second user is not logged in (offline), in this case, it is also necessary to determine whether data synchronization needs to be performed with the second user according to the comparison result. Then the social change data needs to be stored.
如前所述,可利用目标算法(例如哈希算法)对社交数据进行处理,并将处理结果作为所述社交数据的初始数据版本号,以及利用所述目标算法对所述社交变更数据进行处理,生成所述社交变更数据对应的目标数据版本号;或者,可将社交变更数据的变更时间作为所述社交变更数据对应的目标数据版本号。As mentioned above, the social data may be processed using a target algorithm (eg, a hash algorithm), and the processing result may be used as an initial data version number of the social data, and the social change data may be processed using the target algorithm , and generate the target data version number corresponding to the social change data; or, the change time of the social change data may be used as the target data version number corresponding to the social change data.
因此,若利用目标算法(例如哈希算法)生成社交数据及社交变更数据的数据版本号,则只有在社交变更数据与社交数据完全一致的情况下,利用目标算法(例如哈希算法)对二者进行处理生成的哈希值(初始数据版本号和目标数据版本号)才会比对一致;或者,若将社交数据或社交变更数据的变更时间作为数据版本号,则只有在所述社交变更数据与社交数据的变更时间一致的情况下,才会比对一致。Therefore, if a target algorithm (such as a hash algorithm) is used to generate the data version numbers of social data and social change data, only when the social change data and social data are completely consistent, the target algorithm (such as a hash algorithm) is used to compare the two The hash value (initial data version number and target data version number) generated by processing by the user will be consistent; or, if the change time of social data or social change data is used as the data version number, only the social change Only when the data and social data are changed at the same time will the comparison be consistent.
若比对不一致,则表明第二用户的与所述社交变更数据关联的社交数据与第一用户的所述社交变更数据不一致,需进行数据同步,即需将所述社交变更数据同步至第二用户。If the comparison is inconsistent, it means that the social data associated with the social change data of the second user is inconsistent with the social change data of the first user, and data synchronization needs to be performed, that is, the social change data needs to be synchronized to the second user. user.
实际应用中,若第二用户的登录状态为已登录(在线),则在比对不一致的情况下,直接将所述社交变更数据以及所述目标数据版本号同步至第二用户;若第二用户的登录状态的未登录(离线),则在比对不一致的情况下,需将所述社交变更数据以及所述目标数据版本号进行存储,并继续检测第二用户的登录状态,在第二用户下一次登录时,将所存储的社交变更数据同步至第二用户。In practical applications, if the login status of the second user is logged in (online), in the case of inconsistent comparison, the social change data and the version number of the target data are directly synchronized to the second user; If the user's login status is not logged in (offline), if the comparison is inconsistent, the social change data and the version number of the target data need to be stored, and continue to detect the login status of the second user. The next time the user logs in, the stored social change data is synchronized to the second user.
此外,前述在确定第二用户的登录状态为未登录,并在数据版本号比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储之后,继续检测所述至少一个第二用户的登录状态,在检测到第二用户登录之后,可检测所存储的所述增量数据的数据量;若所述增量数据的数据量大于预设数据量阈值,则向所述至少一个第二用户发送数据同步指令;响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。In addition, after it is determined that the login status of the second user is not logged in, and the data version number is inconsistent, the target data version number and the social change data are stored as incremental data, and the detection is continued. For the login status of the at least one second user, after detecting that the second user is logged in, the data volume of the stored incremental data can be detected; if the data volume of the incremental data is greater than the preset data volume threshold, sending a data synchronization instruction to the at least one second user; and synchronizing the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
具体的,服务端可通过长连接将社交变更数据发送至第二用户,但在第二用户处于未登录状态的情况下,服务端需要将所述社交变更数据进行存储,在第二用户再次上线之后,将所存储的社交变更数据同步至第二用户;但在服务端所存储的社交变更数据的数据量大于预设数据量阈值的情况下,为减少服务端的数据传输压力,可由服务端向第二用户发送数据同步指令,由第二用户主动从服务端拉取所述社交变更数据。Specifically, the server can send the social change data to the second user through a persistent connection, but when the second user is not logged in, the server needs to store the social change data, and when the second user goes online again After that, the stored social change data is synchronized to the second user; however, when the data volume of the social change data stored by the server is greater than the preset data volume threshold, in order to reduce the data transmission pressure on the server, the server can send the data to the second user. The second user sends a data synchronization instruction, and the second user actively pulls the social change data from the server.
此外,在将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后, 还可通过确定第一用户的第一社交数据的数据变更频率的方式,确定社交变更数据的同步方式,具体可通过以下方式实现:确定所述第一用户的第一社交数据的数据变更频率;若所述数据变更频率大于预设变更频率阈值,则将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;在检测到所述增量数据的数据量大于预设数据量阈值的情况下,确定与所述第一用户存在社交关系的至少一个第二用户,并向所述至少一个第二用户发送数据同步指令;响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。In addition, after comparing the data version number corresponding to the social data with the target data version number, the synchronization of the social change data may also be determined by determining the data change frequency of the first social data of the first user Specifically, it can be implemented in the following ways: determining the data change frequency of the first social data of the first user; if the data change frequency is greater than a preset change frequency threshold, then the target data version number and the social The change data is stored as incremental data; when it is detected that the data volume of the incremental data is greater than the preset data volume threshold, determine at least one second user who has a social relationship with the first user, and report to all The at least one second user sends a data synchronization instruction; and in response to a data synchronization request sent by the at least one second user, the incremental data is synchronized to the at least one second user.
具体的,服务端可通过长连接将社交变更数据发送至第二用户,但在第一用户的第一社交数据的数据变更频率高于预设阈值的情况下,若服务端通过长连接分批向第二用户发送社交变更数据,则存在数据同步效率低的缺陷,因此,在第一用户的第一社交数据的数据变更频率高于预设阈值的情况下,服务端可选择将社交变更数据进行存储,并在存储的社交变更数据达到预设数据量阈值的情况下,将所存储的社交变更数据统一同步至第二用户;或向第二用户下发社交变更数据的拉取指令,由第二用户做一次社交变更数据的全量拉取,以实现数据同步。Specifically, the server can send the social change data to the second user through a long connection, but if the data change frequency of the first social data of the first user is higher than the preset threshold, if the server uses the long connection in batches Sending social change data to the second user has the defect of low data synchronization efficiency. Therefore, in the case where the data change frequency of the first social data of the first user is higher than the preset threshold, the server can choose to send the social change data Store it, and when the stored social change data reaches the preset data volume threshold, synchronize the stored social change data to the second user; or issue a pull instruction for the social change data to the second user. The second user does a full pull of social change data to achieve data synchronization.
本说明书实施例中,当用户的社交数据发生变化时,比如好友的增加、好友昵称的修改,群成员的变更等,服务端会通过长连接,将发生变化的数据增量推送到其他用户,以保证不同用户的社交数据的同步。另外,通过服务端主动进行增量数据同步,以及用户进行数据拉取二者结合的方式,有利于保证数据同步结果的正确性、时效性,并有利于减少服务端的数据传输压力。In the embodiment of this specification, when a user's social data changes, such as the addition of friends, the modification of friends' nicknames, the change of group members, etc., the server will incrementally push the changed data to other users through a long connection. To ensure the synchronization of social data of different users. In addition, the combination of incremental data synchronization by the server and data pulling by the user is beneficial to ensure the correctness and timeliness of the data synchronization results, and is beneficial to reduce the data transmission pressure on the server.
本说明书实施例通过为用户的社交数据设置数据版本号,并通过将服务端中第一用户的社交数据对应的数据版本号与第二用户的同类别的社交数据对应的数据版本号进行比对,存在比对不一致的数据版本号的情况下,则可将第一用户的社交数据中比对不一致的数据版本号对应的社交数据同步至第二用户,在可以兼顾网络流量的同时,还可以保证不同用户间社交数据的一致性以及社交关系正确性,以及社交数据更新的及时性。In the embodiment of this specification, a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
下述结合附图2,以本说明书提供的数据同步方法在社交场景的应用为例,对所述数据同步方法进行进一步说明。其中,图2示出了本说明书一个实施例提供的一种数据同步过程的交互示意图,具体步骤包括步骤202至步骤228。The data synchronization method is further described below by taking the application of the data synchronization method provided in this specification in a social scene as an example with reference to FIG. 2 . 2 shows an interactive schematic diagram of a data synchronization process provided by an embodiment of the present specification, and the specific steps include steps 202 to 228 .
步骤202,第一客户端向服务端发送数据修改指令。Step 202, the first client sends a data modification instruction to the server.
步骤204,服务端根据所述数据修改指令中携带的数据修改信息对待修改社交数据进行更新,并基于所述待修改社交数据的更新结果对所述待修改社交数据对应的数据版本号进行更新。Step 204: The server updates the social data to be modified according to the data modification information carried in the data modification instruction, and updates the data version number corresponding to the social data to be modified based on the update result of the social data to be modified.
步骤206,服务端将所述待修改数据的更新结果以及所述数据版本号的更新结果同步至第二客户端。Step 206, the server synchronizes the update result of the data to be modified and the update result of the data version number to the second client.
步骤208,第二客户端存储所述待修改数据的更新结果以及所述数据版本号的更新结果。Step 208, the second client stores the update result of the data to be modified and the update result of the data version number.
步骤210,服务端采集第一客户端的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号。Step 210: The server collects the social change data of the first client, and updates the data version number corresponding to the social change data to generate a target data version number.
步骤212,服务端采集第二客户端的与所述社交变更数据关联的社交数据对应的数据版本号。Step 212 , the server collects the data version number corresponding to the social data associated with the social change data of the second client.
步骤214,服务端将所述社交数据对应的数据版本号与所述目标数据版本号进行比对。Step 214, the server compares the data version number corresponding to the social data with the target data version number.
步骤216,在比对不一致的情况下,服务端将所述目标数据版本号以及所述社交变 更数据作为增量数据同步至所述第二用户。Step 216, in the case of inconsistent comparison, the server synchronizes the target data version number and the social change data to the second user as incremental data.
步骤218,第二客户端存储所述增量数据。Step 218, the second client stores the incremental data.
步骤220,服务端确定第一客户端的第一社交数据的数据变更频率,在所述数据变更频率大于预设变更频率阈值的情况下,则将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储。Step 220, the server determines the data change frequency of the first social data of the first client, and in the case that the data change frequency is greater than the preset change frequency threshold, the target data version number and the social change data are used as Incremental data is stored.
步骤222,服务端在检测到所述增量数据的数据量大于预设数据量阈值的情况下,确定与所述第一用户存在社交关系的至少一个第二用户,并向所述至少一个第二用户发送数据同步指令。Step 222, when detecting that the data volume of the incremental data is greater than a preset data volume threshold, the server determines at least one second user who has a social relationship with the first user, and reports to the at least one first user. Two users send data synchronization instructions.
步骤224,服务端接收第二客户端发送的数据同步请求。Step 224, the server receives the data synchronization request sent by the second client.
步骤226,服务端将所述增量数据同步至第二客户端。Step 226, the server synchronizes the incremental data to the second client.
步骤228,第二客户端存储所述增量数据。Step 228, the second client stores the incremental data.
本说明书实施例通过为用户的社交数据设置数据版本号,并通过将服务端中第一用户的社交数据对应的数据版本号与第二用户的同类别的社交数据对应的数据版本号进行比对,存在比对不一致的数据版本号的情况下,则可将第一用户的社交数据中比对不一致的数据版本号对应的社交数据同步至第二用户,在可以兼顾网络流量的同时,还可以保证不同用户间社交数据的一致性以及社交关系正确性,以及社交数据更新的及时性。In the embodiment of this specification, a data version number is set for the social data of the user, and the data version number corresponding to the social data of the first user in the server is compared with the data version number corresponding to the social data of the second user of the same category , in the case of inconsistent data version numbers, the social data corresponding to the inconsistent data version numbers in the social data of the first user can be synchronized to the second user. Ensure the consistency of social data among different users, the correctness of social relationships, and the timeliness of social data updates.
与上述方法实施例相对应,本说明书还提供了数据同步装置实施例,图3示出了本说明书一个实施例提供的一种数据同步装置的示意图。如图3所示,该装置包括:第一采集模块302,被配置为采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;第二采集模块304,被配置为采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;比对模块306,被配置为将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;同步模块308,被配置为在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。Corresponding to the foregoing method embodiments, the present specification also provides an embodiment of a data synchronization apparatus, and FIG. 3 shows a schematic diagram of a data synchronization apparatus provided by an embodiment of the present specification. As shown in FIG. 3 , the device includes: a first collection module 302, configured to collect social change data of the first user, update the data version number corresponding to the social change data, and generate a target data version number; The second collection module 304 is configured to collect the data version number corresponding to the social data associated with the social change data of the second user; the comparison module 306 is configured to compare the data version number corresponding to the social data with the The target data version numbers are compared; the synchronization module 308 is configured to synchronize the target data version numbers and the social change data to the second user as incremental data if the comparison is inconsistent.
可选地,所述的数据同步装置,还包括:指令接收模块,被配置为接收第一用户针对待修改社交数据提交的数据修改指令;更新模块,被配置为根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新;更新结果同步模块,被配置为将所述待修改数据的更新结果同步至第二用户。Optionally, the data synchronization device further includes: an instruction receiving module, configured to receive a data modification instruction submitted by the first user for the social data to be modified; an update module, configured to modify the instruction according to the data carried in the instruction The data modification information of the to-be-modified social data is updated; the update result synchronization module is configured to synchronize the update result of the to-be-modified data to the second user.
可选地,所述数据同步装置,还包括:版本号更新模块,被配置为基于所述待修改社交数据的更新结果对所述第一用户的第一社交数据对应的数据版本号进行更新,生成所述第一用户的第一社交数据对应的第一数据版本号。Optionally, the data synchronization apparatus further includes: a version number update module configured to update the data version number corresponding to the first social data of the first user based on the update result of the social data to be modified, A first data version number corresponding to the first social data of the first user is generated.
可选地,所述数据同步装置,还包括:用户确定模块,被配置为确定与所述第一用户存在社交关系的至少一个第二用户;数据获取模块,被配置为获取所述至少一个第二用户的第二社交数据中与所述第一用户存在关联关系的第二社交子数据,并确定所述第二社交子数据对应的第二数据子版本号;数据确定模块,被配置为确定所述第一用户的第一社交数据中与所述第二社交子数据存在关联关系的第一社交子数据,并确定所述第一社交子数据对应的第一数据子版本号;版本号比对模块,被配置为将所述第一数据子版本号与所述第二数据子版本号进行比对;数据同步模块,被配置为在比对不一致的情况下,将所述第一数据子版本号以及所述第一数据子版本号对应的第一社交子数据作为增量数据同步至所述第二用户。Optionally, the data synchronization apparatus further includes: a user determination module configured to determine at least one second user who has a social relationship with the first user; a data acquisition module configured to acquire the at least one first user The second social sub-data that is associated with the first user in the second social data of the two users, and the second data sub-version number corresponding to the second social sub-data is determined; the data determination module is configured to determine The first social sub-data that has an associated relationship with the second social sub-data in the first social data of the first user, and the first data sub-version number corresponding to the first social sub-data is determined; The pairing module is configured to compare the first data sub-version number with the second data sub-version number; the data synchronization module is configured to compare the first data sub-version number when the comparison is inconsistent. The version number and the first social sub-data corresponding to the first data sub-version number are synchronized to the second user as incremental data.
可选地,所述数据同步装置,还包括:第二用户确定模块,被配置为确定与所述第一用户存在社交关系的至少一个第二用户;第一登录状态检测模块,被配置为检测所述 至少一个第二用户的第一登录状态;若所述第一登录状态检测模块的运行结果为已登录,则运行所述同步模块。Optionally, the data synchronization apparatus further includes: a second user determination module configured to determine at least one second user who has a social relationship with the first user; a first login status detection module configured to detect The first login state of the at least one second user; if the operation result of the first login state detection module is logged in, the synchronization module is executed.
可选地,所述数据同步装置,还包括:若所述第一登录状态检测模块的运行结果为未登录,则运行存储模块;所述存储模块,被配置为在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;第二登录状态检测模块,被配置为检测所述至少一个第二用户的第二登录状态;若所述第二登录状态检测模块的运行结果为已登录,则运行第一增量数据同步模块;所述第一增量数据同步模块,被配置为将所述增量数据同步至所述第二用户。Optionally, the data synchronization device further includes: if the operation result of the first login status detection module is not logged in, then running a storage module; the storage module is configured to be in the case of inconsistent comparison, The target data version number and the social change data are stored as incremental data; the second login state detection module is configured to detect the second login state of the at least one second user; if the second login If the operation result of the status detection module is that the user is logged in, the first incremental data synchronization module is executed; the first incremental data synchronization module is configured to synchronize the incremental data to the second user.
可选地,所述数据同步装置,还包括:若所述第二登录状态检测模块的运行结果为已登录,则运行数据量检测模块;所述数据量检测模块,被配置为检测所述增量数据的数据量;若所述增量数据的数据量大于预设数据量阈值,则运行同步指令发送模块;所述同步指令发送模块,被配置为向所述至少一个第二用户发送数据同步指令;第二增量数据同步模块,被配置为响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。Optionally, the data synchronization device further includes: if the operation result of the second login status detection module is logged in, running a data volume detection module; the data volume detection module is configured to detect the increase If the data volume of the incremental data is greater than the preset data volume threshold, the synchronization command sending module is run; the synchronization command sending module is configured to send data synchronization to the at least one second user an instruction; a second incremental data synchronization module configured to synchronize the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
可选地,所述数据同步装置,还包括:数据变更频率确定模块,被配置为确定所述第一用户的第一社交数据的数据变更频率;若所述数据变更频率大于预设变更频率阈值,则运行存储模块;所述存储模块,被配置为将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;指令发送模块,被配置为在检测到所述增量数据的数据量大于预设数据量阈值的情况下,确定与所述第一用户存在社交关系的至少一个第二用户,并向所述至少一个第二用户发送数据同步指令;第三增量数据同步模块,被配置为响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。Optionally, the data synchronization apparatus further includes: a data change frequency determination module configured to determine the data change frequency of the first social data of the first user; if the data change frequency is greater than a preset change frequency threshold , then run the storage module; the storage module is configured to store the target data version number and the social change data as incremental data; the instruction sending module is configured to detect the incremental data When the data volume is greater than the preset data volume threshold, determine at least one second user that has a social relationship with the first user, and send a data synchronization instruction to the at least one second user; a third incremental data synchronization module is configured to synchronize the incremental data to the at least one second user in response to a data synchronization request sent by the at least one second user.
可选地,所述第一采集模块,包括:确定子模块,被配置为确定所述社交变更数据对应的变更时间;更新子模块,被配置为基于所述变更时间对所述数据版本号进行更新。Optionally, the first collection module includes: a determination sub-module configured to determine a change time corresponding to the social change data; an update sub-module configured to perform an update on the data version number based on the change time. renew.
可选地,所述同步模块,包括:同步子模块,被配置为与所述第二用户的用户终端建立长连接,通过所述长连接将所述目标数据版本号以及所述社交变更数据同步至所述用户终端,以将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。Optionally, the synchronization module includes: a synchronization sub-module configured to establish a long connection with the user terminal of the second user, and to synchronize the target data version number and the social change data through the long connection to the user terminal, so as to synchronize the target data version number and the social change data to the second user as incremental data.
上述为本实施例的一种数据同步装置的示意性方案。需要说明的是,该数据同步装置的技术方案与上述的数据同步方法的技术方案属于同一构思,数据同步装置的技术方案未详细描述的细节内容,均可以参见上述数据同步方法的技术方案的描述。The above is a schematic solution of a data synchronization apparatus according to this embodiment. It should be noted that the technical solution of the data synchronization device and the technical solution of the above-mentioned data synchronization method belong to the same concept, and the details that are not described in detail in the technical solution of the data synchronization device can be referred to the description of the technical solution of the above-mentioned data synchronization method. .
图4示出了根据本说明书一个实施例提供的一种计算设备400的结构框图。该计算设备400的部件包括但不限于存储器410和处理器420。处理器420与存储器410通过总线430相连接,数据库450用于保存数据。FIG. 4 shows a structural block diagram of a computing device 400 provided according to an embodiment of the present specification. Components of the computing device 400 include, but are not limited to, memory 410 and processor 420 . The processor 420 is connected with the memory 410 through the bus 430, and the database 450 is used for saving data.
计算设备400还包括接入设备440,接入设备440使得计算设备400能够经由一个或多个网络460通信。这些网络的示例包括公用交换电话网(PSTN)、局域网(LAN)、广域网(WAN)、个域网(PAN)或诸如因特网的通信网络的组合。接入设备440可以包括有线或无线的任何类型的网络接口(例如,网络接口卡(NIC))中的一个或多个,诸如IEEE802.11无线局域网(WLAN)无线接口、全球微波互联接入(Wi-MAX)接口、以太网接口、通用串行总线(USB)接口、蜂窝网络接口、蓝牙接口、近场通信(NFC)接口,等等。Computing device 400 also includes access device 440 that enables computing device 400 to communicate via one or more networks 460 . Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. Access device 440 may include one or more of any type of network interface (eg, network interface card (NIC)), wired or wireless, such as IEEE 802.11 wireless local area network (WLAN) wireless interface, World Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and the like.
在本说明书的一个实施例中,计算设备400的上述部件以及图4中未示出的其他部件也可以彼此相连接,例如通过总线。应当理解,图4所示的计算设备结构框图仅仅是 出于示例的目的,而不是对本说明书范围的限制。本领域技术人员可以根据需要,增添或替换其他部件。In one embodiment of the present specification, the above-described components of computing device 400 and other components not shown in FIG. 4 may also be connected to each other, such as through a bus. It should be understood that the structural block diagram of the computing device shown in FIG. 4 is only for the purpose of example, rather than limiting the scope of this specification. Those skilled in the art can add or replace other components as required.
计算设备400可以是任何类型的静止或移动计算设备,包括移动计算机或移动计算设备(例如,平板计算机、个人数字助理、膝上型计算机、笔记本计算机、上网本等)、移动电话(例如,智能手机)、可佩戴的计算设备(例如,智能手表、智能眼镜等)或其他类型的移动设备,或者诸如台式计算机或PC的静止计算设备。计算设备400还可以是移动式或静止式的服务器。Computing device 400 may be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (eg, tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (eg, smart phones) ), wearable computing devices (eg, smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. Computing device 400 may also be a mobile or stationary server.
其中,所述存储器410用于存储计算机可执行指令,处理器420用于执行如下计算机可执行指令:采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。The memory 410 is used for storing computer-executable instructions, and the processor 420 is used for executing the following computer-executable instructions: collecting social change data of the first user, and updating the data version number corresponding to the social change data, generating a target data version number; collecting a data version number corresponding to the social data associated with the social change data of the second user; comparing the data version number corresponding to the social data with the target data version number; In the case of inconsistency, the target data version number and the social change data are synchronized to the second user as incremental data.
上述为本实施例的一种计算设备的示意性方案。需要说明的是,该计算设备的技术方案与上述的数据同步方法的技术方案属于同一构思,计算设备的技术方案未详细描述的细节内容,均可以参见上述数据同步方法的技术方案的描述。The above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned data synchronization method belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned data synchronization method.
本说明书一实施例还提供一种计算机可读存储介质,其存储有计算机指令,该指令被处理器执行时以用于实现所述数据同步方法的步骤。An embodiment of the present specification further provides a computer-readable storage medium, which stores computer instructions, which are used to implement the steps of the data synchronization method when the instructions are executed by a processor.
上述为本实施例的一种计算机可读存储介质的示意性方案。需要说明的是,该存储介质的技术方案与上述的数据同步方法的技术方案属于同一构思,存储介质的技术方案未详细描述的细节内容,均可以参见上述数据同步方法的技术方案的描述。The above is a schematic solution of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the above-mentioned data synchronization method belong to the same concept, and the details not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the above-mentioned data synchronization method.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
所述计算机指令包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。The computer instructions include computer program code, which may be in source code form, object code form, an executable file, some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable media may 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, the computer-readable media Electric carrier signals and telecommunication signals are not included.
需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本说明书实施例并不受所描述的动作顺序的限制,因为依据本说明书实施例,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本说明书实施例所必须的。It should be noted that, for the convenience of description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the embodiments of this specification are not limited by the described action sequences. Limitation, because certain steps may be performed in other orders or simultaneously according to embodiments of the present specification. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary for the embodiments of the specification.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
以上公开的本说明书优选实施例只是用于帮助阐述本说明书。可选实施例并没有详 尽叙述所有的细节,也不限制该发明仅为所述的具体实施方式。显然,根据本说明书实施例的内容,可作很多的修改和变化。本说明书选取并具体描述这些实施例,是为了更好地解释本说明书实施例的原理和实际应用,从而使所属技术领域技术人员能很好地理解和利用本说明书。本说明书仅受权利要求书及其全部范围和等效物的限制。The preferred embodiments of the present specification disclosed above are provided only to aid in the elaboration of the present specification. Alternative embodiments are not intended to be exhaustive of all details nor to limit the invention to only the described embodiments. Obviously, many modifications and changes can be made in accordance with the contents of the embodiments of the present specification. These embodiments are selected and described in this specification to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can well understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims (13)

  1. 一种数据同步方法,包括:A data synchronization method, comprising:
    采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;collecting the social change data of the first user, and updating the data version number corresponding to the social change data to generate a target data version number;
    采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;collecting the data version number of the second user corresponding to the social data associated with the social change data;
    将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;Compare the data version number corresponding to the social data with the target data version number;
    在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。In the case of inconsistent comparison, the target data version number and the social change data are synchronized to the second user as incremental data.
  2. 根据权利要求1所述的数据同步方法,还包括:The data synchronization method according to claim 1, further comprising:
    接收第一用户针对待修改社交数据提交的数据修改指令;receiving a data modification instruction submitted by the first user for the social data to be modified;
    根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新;Update the social data to be modified according to the data modification information carried in the data modification instruction;
    将所述待修改数据的更新结果同步至第二用户。Synchronizing the update result of the data to be modified to the second user.
  3. 根据权利要求2所述的数据同步方法,所述根据所述数据修改指令中携带的数据修改信息对所述待修改社交数据进行更新之后,还包括:The data synchronization method according to claim 2, after updating the social data to be modified according to the data modification information carried in the data modification instruction, further comprising:
    基于所述待修改社交数据的更新结果对所述第一用户的第一社交数据对应的数据版本号进行更新,生成所述第一用户的第一社交数据对应的第一数据版本号。Based on the update result of the social data to be modified, the data version number corresponding to the first social data of the first user is updated to generate a first data version number corresponding to the first social data of the first user.
  4. 根据权利要求3所述的数据同步方法,还包括:The data synchronization method according to claim 3, further comprising:
    确定与所述第一用户存在社交关系的至少一个第二用户;determining at least one second user that has a social relationship with the first user;
    获取所述至少一个第二用户的第二社交数据中与所述第一用户存在关联关系的第二社交子数据,并确定所述第二社交子数据对应的第二数据子版本号;acquiring second social sub-data that is associated with the first user in the second social data of the at least one second user, and determining a second data sub-version number corresponding to the second social sub-data;
    确定所述第一用户的第一社交数据中与所述第二社交子数据存在关联关系的第一社交子数据,并确定所述第一社交子数据对应的第一数据子版本号;determining the first social sub-data that is associated with the second social sub-data in the first social data of the first user, and determining the first data sub-version number corresponding to the first social sub-data;
    将所述第一数据子版本号与所述第二数据子版本号进行比对;Comparing the first data subversion number with the second data subversion number;
    在比对不一致的情况下,将所述第一数据子版本号以及所述第一数据子版本号对应的第一社交子数据作为增量数据同步至所述第二用户。If the comparison is inconsistent, the first data sub-version number and the first social sub-data corresponding to the first data sub-version number are synchronized to the second user as incremental data.
  5. 根据权利要求1所述的数据同步方法,所述将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后,还包括:The data synchronization method according to claim 1, after the comparing the data version number corresponding to the social data with the target data version number, further comprising:
    确定与所述第一用户存在社交关系的至少一个第二用户;determining at least one second user that has a social relationship with the first user;
    检测所述至少一个第二用户的第一登录状态;detecting the first login status of the at least one second user;
    若所述至少一个第二用户的第一登录状态为已登录,则执行所述在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户的步骤。If the first login status of the at least one second user is logged in, execute the step of synchronizing the version number of the target data and the social change data as incremental data to the Steps for the second user.
  6. 根据权利要求5所述的数据同步方法,还包括:The data synchronization method according to claim 5, further comprising:
    若所述至少一个第二用户的登录状态为未登录,则在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;If the login status of the at least one second user is not logged in, in the case of inconsistent comparison, storing the target data version number and the social change data as incremental data;
    检测所述至少一个第二用户的第二登录状态;detecting a second login state of the at least one second user;
    若所述至少一个第二用户的第二登录状态为已登录,则将所述增量数据同步至所述第二用户。If the second login status of the at least one second user is logged in, the incremental data is synchronized to the second user.
  7. 根据权利要求6所述的数据同步方法,所述检测所述至少一个第二用户的第二登录状态之后,还包括:The data synchronization method according to claim 6, after the detecting the second login state of the at least one second user, further comprising:
    若所述至少一个第二用户的第二登录状态为已登录,则检测所述增量数据的数据量;If the second login status of the at least one second user is logged in, detecting the data volume of the incremental data;
    若所述增量数据的数据量大于预设数据量阈值,则向所述至少一个第二用户发送数据同步指令;If the data volume of the incremental data is greater than the preset data volume threshold, sending a data synchronization instruction to the at least one second user;
    响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。The incremental data is synchronized to the at least one second user in response to a data synchronization request sent by the at least one second user.
  8. 根据权利要求1所述的数据同步方法,所述将所述社交数据对应的数据版本号与所述目标数据版本号进行比对之后,还包括:The data synchronization method according to claim 1, after the comparing the data version number corresponding to the social data with the target data version number, further comprising:
    确定所述第一用户的第一社交数据的数据变更频率;determining a data change frequency of the first social data of the first user;
    若所述数据变更频率大于预设变更频率阈值,则将所述目标数据版本号以及所述社交变更数据作为增量数据进行存储;If the data change frequency is greater than a preset change frequency threshold, the target data version number and the social change data are stored as incremental data;
    在检测到所述增量数据的数据量大于预设数据量阈值的情况下,确定与所述第一用户存在社交关系的至少一个第二用户,并向所述至少一个第二用户发送数据同步指令;In the case where it is detected that the data volume of the incremental data is greater than a preset data volume threshold, determine at least one second user that has a social relationship with the first user, and send data synchronization to the at least one second user instruction;
    响应于所述至少一个第二用户发送的数据同步请求,将所述增量数据同步至所述至少一个第二用户。The incremental data is synchronized to the at least one second user in response to a data synchronization request sent by the at least one second user.
  9. 根据权利要求1所述的数据同步方法,所述对所述社交变更数据对应的数据版本号进行更新,包括:The data synchronization method according to claim 1, wherein the updating of the data version number corresponding to the social change data comprises:
    确定所述社交变更数据对应的变更时间;determining the change time corresponding to the social change data;
    基于所述变更时间对所述数据版本号进行更新。The data version number is updated based on the change time.
  10. 根据权利要求1所述的数据同步方法,所述将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户,包括:The data synchronization method according to claim 1, wherein the synchronization of the target data version number and the social change data to the second user as incremental data comprises:
    与所述第二用户的用户终端建立长连接,通过所述长连接将所述目标数据版本号以及所述社交变更数据同步至所述用户终端,以将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。establishing a long connection with the user terminal of the second user, and synchronizing the target data version number and the social change data to the user terminal through the long connection, so that the target data version number and the social Changed data is synchronized to the second user as incremental data.
  11. 一种数据同步装置,包括:A data synchronization device, comprising:
    第一采集模块,被配置为采集第一用户的社交变更数据,并对所述社交变更数据对应的数据版本号进行更新,生成目标数据版本号;a first collection module, configured to collect social change data of the first user, update the data version number corresponding to the social change data, and generate a target data version number;
    第二采集模块,被配置为采集第二用户的与所述社交变更数据关联的社交数据对应的数据版本号;a second collection module, configured to collect a data version number corresponding to the social data associated with the social change data of the second user;
    比对模块,被配置为将所述社交数据对应的数据版本号与所述目标数据版本号进行比对;A comparison module, configured to compare the data version number corresponding to the social data with the target data version number;
    同步模块,被配置为在比对不一致的情况下,将所述目标数据版本号以及所述社交变更数据作为增量数据同步至所述第二用户。The synchronization module is configured to synchronize the target data version number and the social change data to the second user as incremental data when the comparison is inconsistent.
  12. 一种计算设备,包括:A computing device comprising:
    存储器和处理器;memory and processor;
    所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令实现权利要求1至10任意一项所述数据同步方法的步骤。The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the data synchronization method of any one of claims 1 to 10.
  13. 一种计算机可读存储介质,其存储有计算机指令,该计算机指令被处理器执行时实现权利要求1至10任意一项所述数据同步方法的步骤。A computer-readable storage medium storing computer instructions, when the computer instructions are executed by a processor, implement the steps of the data synchronization method according to any one of claims 1 to 10.
PCT/CN2022/086611 2021-04-29 2022-04-13 Data synchronization method and apparatus WO2022228125A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110475659.2 2021-04-29
CN202110475659.2A CN113094441A (en) 2021-04-29 2021-04-29 Data synchronization method and device

Publications (1)

Publication Number Publication Date
WO2022228125A1 true WO2022228125A1 (en) 2022-11-03

Family

ID=76680882

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/086611 WO2022228125A1 (en) 2021-04-29 2022-04-13 Data synchronization method and apparatus

Country Status (2)

Country Link
CN (1) CN113094441A (en)
WO (1) WO2022228125A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113094441A (en) * 2021-04-29 2021-07-09 支付宝(杭州)信息技术有限公司 Data synchronization method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013116806A1 (en) * 2012-02-02 2013-08-08 Visa International Service Association Multi-source, multi-dimensional, cross-entity, multimedia database platform apparatuses, methods and systems
CN110333919A (en) * 2019-04-30 2019-10-15 上海连尚网络科技有限公司 A kind of method and apparatus that social object information is presented
CN110765335A (en) * 2019-10-21 2020-02-07 腾讯科技(深圳)有限公司 Processing method and device of personalized signature, electronic equipment and storage medium
CN112073300A (en) * 2020-08-28 2020-12-11 北京五八信息技术有限公司 Group data synchronization method and device
CN113094441A (en) * 2021-04-29 2021-07-09 支付宝(杭州)信息技术有限公司 Data synchronization method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104811976A (en) * 2015-04-02 2015-07-29 四川大学 Method and base station for improving group service airinterface analyzing capacity
CN111880956B (en) * 2020-07-24 2023-12-05 北京达佳互联信息技术有限公司 Data synchronization method and device
CN112187548A (en) * 2020-10-09 2021-01-05 深圳壹账通智能科技有限公司 Method, device and equipment for synchronously updating configuration data and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013116806A1 (en) * 2012-02-02 2013-08-08 Visa International Service Association Multi-source, multi-dimensional, cross-entity, multimedia database platform apparatuses, methods and systems
CN110333919A (en) * 2019-04-30 2019-10-15 上海连尚网络科技有限公司 A kind of method and apparatus that social object information is presented
CN110765335A (en) * 2019-10-21 2020-02-07 腾讯科技(深圳)有限公司 Processing method and device of personalized signature, electronic equipment and storage medium
CN112073300A (en) * 2020-08-28 2020-12-11 北京五八信息技术有限公司 Group data synchronization method and device
CN113094441A (en) * 2021-04-29 2021-07-09 支付宝(杭州)信息技术有限公司 Data synchronization method and device

Also Published As

Publication number Publication date
CN113094441A (en) 2021-07-09

Similar Documents

Publication Publication Date Title
US10831802B2 (en) Techniques to respond to user requests using natural-language machine learning based on example conversations
EP2783501B1 (en) Contact information synchronization system and method
CN110598280B (en) Equipment simulation system and method and computer readable storage medium
EP3350976B1 (en) Synchronizing file data between computer systems
CN104283926B (en) A kind of method of data synchronization, device and server
CN107204999B (en) Method and device for realizing heartbeat
US20160156703A1 (en) Method and Device for Interworking Between Different Otts
TWI756688B (en) Credit-based interactive credit assessment method and device, computing device and computer-readable storage medium therefor
SG183255A1 (en) Method, system and group server for synchronizing operations of multiple groups
WO2022228125A1 (en) Data synchronization method and apparatus
CN112642146A (en) Data processing method and device
CN110620784A (en) Credit-based interactive processing method and device
CN112003943A (en) Voice data synchronization method and device
CN109218418A (en) Method of data synchronization and device calculate equipment and storage medium
CN112929257B (en) Multi-scene message sending method, device, server and storage medium
CN112069154B (en) etcd distributed database automatic operation and maintenance method and related device
WO2024051195A1 (en) Data calling method and apparatus, and serving gateway and storage medium
US11201918B2 (en) Minimizing number of synchs
WO2023186154A1 (en) Data transmission system and method
WO2023020092A1 (en) Multi-person collaboration-based resource processing method, apparatus and system
CN112637009B (en) Data link detection system, method and device
CN109728937A (en) A kind of method and device of the updating network state of voice mould group
CN112231414B (en) Data synchronization method and device of block chain system, readable medium and electronic equipment
CN110661857B (en) Data synchronization method and device
CN113420874A (en) Gradient synchronization method in distributed training and distributed training system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22794596

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22794596

Country of ref document: EP

Kind code of ref document: A1