Data synchronization method and device, electronic equipment, system and medium
By storing and transmitting data in the form of key-value pairs during the data synchronization process, the problems of low success rate and high cost of data synchronization caused by URL length limitation and special character encoding and decoding processing in the prior art are solved, and a more efficient and economical data synchronization effect is achieved.
Patent Information
- Application Number
- CN202510124452.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-06-06
AI Technical Summary
The prior art has problems of low success rate and high cost due to URL length limitations and special character encoding and decoding processing in GET requests during data synchronization.
Data is stored and transmitted in the form of key-value pair data. By storing key-value pair data in the database and sending keys in the key-value pair data to the second data end, the second data end makes the query according to the key and performs synchronization processing.
It improves the success rate of data synchronization, reduces the processing cost of data synchronization, and simplifies the process of data synchronization.
Smart Images

Figure CN120104694A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of communication technology, and in particular, to a data synchronization method, device, electronic device, system and medium. Background Art
[0002] In today's era of rapid development of communication technology, enterprise data systems often have different data terminals in different regions, and the synchronization of business data between these data terminals is crucial. For example, a user is on a business trip in the first region and activates membership benefits based on page operations. After activation, the membership benefits take effect in the first region, and the first data terminal in the first region needs to synchronize the membership benefits to other regions such as the second region.
[0003] Reference Figure 1 , shows a flow chart of a data synchronization method in the prior art, which uses the parameters of the URL (Uniform Resource Locator) contained in the GET (get) request to carry the business data to be synchronized. Specifically, the first data terminal encodes the business data A to be synchronized into a GET request and sends the first GET request to the second data terminal. After receiving the first GET request, the second data terminal decodes the business data A from the parameters of the URL contained in the first GET request. The second data terminal can also modify the business data A to obtain business data B, encode the business data B into a second GET request, and send the second GET request to the third data terminal. Among them, the first data terminal, the second data terminal and the third data terminal are data terminals in different regions, which are used to generate business data in their respective regions, or to synchronize business data generated in other regions.
[0004] In actual applications, in order to improve the performance and stability of transmission, the application environment limits the length of the URL in the GET request. This limitation may lead to a series of problems such as incomplete business data. For example, if the business data exceeds the length limit of the URL in the GET request, the excess business data will not be successfully transmitted, which will affect the success rate of data synchronization.
[0005] In addition, the business data may contain some special characters, such as spaces, question marks, percent signs, etc. Since these special characters have specific meanings in the URL, the sender of the GET request in the related art needs to convert the special characters in the business data into URL parameters based on encoding processing, and correspondingly, the receiver of the GET request needs to convert the URL parameters into business data based on decoding processing. The above encoding and decoding processing increases the cost of data synchronization. Summary of the invention
[0006] The purpose of the embodiments of the present invention is to provide a data synchronization method, device, electronic device, and medium, which can improve the success rate of data synchronization and reduce the processing cost of data synchronization.
[0007] The specific technical solutions are as follows:
[0008] In a first aspect of the implementation of the present invention, a data synchronization method is provided, which is applied to a first data terminal, and the method includes:
[0009] generating business data in response to user operations;
[0010] Determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0011] Generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, generate a key in the key-value pair data; the transmitted data is used as a value in the key-value pair data;
[0012] Save the key-value pair data in a database;
[0013] The key in the key-value pair data is sent to the second data end, so that the second data end queries the transmitted data corresponding to the key from the key-value pair data stored in the database according to the key.
[0014] In a second aspect of the present invention, a data synchronization method is provided, which is applied to a second data terminal, and the method includes:
[0015] receiving a key in a key-value pair data from a first data terminal; the first data terminal is a data terminal of a first region; the second data terminal is a data terminal of a second region; the first region and the second region are different regions;
[0016] According to the key, query the query result corresponding to the key from the key-value pair data stored in the database;
[0017] Determine whether the query result contains a completion mark to obtain a first determination result;
[0018] If the first judgment result is no, then judging whether the processing end identifier in the query result matches the data end identifier of the device, and obtaining a second judgment result;
[0019] If the second judgment result is yes, the business data in the query result is synchronized to obtain a synchronization result; the synchronization is used to synchronize the user rights and interests corresponding to the business data within a preset area;
[0020] After the synchronization process is completed, the business data in the query result is replaced with the synchronization process result, and a completion mark is added to the query result to obtain the updated data;
[0021] Update the query results in the database with the updated data.
[0022] In a third aspect of the present invention, a data synchronization system is provided, the system comprising: a first data terminal and a second data terminal; the first data terminal is a data terminal of a first region; the second data terminal is a data terminal of a second region; the first region and the second region are different regions;
[0023] The first data end generates business data in response to user operation; determines the data to be transmitted; the transmitted data includes: business data and a processing end identifier; the processing end identifier is used to characterize the data end that processes the business data; generates key-value pair data corresponding to the first transmitted data; wherein, for the first transmitted data, generates a key in the key-value pair data; the first transmitted data is used as a value in the key-value pair data; saves the key-value pair data in a database; and sends the key in the key-value pair data to the second data end;
[0024] The second data end receives the key in the key-value pair data from the first data end; based on the key, queries the query result corresponding to the key from the key-value pair data stored in the database; determines whether the query result contains a completion mark to obtain a first judgment result; if the first judgment result is no, the second data end determines whether the processing end mark in the query result matches its own data end mark to obtain a second judgment result; if the second judgment result is yes, the second data end synchronizes the business data in the query result to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area; after completing the synchronization processing, replace the business data in the query result with the synchronization processing result, and add a completion mark to the query result to obtain updated business data; and update the query result in the database to the updated business data.
[0025] In a fourth aspect of the implementation of the present invention, a data synchronization device is provided, the device is applied to a first data end, the first data end is a data end of a first region, and the device includes:
[0026] A business data generation module, used to generate business data in response to user operations;
[0027] The data determination module is used to determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0028] A key-value pair generation module, used to generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, a key in the key-value pair data is generated; and the transmitted data is used as a value in the key-value pair data;
[0029] A key-value pair storage module, used for storing the key-value pair data in a database;
[0030] A key sending module is used to send the key in the key-value pair data to the second data end, so that the second data end can query the query result corresponding to the key from the key-value pair data saved in the database according to the key, so that the second data end matching the processing end identifier can synchronize the business data to obtain the synchronization processing result; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area; the second data end is the data end of the second area; the first area and the second area are different areas.
[0031] In a fifth aspect of the implementation of the present invention, a data synchronization device is provided, the device being applied to a second data terminal, comprising:
[0032] A receiving module, used for receiving a key in a key-value pair data from a first data end; the first data end is a data end of a first region; the second data end is a data end of a second region; the first region and the second region are different regions;
[0033] A query module, used to query the query result corresponding to the key from the key-value pair data stored in the database according to the key;
[0034] A completion judgment module is used to judge whether the query result contains a completion mark, and obtain a first judgment result;
[0035] The identification judgment module is used to judge whether the processing end identification in the query result matches the data end identification of the processor itself if the first judgment result is no, so as to obtain a second judgment result;
[0036] A synchronization processing module, for performing synchronization processing on the business data in the query result to obtain a synchronization processing result if the second judgment result is yes; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area;
[0037] The replacement module is used to replace the business data in the query result with the synchronization result after the synchronization process is completed, and add a completion mark to the query result to obtain the updated data;
[0038] The update module is used to update the query results in the database to the updated data.
[0039] In a sixth aspect of the present invention, there is also provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0040] Memory, used to store computer programs;
[0041] The processor is used to implement the aforementioned method steps when executing the program stored in the memory.
[0042] In a seventh aspect of the implementation of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute any of the above-described methods.
[0043] The data synchronization method, device, electronic device and medium provided by the embodiments of the present invention, after the first data end generates business data and determines the transmitted data in response to the user operation, stores the transmitted data in the form of KV (key-value pair data, key value), saves the key-value pair data in the database, and sends the key (key) in the key-value pair data to the second data end, so that the second data end can query the query result corresponding to the above key from the key-value pair data saved in the above database according to the above key, and make the second data end matching the processing end identifier synchronize the business data to obtain the synchronization processing result.
[0044] The embodiment of the present invention uses the key as the transmission content between the first data end and the second data end. Since the first data end only needs to send the key to the second data end, and the length of the key is usually short, it can meet the length requirement of the URL in the GET request; in this way, the embodiment of the present invention can effectively avoid the situation where the transmission failure is caused by the limited length of the transmission content, thereby improving the key transmission success rate, and then improving the data synchronization success rate.
[0045] In addition, the embodiment of the present invention only transmits the key in the key-value pair data, and the length of the key is usually smaller than the length of the transmitted data, which greatly reduces the amount of data transmitted over the network. Since a smaller amount of data means faster transmission speed, lower network bandwidth occupancy, and less resource consumption, the embodiment of the present invention can reduce data synchronization costs.
[0046] Furthermore, since the embodiment of the present invention only transmits the key in the key-value pair data and does not involve the transmission of the data itself, it can save the encoding processing of the transmitted data by the first data end and the decoding processing of the transmitted data by the second data end. Therefore, the embodiment of the present invention can simplify the data synchronization process and further reduce the data processing cost of the data end. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0048] Figure 1 A flowchart of a data synchronization method in the prior art;
[0049] Figure 2 A flowchart of a data synchronization method according to an embodiment of the present invention;
[0050] Figure 3 A flowchart of a data synchronization method according to an embodiment of the present invention;
[0051] Figure 4 A flowchart of a data synchronization method according to an embodiment of the present invention;
[0052] Figure 5 A schematic diagram of a data synchronization method according to an embodiment of the present invention;
[0053] Figure 6 A schematic diagram of the structure of a data synchronization system according to an embodiment of the present invention;
[0054] Figure 7 A schematic diagram of the structure of a data synchronization device according to an embodiment of the present invention;
[0055] Figure 8 A schematic diagram of the structure of a data synchronization device according to an embodiment of the present invention;
[0056] Fig. 9 The structure block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0058] The data synchronization method according to the embodiment of the present invention can be used to synchronize business data between two data terminals or more than two data terminals.
[0059] The data end of the embodiment of the present invention may be a client or a server. For example, the embodiment of the present invention may transmit data between a client and a server. Alternatively, the embodiment of the present invention may transmit data between different clients. Alternatively, the embodiment of the present invention may transmit data between different servers.
[0060] Business data refers to data that is closely related to various business activities and has actual business significance during the operation of an enterprise. It covers all kinds of information generated, collected, processed and used from the business process. These data play a key role in the decision-making, business operation management and service provision of the enterprise.
[0061] Taking the video platform as an example, business data may include user-related data, such as user registration information, membership rights status, user level, points, etc.; video-related data, such as basic video information, classification, copyright information, playback volume, etc.; interaction-related data, such as comment content, likes and collection records, user interaction behavior, etc.; and operation-related data, such as advertising placement records, platform activity participation data, etc.
[0062] The prior art generally uses the parameters of the URL contained in the GET request to carry the business data to be synchronized.
[0063] However, application environments such as browsers or servers limit the length of the URL in a GET request. In this way, if the business data exceeds the length limit of the URL in a GET request, the excess business data will not be successfully transmitted. In addition, the use of GET requests requires encoding processing at the sender and decoding processing at the receiver, which increases the processing cost of data synchronization.
[0064] In view of the technical problems of low success rate of data synchronization and high processing cost of data synchronization in the related art, an embodiment of the present invention provides a data synchronization method, which can be applied to a first data end, where the first data end is a data end of a first region, and the method specifically includes:
[0065] generating business data in response to user operations;
[0066] Determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0067] Generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, generate a key in the key-value pair data; the transmitted data is used as a value in the key-value pair data;
[0068] Save the above key-value pair data in the database;
[0069] The key in the key-value pair data is sent to the second data terminal, so that the second data terminal queries the query result corresponding to the key from the key-value pair data stored in the database according to the key, so that the second data terminal matching the processing terminal identifier performs synchronization processing on the business data to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area; the second data terminal is a data terminal of the second area; the first area and the second area are different areas.
[0070] After the first data end of an embodiment of the present invention generates business data and determines the transmitted data in response to user operations, it stores the transmitted data in the form of KV, saves the key-value pair data in a database, and sends the key (key) in the key-value pair data to the second data end, so that the second data end can query the query result corresponding to the above key from the key-value pair data saved in the above database according to the above key, and enable the second data end matching the processing end identifier to synchronize the business data to obtain a synchronization processing result.
[0071] The embodiment of the present invention uses the key as the transmission content between the first data end and the second data end. Since the first data end only needs to send the key to the second data end, and the length of the key is usually short, it can meet the length requirement of the URL in the GET request; in this way, the embodiment of the present invention can effectively avoid the situation where the transmission failure is caused by the limited length of the transmission content, thereby improving the key transmission success rate, and then improving the data synchronization success rate.
[0072] In addition, the embodiment of the present invention only transmits the key in the key-value pair data, and the length of the key is usually smaller than the length of the transmitted data, which greatly reduces the amount of data transmitted over the network. Since a smaller amount of data means faster transmission speed, lower network bandwidth occupancy, and less resource consumption, the embodiment of the present invention can reduce data synchronization costs.
[0073] Furthermore, since the embodiment of the present invention only transmits the key in the key-value pair data and does not involve the transmission of the data itself, it can save the encoding processing of the transmitted data by the first data end and the decoding processing of the transmitted data by the second data end. Therefore, the embodiment of the present invention can simplify the data synchronization process and thus reduce the cost of data synchronization.
[0074] The embodiments of the present invention are described below through specific examples.
[0075] Reference Figure 2 , shows a flow chart of steps of a data synchronization method according to an embodiment of the present invention, the method is applied to a first data terminal, the first data terminal may be a data terminal of a first region, and specifically may include the following steps:
[0076] Step 201: Generate business data in response to user operation;
[0077] Step 202: determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0078] Step 203: Generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, generate a key in the key-value pair data; the transmitted data is used as a value in the key-value pair data;
[0079] Step 204: Save the key-value pair data in the database;
[0080] Step 205: Send the key in the key-value pair data to the second data terminal, so that the second data terminal can query the query result corresponding to the key from the key-value pair data stored in the database according to the key, so that the second data terminal matching the processing terminal identifier can synchronize the business data to obtain a synchronization result; the synchronization is used to synchronize user rights and interests corresponding to the business data within a preset area; the second data terminal is a data terminal of the second area; the first area and the second area are different areas.
[0081] Figure 2 The illustrated method embodiment may be used to synchronize user rights-related business data from a first data terminal to a second data terminal.
[0082] User rights refer to the sum of all rights and benefits enjoyed by users in the process of using products or services. It covers many aspects, including but not limited to the user's right to control their own data, the basic right to use products or services, the right to enjoy specific services and functions, and the right to obtain corresponding guarantees and support.
[0083] The embodiments of the present invention do not limit specific user rights. Examples of user rights are as follows:
[0084] Membership rights: users pay to open different levels of membership and enjoy privileges such as exclusive content viewing and no ads;
[0085] User level benefits: upgrading the level based on user activity and spending amount can unlock special benefits such as priority customer service and exclusive discounts;
[0086] Contracted user rights: Users who sign a cooperation or service agreement with the platform can obtain customized services, exclusive cooperation resource use and other rights;
[0087] Points rights: users can earn points through consumption and participation in activities, which can be redeemed for gifts, coupons or virtual items; priority purchase rights: when new products are released or limited-time sales are launched, specific users can place orders for their favorite products first with this right;
[0088] After-sales protection rights: after purchasing goods or services, users can enjoy after-sales support services such as free repairs, returns and exchanges for a certain period of time.
[0089] The first data end may be a data end of the first region, and the second data end may be a data end of the second region; the first region and the second region are different regions.
[0090] The regions in the embodiments of the present invention refer to different ranges divided based on physical locations, and each region is equipped with an independent data terminal. These physical regions can be different cities, countries or continents. For example, the first region is Beijing, and the second region is Shanghai. Or, the first region is country A, the second region is country B, and so on. The data terminals in different regions are responsible for processing the business data generated in their respective regions, and through a specific data synchronization method, such as the method provided in the embodiments of the present invention, the synchronization of business data between different physical regions is achieved to ensure the consistency and coordination of business data in each region.
[0091] In one example, a user is on a business trip in a first region and activates membership benefits based on page operations. After activation, the membership benefits take effect in the first region, and the first data terminal in the first region needs to synchronize the membership benefits to other regions such as the second region.
[0092] In step 201, the first data terminal can convert the operation initiated by the user on the front end into business data that can be understood, processed and stored by the computer. When the user performs an operation on the page (such as opening a membership benefit), the front end can sense and capture this behavior and collect various types of information related to the operation. This information includes not only the content directly input or selected by the user, but also hidden information such as user identity and operating environment.
[0093] The first data terminal can integrate and process this information and generate a complete business data according to the pre-set data structure and rules. The business data can be data related to user rights and interests. It can be understood that the embodiment of the present invention does not limit the specific information contained in the business data.
[0094] In step 202, the transmitted data specifically includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data.
[0095] For example, in the scenario where a user activates membership benefits, the business data records detailed information related to the membership activation, such as user ID (identity), membership package type, activation time, etc.
[0096] The processing end identifier can be specified by the first data end. The first data end can determine the processing end identifier based on the functional responsibility information of other data ends. For example, some data ends are good at data verification, while others focus on business logic processing, so as to accurately match business data to the most appropriate data end for processing.
[0097] In step 203, the first data end may generate key-value pair data corresponding to the transmitted data.
[0098] The embodiments of the present invention can generate a unique key. The above uniqueness means that it is unique within a service system or a business system. This means that during the operation of the service system or the business system, no matter what kind of data operation, transaction processing or information interaction is performed, the generated key can clearly identify a specific object, transaction or state, and will not be confused with other keys already in the system. For example, in an e-commerce transaction scenario, the generated key can clearly identify a specific order.
[0099] In practical applications, the process of generating the key in the key-value pair data for the transmitted data may specifically include: step A1 or step A2.
[0100] Wherein, step A1, for the transmitted data, generate a UUID (Universally Unique Identifier) as a key in the key-value pair data;
[0101] Step A2: encrypt the unique target data in the transmitted data to obtain the key in the key-value pair data.
[0102] For step A1, the universal unique identifier is intended to provide a unique identifier for objects in a distributed system, so that it is very unlikely that duplicate identifiers will be generated at different time nodes and spatial regions. UUIDs are usually generated based on random numbers, have extremely high randomness, and are difficult to guess or forge. UUIDs are usually a 128-bit number presented in hexadecimal form.
[0103] In one implementation, a UUID can be generated for the transmitted data according to a time-based UUID generation method. The method uses the computer's MAC (Media Access Control) address and timestamp to generate a UUID. The MAC address is a unique identifier for the device where the first data end is located, and the timestamp records the time when the UUID is generated. By combining the MAC address and the high-precision timestamp together, and then processing them through a certain algorithm, a unique identifier can be generated. Specifically, it obtains the current time of the system, accurate to the nanosecond level, and then combines it with the MAC address to obtain a UUID.
[0104] In another implementation, a UUID generation method based on random numbers may be used to generate a UUID for the transmitted data.
[0105] The method first generates a random number of preset digits, and then organizes the random number according to the UUID format to obtain a UUID.
[0106] Taking a 128-bit random number as an example, the process of organizing the random number in the UUID format includes:
[0107] Divide the 128-bit number from left to right. The first 32 bits (binary) are converted to hexadecimal as the first group, with a length of 8 hexadecimal digits. Then, starting from the 33rd bit, take the next 16 bits (binary) and convert them to hexadecimal as the second group, with a length of 4 hexadecimal digits. Starting from the 49th bit, take the next 16 bits (binary) and convert them to hexadecimal as the third group, with a length of 4 hexadecimal digits. Starting from the 65th bit, take the next 16 bits (binary) and convert them to hexadecimal as the fourth group, with a length of 4 hexadecimal digits. Finally, starting from the 81st bit, take the remaining 48 bits (binary) and convert them to hexadecimal as the fifth group, with a length of 12 hexadecimal digits.
[0108] For step A2, the unique target data in the transmitted data may include any one or combination of the following business features: order number, transaction serial number, user ID (identity), etc. The unique target data in the transmitted data is encrypted, and the encryption method used may include but is not limited to: symmetric encryption algorithm, asymmetric encryption algorithm, or hash algorithm, etc. The encryption result obtained by the above encryption process can be used as the key in the key-value pair data.
[0109] Those skilled in the art can determine the length of the key in the key-value pair data according to actual application requirements, and the length of the key can be less than the upper limit of the length of the URL in the GET request. For example, in a certain application environment, the upper limit of the length of the URL in the GET request is 2048 characters, and the length of the key can be less than 2048 characters. For example, the length of the key can be 128 characters, etc.
[0110] The above-mentioned transmitted data is used as the value in the above-mentioned key-value pair data. Assuming that the transmitted data A specifically includes: order number, user information and product information, the example of the key-value pair data is as follows:
[0111] key: "hash_key_abc123" / / You can perform hash calculation on the order number to get the key
[0112] Value:
[0113] {
[0114] "orderNumber":"24680", / / Order number
[0115] "userInfo":{
[0116] "username":"user3", / / user name
[0117] "email":user3@example.com / / user email address
[0118] },
[0119] "productInfo":{
[0120] "productName":"productC", / / product name
[0121] "price":200 / / Product price
[0122] }
[0123] }
[0124] In step 204, various databases may support storing key-value pair data.
[0125] For example, Redis (Remote Dictionary Server) is an open source in-memory data structure storage system that is specifically designed to handle key-value data. It has high performance, rich data structures (such as strings, lists, hashes, sets, ordered sets, etc.) and powerful features such as data expiration, publish / subscribe, etc. Redis is very suitable for storing key-value data that needs to be read and written quickly, and can be used as a cache, message queue, etc.
[0126] For example, Memcached (Memory Cache Daemon) is a high-performance distributed memory object caching system, which is mainly used to store key-value data to accelerate dynamic Web (network) applications. It reduces the number of database accesses and improves performance by caching data in memory.
[0127] It should be noted that, in order to enhance the security of data synchronization, the value in the key-value pair data stored in the database in the embodiment of the present invention may be encrypted data for transmission. The embodiment of the present invention may use a preset encryption algorithm to encrypt the transmitted data to obtain encrypted data for transmission. The embodiment of the present invention does not limit the specific preset encryption algorithm. For example, the preset encryption algorithm may include, but is not limited to: a symmetric encryption algorithm, an asymmetric encryption algorithm, or a hash algorithm, etc.
[0128] In step 205, the first data terminal may send the key in the key-value pair data to the second data terminal, so that the second data terminal may query the query result corresponding to the key from the key-value pair data stored in the database according to the key, so that the second data terminal matching the processing terminal identifier may synchronize the business data to obtain a synchronization result; the synchronization is used to synchronize user rights and interests corresponding to the business data within a preset area; the second data terminal is a data terminal of the second area; the first area and the second area are different areas.
[0129] The second data end may include: a data end corresponding to the processing end identifier, and the second data end may also be different from the data end corresponding to the processing end identifier.
[0130] In practical applications, the first data end can use a GET request to send the key in the key-value pair data to the second data end. Specifically, the key can be carried by using the parameters of the URL contained in the GET request. Since the length of the key is usually short, it can meet the length requirement of the URL in the GET request; in this way, the embodiment of the present invention can effectively avoid the situation where the transmission fails due to the limited length of the transmitted content.
[0131] It should be noted that the first data end of the embodiment of the present invention can also provide the second data end with the connection information of the database, so that the second data end can access the database according to the connection information. The above connection information specifically includes: the host address, port number and database number of the server where the database is located. It can be understood that the embodiment of the present invention does not limit the specific connection information.
[0132] For example, the first data end may send the database connection information to the second data end by using a message queue, HTTP (Hypertext Transfer Protocol) interface call, or cloud service data transmission.
[0133] In addition, it should be noted that multiple data terminals in the service system can pre-agree on the connection information of the database. In this way, multiple data terminals in the service system can not only store the generated key-value pair data in the pre-agreement database (hereinafter referred to as the preset database), but also query the required transmitted data in the pre-agreement database according to the received key. The preset database is used to store the key-value pair data in the data synchronization process.
[0134] For example, the first data end may connect to a preset database according to the connection information, and after the connection is successful, store a key-value pair data A in the preset database.
[0135] For example, the second data end can first extract the target information such as the host address, port number and database number of the preset database from the connection information; then, construct an access address based on the target information and the key in the key-value pair data A; the format of the access address can be "redis: / / host address:port number / database number / key"; then, based on the access address, query the query result corresponding to the key from the key-value pair data saved in the preset database.
[0136] In an optional implementation, after the first data end sends the key in the above-mentioned key-value pair data to the second data end, the above-mentioned method may also include: according to a preset time period, according to the key, querying the query result corresponding to the key from the key-value pair data saved in the database; judging whether the query result contains a completion mark, if so, saving the query result locally, otherwise, returning to execute the step of querying the query result corresponding to the key from the key-value pair data saved in the database according to the key according to the preset time period.
[0137] This periodic query behavior can continuously monitor the processing progress of business data. By determining whether the query result contains a completion mark, the first data end can accurately grasp the processing status of the business data. Once the completion mark is detected, the query result is immediately saved locally to ensure that the synchronization processing results can be obtained in time and realize real-time synchronization of data. If the completion mark is not detected, the query steps are repeated and tracking is continued until the processed data is obtained.
[0138] In summary, the data synchronization method of the embodiment of the present invention uses the key as the transmission content between the first data end and the second data end. Since the first data end only needs to send the key to the second data end, and the length of the key is usually short, it can meet the length requirement of the URL in the GET request; in this way, the embodiment of the present invention can effectively avoid the situation where transmission failure is caused by the limited length of the transmission content, thereby improving the key transmission success rate, and then improving the data synchronization success rate.
[0139] In addition, the embodiment of the present invention only transmits the key in the key-value pair data, and the length of the key is usually smaller than the length of the transmitted data, which greatly reduces the amount of data transmitted over the network. Since a smaller amount of data means faster transmission speed, lower network bandwidth occupancy, and less resource consumption, the embodiment of the present invention can reduce the cost of data synchronization.
[0140] Furthermore, since the embodiment of the present invention only transmits the key in the key-value pair data and does not involve the transmission of the data itself, it can save the encoding processing of the transmitted data by the first data end and the decoding processing of the transmitted data by the second data end. Therefore, the embodiment of the present invention can simplify the data synchronization process and thus reduce the cost of data synchronization.
[0141] Reference Figure 3 , shows a flow chart of the steps of a data synchronization method according to an embodiment of the present invention, the method is applied to the second data terminal, and specifically may include the following steps:
[0142] Step 301, receiving a key in a key-value pair data from a first data end; the first data end is a data end of a first region; the second data end is a data end of a second region; the first region and the second region are different regions;
[0143] Step 302: According to the key, query the query result corresponding to the key from the key-value pair data stored in the database;
[0144] Step 303: determine whether the query result contains a completion mark, and obtain a first determination result;
[0145] Step 304: If the first judgment result is no, determine whether the processing end identifier in the query result matches the data end identifier of the device, and obtain a second judgment result;
[0146] Step 305: If the second judgment result is yes, the business data in the query result is synchronized to obtain a synchronization result; the synchronization is used to synchronize user rights and interests corresponding to the business data within a preset area;
[0147] Step 306: After the synchronization process is completed, the business data in the query result is replaced with the synchronization process result, and a completion mark is added to the query result to obtain the updated business data;
[0148] Step 307: Update the query results in the database to updated business data.
[0149] Figure 3 In the illustrated method embodiment, the second data end may perform synchronization-related processing on the key in the key-value pair data.
[0150] In step 301, the second data end may receive the key in the key-value pair data from the first data end by using a GET request. Specifically, the second data end may obtain the specific content of the key from the GET request.
[0151] For example, an example GET request is as follows:
[0152] GET / path? param1=value1¶m2=value2&...HTTP / 1.1
[0153] Host:example.com
[0154] Host represents the information of the target host of the transmission. In the scenario of data transmission from the first data end to the second data end, the target host can be the second data end. The " / path" part is usually called the request path or resource path. param1 and param2 represent parameter names respectively.
[0155] If there is a parameter named "key", such as:
[0156] GET / path? key=some_value&otherParam=another_value HTTP / 1.1
[0157] Host:example.com
[0158] Then, in this request, "some_value" is the content of the key "key".
[0159] In step 302, the second data terminal may obtain the connection information of the preset database in advance. In this way, the process of the second data terminal querying the query result corresponding to the above key from the key-value pair data stored in the database specifically includes: firstly extracting the target information such as the host address, port number and database number of the preset database from the connection information; then, constructing the access address according to the target information and the key in the key-value pair data A; the format of the access address may be "redis: / / host address:port number / database number / key"; then, according to the access address, querying the query result corresponding to the key from the key-value pair data stored in the preset database.
[0160] In order to enhance the security of data synchronization, the values in the key-value pair data stored in the database in the embodiment of the present invention may be encrypted transmitted data. In this way, the second data terminal may first query the encrypted transmitted data corresponding to the above key from the database, and then decrypt the encrypted transmitted data to obtain the query result. Among them, decrypting the encrypted transmitted data may be the reverse process of encrypting the transmitted data. The embodiment of the present invention does not limit the specific decryption process.
[0161] In step 303, the processing status of the business data is determined by checking whether there is a specific completion mark in the query result of the key-value pair data stored in the database. The completion mark is used as a mark to indicate whether the business data has completed the corresponding processing flow.
[0162] Specifically, after obtaining the query results, the second data end will traverse and check the query results to see whether a pre-set completion mark (such as a specific string or Boolean value) is included therein.
[0163] By determining whether the query result contains a completion mark, it is possible to avoid repeated processing of business data that has already been processed, so that the processing flow of business data will not be repeated, thereby improving the efficiency and accuracy of data synchronization.
[0164] In step 304, the processing terminal identifier is a mark used to identify the data terminal responsible for processing the service data. The processing terminal identifier in the query result is compared with the data terminal identifier of the second data terminal itself to determine whether the second data terminal is the data terminal responsible for processing the service data.
[0165] In a specific implementation, the second data end extracts the processing end identifier in the query result, and performs a string comparison (if the identifier is in string form) or a numerical comparison (if the identifier is in numerical form) on the processing end identifier with its own data end identifier.
[0166] By judging whether the processing end identifier in the query result matches the data end identifier of the user, only the designated processing end can process the business data, thus avoiding processing conflicts between different data ends.
[0167] In step 305, after determining that the second data terminal is a suitable data terminal responsible for processing the business data, the second data terminal synchronously processes the business data in the query result.
[0168] In one example, the synchronization process specifically includes: updating the regional scope of the user rights and interests contained in the business data to a preset regional scope; the preset regional scope includes: a first region and a second region, so that the user rights and interests corresponding to the business data can be consistent within the preset regional scope. Of course, the preset regional scope can also be a global scope or a national scope, and the embodiment of the present invention does not limit the specific preset regional scope.
[0169] In another example, the synchronization processing specifically includes: determining whether the user in the business data hits the blacklist. If so, the synchronization processing result may include: user rights restriction information, such as user rights restriction status, restricted scope, operation log records, blacklist marks, and possible notification information. User rights restriction information can prevent the user from obtaining corresponding rights within a preset area, such as restricting the user from using membership privileges, purchasing specific goods or services, etc.
[0170] If the user in the business data does not hit the blacklist, the regional scope of the user rights and interests included in the business data can be updated to a preset regional scope.
[0171] In specific implementation, a blacklist can be established based on the user's abnormal login behavior and illegal and irregular behavior. In terms of abnormal login behavior, if a user account frequently logs in from multiple different regions and different devices in a short period of time, which is seriously inconsistent with the account's daily login habits, it is very likely that the account has been stolen and there is a security risk; or there are a large number of incorrect password attempts, and it is suspected that someone is maliciously cracking the account password; or the login IP address belongs to a known malicious attack source address segment, which indicates that the account has an abnormal situation.
[0172] In summary, the synchronization processing in step 305 can achieve consistency of user rights within a preset area, so that users can obtain the same user rights information no matter where they operate or query in the area, thereby improving user experience.
[0173] Step 306 replaces the business data in the query result with the synchronization result after the synchronization is completed, and adds a completion mark, which is used to mark that the business data has been processed. This makes it easier for subsequent data processing flows to determine the processing status of the business data.
[0174] For example, the query result may include: a business data field, and the embodiment of the present invention may update the field content of the business data field from business data to a synchronization processing result. In addition, a new field is added to the query result to indicate a completion mark.
[0175] Step 307 writes the updated business data obtained after the processing in step 306 back to the database to update the query results in the database so that the data in the database is consistent with the actual processing results.
[0176] In an optional implementation, the above method may further include: if the first judgment result is yes, saving the query result locally.
[0177] If the first judgment result is yes, it indicates that the business data has been processed by other data terminals. At this time, saving the query results locally allows the second data terminal to quickly obtain the processing results of other data terminals, without the need to repeatedly process the completed business data, thus reducing resource waste. In the subsequent business process, the second data terminal can operate based on this saved result to keep the execution of local business consistent with other data terminals, realize the synchronization of synchronous processing results on multiple data terminals, and ensure data consistency between data terminals in different regions.
[0178] In another optional implementation, the method may further include: if the second judgment result is no, executing the step of searching for a query result corresponding to the key from the key-value pair data stored in the database according to the key in a preset time period.
[0179] If the second judgment result is no, it means that the business data in the query result should not be processed by this data end. In this case, regular queries according to the preset time period can achieve sharing and synchronization of synchronous processing results among various data ends.
[0180] In the dynamic process of data synchronization, other data terminals responsible for processing the business data will process the data and generate synchronization processing results. Through regular queries, this data terminal can continuously track the processing status of business data and obtain the synchronization processing results generated by other data terminals in a timely manner.
[0181] In summary, the data synchronization method of the embodiment of the present invention uses the key in the key-value pair data as the transmission content between the first data end and the second data end. Since the length of the key is usually short, it can well meet the length requirement of the URL in the GET request. In network transmission, the limited URL length is a common problem. The shorter key can effectively avoid the transmission failure caused by the excessive length of the transmission content, thereby improving the key transmission success rate and laying a reliable foundation for the subsequent data synchronization process.
[0182] Furthermore, the embodiment of the present invention can accurately know whether the business data has been processed by judging whether the query result contains a completion mark. If the completion mark is contained, no subsequent processing is performed, thus avoiding repeated operations on processed data, reducing unnecessary computing resource consumption, and improving data processing efficiency.
[0183] In addition, when the query result does not contain a completion mark, the embodiment of the present invention further determines whether the processing end mark matches its own data end mark, and only the matching processing end can process the business data. This mechanism clarifies the responsible subject for data processing, avoids processing conflicts between different data ends, and ensures the accuracy and orderliness of data processing.
[0184] Furthermore, after determining that the second data terminal is a suitable processing terminal, the embodiment of the present invention synchronizes the business data in the query result and updates the regional range of the user rights and interests contained in the business data to the preset regional range. This operation synchronizes the user rights and interests in the preset area, and the user can obtain consistent user rights and interests information no matter where the user operates or queries in the area, thereby improving the user experience.
[0185] Furthermore, after the synchronization process is completed, the embodiment of the present invention replaces the business data in the query result with the synchronization process result, adds a completion mark, and then writes the updated data back to the database. In this way, the data in the database can reflect the actual processing results in real time, ensuring the consistency and accuracy of the database data, and providing reliable data support for subsequent business operations and queries.
[0186] Reference Figure 4 , shows a flow chart of the steps of a data synchronization method according to an embodiment of the present invention, the method may specifically include the following steps:
[0187] Step 401: The first data terminal generates business data in response to a user operation;
[0188] Step 402: The first data end determines the data to be transmitted; the transmitted data includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0189] Step 403: The first data terminal generates key-value pair data corresponding to the first transmitted data; wherein, for the first transmitted data, a key in the key-value pair data is generated; and the first transmitted data is used as a value in the key-value pair data;
[0190] Step 404: The first data terminal saves the key-value pair data in the database;
[0191] Step 405: the first data end sends the key in the key-value pair data to the second data end; the first data end is a data end in the first region; the second data end is a data end in the second region; the first region and the second region are different regions;
[0192] Step 406: The second data terminal searches for a query result corresponding to the key from the key-value pair data stored in the database according to the key;
[0193] Step 407: The second data terminal determines whether the query result includes a completion mark, and obtains a first determination result.
[0194] Step 408: If the first judgment result is no, the second data end judges whether the processing end identifier in the query result matches its own data end identifier to obtain a second judgment result;
[0195] Step 409: If the second judgment result is yes, the second data terminal performs synchronization processing on the business data in the query result to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area;
[0196] Step 410: After completing the synchronization process, the second data terminal replaces the business data in the query result with the synchronization process result, and adds a completion mark to the query result to obtain updated data;
[0197] Step 411: The second data terminal updates the query results in the database to updated data.
[0198] Figure 4 The data synchronization path of the method embodiment shown specifically includes: first data end → second data end. The first data end sends a key to the second data end, and saves the key-value to the database. The second data end queries the query result corresponding to the key in the database according to the received key, modifies the business data in the query result to the synchronization processing result, replaces the business data in the query result with the synchronization processing result, and adds a completion mark to the query result to obtain the updated data, and updates the value in the database to the updated data.
[0199] Reference Figure 5 , which shows a flow chart of a data synchronization method according to an embodiment of the present invention. Assuming that the page operation generated by the user can be used to activate membership benefits, the membership benefits are effective in the first area corresponding to the data terminal A. The embodiment of the present invention is used to synchronize the membership benefits of the user from the first area to a preset area range, for example, the preset area range can be a global range or a national range, etc.
[0200] Data terminal A can generate business data (for example, member rights data) based on the user's page operation. Data terminal A also determines the data to be transmitted; the transmitted data includes: business data and processing terminal identifier; the processing terminal identifier is used to characterize the data terminal that processes the business data; data terminal A also generates the key-value corresponding to the transmitted data, saves the key-value in the database, and sends the key to data terminal B and data terminal C. Assume that data terminal B corresponds to the second area and data terminal C corresponds to the third area. Assume that the processing terminal identifier is the identifier of data terminal B.
[0201] After receiving the key sent by data terminal A, data terminal B obtains the query result from the database according to the key, determines whether the query result contains a completion mark, and obtains a first judgment result; if the first judgment result is no, the second data terminal determines whether the processing end mark in the query result matches its own data end mark, and obtains a second judgment result; if the second judgment result is yes, the business data in the query result is synchronized to obtain a synchronization result; after the synchronization is completed, the business data in the query result is replaced with the synchronization result, and a completion mark is added to the query result to obtain the updated data; the value in the database is updated to the updated data.
[0202] After receiving the key sent by data terminal B, data terminal C obtains the query result from the database according to the key, determines whether the query result contains a completion mark, and obtains the first judgment result; if the first judgment result is no, it determines whether the processing terminal mark in the query result matches its own data terminal mark, and obtains the second judgment result. If the second judgment result is no, it means that the business data in the query result should not be processed by this data terminal. In this case, the updated data corresponding to the key is regularly queried according to the preset time period.
[0203] After data terminal A sends the key to data terminal B and data terminal C, the above method may further include: querying the query result corresponding to the key from the key-value pair data saved in the database according to the key in a preset time period; determining whether the query result contains a completion mark, and if so, saving the query result locally; otherwise, returning to execute the step of querying the query result corresponding to the key from the key-value pair data saved in the database according to the key in a preset time period.
[0204] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0205] Reference Figure 6 , shows a schematic diagram of the structure of a data synchronization system according to an embodiment of the present invention, the system comprising: a first data terminal 601 and a second data terminal 602; the first data terminal is a data terminal of a first region; the second data terminal is a data terminal of a second region; the first region and the second region are different regions;
[0206] The first data end generates business data in response to user operation; determines the data to be transmitted; the transmitted data includes: business data and a processing end identifier; the processing end identifier is used to characterize the data end that processes the business data; generates key-value pair data corresponding to the first transmitted data; wherein, for the first transmitted data, generates a key in the key-value pair data; the first transmitted data is used as a value in the key-value pair data; saves the key-value pair data in a database; and sends the key in the key-value pair data to the second data end;
[0207] The second data end receives the key in the key-value pair data from the first data end; based on the key, queries the query result corresponding to the key from the key-value pair data stored in the database; determines whether the query result contains a completion mark to obtain a first judgment result; if the first judgment result is no, the second data end determines whether the processing end mark in the query result matches its own data end mark to obtain a second judgment result; if the second judgment result is yes, the second data end synchronizes the business data in the query result to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area; after completing the synchronization processing, replace the business data in the query result with the synchronization processing result, and add a completion mark to the query result to obtain updated business data; and update the query result in the database to the updated business data.
[0208] Reference Figure 7 , shows a schematic diagram of the structure of a data synchronization device according to an embodiment of the present invention, the data synchronization device is applied to a first data end, the first data end is a data end of a first region, and the device includes:
[0209] The business data generating module 701 is used to generate business data in response to user operations;
[0210] The data determination module 702 is used to determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data;
[0211] The key-value pair generating module 703 is used to generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, a key in the key-value pair data is generated; and the transmitted data is used as a value in the key-value pair data;
[0212] A key-value pair saving module 704 is used to save the key-value pair data in a database;
[0213] The key sending module 705 is used to send the key in the key-value pair data to the second data terminal, so that the second data terminal can query the query result corresponding to the key from the key-value pair data stored in the database according to the key, so that the second data terminal matching the processing terminal identifier can synchronize the business data to obtain the synchronization processing result; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area; the second data terminal is the data terminal of the second area; the first area and the second area are different areas.
[0214] Optionally, the key-value pair generation module includes:
[0215] A first generating module is used to generate a universal unique identifier for the transmitted data as a key in the key-value pair data; or
[0216] The second generating module is used to encrypt the unique target data in the transmitted data to obtain the key in the key-value pair data.
[0217] Optionally, the device further comprises:
[0218] A periodic query module, used to query the query result corresponding to the key from the key-value pair data stored in the database according to the key in a preset time period;
[0219] The completion judgment module is used to judge whether the query result contains a completion mark. If so, the query result is saved locally. Otherwise, it returns to execute the step of querying the query result corresponding to the key from the key-value pair data saved in the database according to the key in a preset time period.
[0220] Reference Figure 8 , shows a schematic diagram of the structure of a data synchronization device according to an embodiment of the present invention, the data synchronization device is applied to the second data terminal, and may specifically include the following modules:
[0221] The receiving module 801 is used to receive a key in a key-value pair data from a first data end; the first data end is a data end of a first region; the second data end is a data end of a second region; the first region and the second region are different regions;
[0222] A query module 802 is used to query the query result corresponding to the key from the key-value pair data stored in the database according to the key;
[0223] The completion judgment module 803 is used to judge whether the query result contains a completion mark, and obtain a first judgment result;
[0224] The identification judgment module 804 is used to judge whether the processing end identification in the query result matches the data end identification of the processing end, and obtain a second judgment result if the first judgment result is no;
[0225] The synchronization processing module 805 is used to synchronize the business data in the query result to obtain a synchronization processing result if the second judgment result is yes; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area;
[0226] A replacement module 806 is used to replace the business data in the query result with the synchronization result after the synchronization process is completed, and to add a completion mark to the query result to obtain updated data;
[0227] The updating module 807 is used to update the query results in the database to updated data.
[0228] Optionally, the synchronization processing module includes:
[0229] The area updating module is used to update the area range of the user rights and interests contained in the business data to a preset area range; the preset area range includes: a first area and a second area.
[0230] Optionally, the device further comprises:
[0231] The saving module is used to save the query result locally if the first judgment result is yes.
[0232] Optionally, the device further comprises:
[0233] The periodic query module is used to query the query result corresponding to the key from the key-value pair data stored in the database according to the key in a preset time period if the second judgment result is no.
[0234] An embodiment of the present invention further provides an electronic device that can implement the functions of the aforementioned storage node or scheduling node or ledger node or management node.
[0235] like Fig. 9 As shown, the electronic device may include a processor 1001, a communication interface 1002, a memory 1003 and a communication bus 1004, wherein the processor 1001, the communication interface 1002, and the memory 1003 communicate with each other via the communication bus 1004.
[0236] Memory 1003, used for storing computer programs;
[0237] The processor 1001 is used to execute the program stored in the memory 1003, and implements the following steps:
[0238] Storing the storage object;
[0239] Sending the storage object to a coupled second storage node, so that the second storage node stores and / or forwards the storage object;
[0240] After the storage object is successfully stored, the object information of the storage object is sent to the ledger node, so that the ledger node saves the ledger information of the first storage node; the ledger information includes: the object information stored in the corresponding storage node.
[0241] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0242] The communication interface is used for communication between the above electronic device and other devices.
[0243] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one data synchronization device located away from the aforementioned processor.
[0244] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0245] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the computer-readable storage medium is executed on a computer, the computer executes the data synchronization method described in any one of the above embodiments.
[0246] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the data synchronization method described in any one of the above embodiments.
[0247] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk (SSD)), etc. Examples of optical media may include DVD (Digital Video Disc) and the like.
[0248] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0249] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0250] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data synchronization method, characterized in that: Applied to a first data end, where the first data end is a data end in a first region, the method includes: generating business data in response to user operations; Determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data; Generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, generate a key in the key-value pair data; the transmitted data is used as a value in the key-value pair data; Save the key-value pair data in a database; The key in the key-value pair data is sent to the second data terminal, so that the second data terminal queries the query result corresponding to the key from the key-value pair data stored in the database according to the key, so that the second data terminal matching the processing terminal identifier performs synchronization processing on the business data to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area; the second data terminal is a data terminal of the second area; the first area and the second area are different areas.
2. The method according to claim 1, characterized in that The step of generating a key in the key-value pair data for the transmitted data includes: For the transmitted data, generate a universal unique identifier as a key in the key-value pair data; or The unique target data in the transmitted data is encrypted to obtain the key in the key-value pair data.
3. The method according to claim 1, characterized in that The method further comprises: According to the key, query the query result corresponding to the key from the key-value pair data stored in the database according to the key in a preset time period; Determine whether the query result contains a completion mark. If so, save the query result locally. Otherwise, return to execute the step of querying the query result corresponding to the key from the key-value pair data saved in the database according to the key in the preset time period.
4. A data synchronization method, characterized in that: Applied to the second data terminal, the method includes: receiving a key in a key-value pair data from a first data terminal; the first data terminal is a data terminal of a first region; the second data terminal is a data terminal of a second region; the first region and the second region are different regions; According to the key, query the query result corresponding to the key from the key-value pair data stored in the database; Determine whether the query result contains a completion mark to obtain a first determination result; If the first judgment result is no, then judging whether the processing end identifier in the query result matches the data end identifier of the device, and obtaining a second judgment result; If the second judgment result is yes, the business data in the query result is synchronized to obtain a synchronization result; the synchronization is used to synchronize the user rights and interests corresponding to the business data within a preset area; After the synchronization process is completed, the business data in the query result is replaced with the synchronization process result, and a completion mark is added to the query result to obtain the updated business data; Update the query results in the database to the updated business data.
5. The method according to claim 4, characterized in that The synchronous processing of the business data in the query result includes: The regional scope of the user rights and interests included in the business data is updated to a preset regional scope; the preset regional scope includes: a first region and a second region.
6. The method according to claim 4, characterized in that The method further comprises: If the first judgment result is yes, the query result is saved locally.
7. The method according to claim 4, characterized in that The method further comprises: If the second judgment result is no, then the step of searching for a query result corresponding to the key from the key-value pair data stored in the database according to the key is executed according to a preset time period.
8. A data synchronization system, characterized in that: The system comprises: a first data terminal and a second data terminal; the first data terminal is a data terminal of a first area; the second data terminal is a data terminal of a second area; the first area and the second area are different areas; The first data end generates business data in response to user operation; determines the data to be transmitted; the transmitted data includes: business data and a processing end identifier; the processing end identifier is used to characterize the data end that processes the business data; generates key-value pair data corresponding to the first transmitted data; wherein, for the first transmitted data, generates a key in the key-value pair data; the first transmitted data is used as a value in the key-value pair data; saves the key-value pair data in a database; and sends the key in the key-value pair data to the second data end; The second data end receives the key in the key-value pair data from the first data end; based on the key, queries the query result corresponding to the key from the key-value pair data stored in the database; determines whether the query result contains a completion mark to obtain a first judgment result; if the first judgment result is no, the second data end determines whether the processing end mark in the query result matches its own data end mark to obtain a second judgment result; if the second judgment result is yes, the second data end synchronizes the business data in the query result to obtain a synchronization processing result; the synchronization processing is used to synchronize user rights and interests corresponding to the business data within a preset area; after completing the synchronization processing, replace the business data in the query result with the synchronization processing result, and add a completion mark to the query result to obtain updated business data; and update the query result in the database to the updated business data.
9. A data synchronization device, characterized in that: Applied to a first data end, the first data end is a data end of a first region, the device comprises: A business data generation module, used to generate business data in response to user operations; The data determination module is used to determine the data to be transmitted; the data to be transmitted includes: business data and a processing end identifier; the processing end identifier is used to represent the data end that processes the business data; A key-value pair generation module, used to generate key-value pair data corresponding to the transmitted data; wherein, for the transmitted data, a key in the key-value pair data is generated; and the transmitted data is used as a value in the key-value pair data; A key-value pair storage module, used for storing the key-value pair data in a database; A key sending module is used to send the key in the key-value pair data to the second data end, so that the second data end can query the query result corresponding to the key from the key-value pair data saved in the database according to the key, so that the second data end matching the processing end identifier can synchronize the business data to obtain the synchronization processing result; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area; the second data end is the data end of the second area; the first area and the second area are different areas.
10. A data synchronization device, characterized in that: Applied to the second data terminal, the device comprises: A receiving module, used for receiving a key in a key-value pair data from a first data end; the first data end is a data end of a first region; the second data end is a data end of a second region; the first region and the second region are different regions; A query module, used to query the query result corresponding to the key from the key-value pair data stored in the database according to the key; A completion judgment module is used to judge whether the query result contains a completion mark, and obtain a first judgment result; The identification judgment module is used to judge whether the processing end identification in the query result matches the data end identification of the processor itself if the first judgment result is no, so as to obtain a second judgment result; A synchronization processing module, for performing synchronization processing on the business data in the query result to obtain a synchronization processing result if the second judgment result is yes; the synchronization processing is used to synchronize the user rights and interests corresponding to the business data within a preset area; The replacement module is used to replace the business data in the query result with the synchronization result after the synchronization process is completed, and add a completion mark to the query result to obtain the updated data; The update module is used to update the query results in the database to the updated data.
11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.