Data synchronization method and apparatus, electronic device, and storage medium

By introducing a connection token mechanism and multi-level synchronization detection in the cloud computing virtual network environment, the problems of low data synchronization efficiency and poor accuracy are solved, achieving efficient and accurate data synchronization, supporting hot start scenarios and reducing resource waste.

CN122179441APending Publication Date: 2026-06-09BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
Filing Date
2026-03-16
Publication Date
2026-06-09

Smart Images

  • Figure CN122179441A_ABST
    Figure CN122179441A_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data synchronization method and device, electronic equipment and storage medium. By establishing a communication connection between the terminal and the server based on the obtained connection token, performing multi-level synchronization detection based on the data in the server and the data in the local cache of the terminal, obtaining a detection result, synchronizing the data in the server to the local cache based on the detection result, releasing the connection token and disconnecting the communication connection between the terminal and the server. The method establishes and maintains the communication connection with the server through the connection token mechanism, and ensures the token release and connection disconnection after synchronization, effectively guaranteeing the stability and exclusivity of network connection during key synchronization operation, and improving the reliability of the whole synchronization process. Through multi-level synchronization detection, the change can be accurately located from coarse to fine, realizing real accurate incremental synchronization, avoiding full load, and greatly improving the synchronization efficiency, especially in large-scale data scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a data synchronization method, apparatus, electronic device, and storage medium. Background Technology

[0002] In cloud computing virtual network environments, virtual gateway proxies, as a key component connecting the control plane and the data plane, need to manage a large amount of network resource configuration data, such as virtual private networks, virtual interfaces, routing rules, and quality of service policies. This configuration data is typically cached at multiple levels to improve access performance, including: remote central databases (such as MySQL), distributed central caches (such as Redis), local memory on proxy nodes, and local persistent files.

[0003] However, when the system restarts, the network fails, or the system runs for an extended period, inconsistencies may arise between different cache layers. Therefore, an efficient synchronization mechanism is needed to ensure data integrity. Currently, the industry primarily uses the following data synchronization solutions: 1) Full Reload Method: Each time the proxy node starts or triggers a periodic task, it deletes all data in its local cache and fetches all data from the server again. In this solution, data synchronization takes a long time, which can lead to long service interruptions and cannot support hot start scenarios. Furthermore, frequent full data transfers will waste network bandwidth and computing resources.

[0004] 2) Overall Version Number Comparison: This involves maintaining the version number of the Virtual Private Network (VPN). If the VPN's version number changes, all data within that VPN is retrieved from the server. Since any change in data at any granularity within a VPN (such as modifying a configuration record or updating a file) will cause the VPN's version number to change, triggering the retrieval of all data from the server, the data synchronization volume is substantial. Furthermore, even if the VPN version numbers are consistent, there is a possibility that data in the local cache may be mistakenly modified or corrupted, making it impossible to guarantee consistency between the local cache and the data on the server, resulting in poor accuracy of the data synchronization results.

[0005] 3) Timestamp comparison method: This method determines whether data has changed by comparing the last update timestamp. However, due to potential issues such as clock asynchrony and insufficient timestamp precision, the judgment result may be inaccurate, leading to inaccurate data synchronization results. It also cannot achieve data synchronization in incremental deletion scenarios. For example, when data is deleted on the server side, timestamp comparison alone is insufficient for the proxy node to detect and execute the local deletion operation.

[0006] 4) Event-driven synchronization: Listen for database or Redis change events and update the data in the local cache in real time. This approach is complex to implement, requiring additional deployment and maintenance of infrastructure such as event buses and message queues. Furthermore, event-driven architectures suffer from typical problems of distributed messaging systems, such as event loss and message out-of-order delivery, resulting in poor accuracy of data synchronization results.

[0007] 5) Hash comparison method: Calculates a digest of the data (MD5 / SHA1) and determines whether the data has changed by comparing whether the digest has changed. Hash calculation incurs additional computational overhead, and hash comparison can only determine whether the data has changed, but cannot identify the specific changed data. Therefore, only the data on the server side can be fully synchronized to the local cache.

[0008] Existing technical solutions suffer from problems such as low data synchronization efficiency, low data synchronization accuracy, and high data synchronization overhead. Summary of the Invention

[0009] To address the aforementioned technical problems, this disclosure provides a data synchronization method, apparatus, electronic device, and storage medium.

[0010] In a first aspect, embodiments of this disclosure provide a data synchronization method, the method comprising: The terminal establishes a communication connection with the server based on the obtained connection token. Based on the data in the server and the data in the local cache of the terminal, multi-level synchronization detection is performed to obtain the detection results. The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, as well as the differences between the data version in the server and the data version in the terminal. Based on the detection results, the data in the server is synchronized to the local cache; Release the connection token and disconnect the communication connection between the terminal and the server.

[0011] In some embodiments, the step of performing multi-level synchronization detection based on data in the server and data in the local cache of the terminal to obtain detection results includes: Based on the first set of virtual private networks in the server and the second set of virtual private networks in the local cache, domain-level synchronization detection is performed to obtain the first detection result. If the first detection result includes an intersection domain, then for any resource type in the intersection domain, based on the first version number corresponding to the resource type on the server and the second version number corresponding to the resource type in the local cache, a resource-level synchronization detection is performed to obtain a second detection result; the intersection domain is the virtual private network in the intersection of the first virtual private network set and the second virtual private network set; If the second detection result includes a resource type to be synchronized, then for the resource type to be synchronized, based on the first resource instance set and the first revision number of each resource instance on the server side, and the second resource instance set and the second revision number of each resource instance in the local cache, an instance-level synchronization detection is performed to obtain a third detection result.

[0012] In some embodiments, the step of performing domain-level synchronization detection based on the first virtual private network set in the server and the second virtual private network set in the local cache to obtain a first detection result includes: Obtain the identifiers of the virtual private networks currently existing in the server, and form a first set of virtual private networks; Obtain the identifiers of the virtual private networks stored in the local cache to form a second set of virtual private networks; By comparing the first set of virtual private networks with the second set of virtual private networks, a first detection result is obtained, which includes newly added domains, deleted domains, and intersection domains. The newly added domain is a virtual private network that belongs to the first virtual private network set but not to the second virtual private network set, and the deleted domain is a virtual private network that belongs to the second virtual private network set but not to the first virtual private network set.

[0013] In some embodiments, the step of performing resource-level synchronization detection based on the first version number corresponding to the resource type on the server side and the second version number corresponding to the resource type in the local cache, to obtain a second detection result, includes: Compare the server-side resource version number with the second version number; If the server-side resource version number is the same as the second version number, then it is determined that the second detection result does not include the resource type to be synchronized; If the server-side resource version number is different from the second version number, then the second detection result is determined to include the resource type to be synchronized.

[0014] In some embodiments, the execution of instance-level synchronization detection based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, and the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, to obtain a third detection result includes: Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored on the server, and use it as the first resource instance set; Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored in the local cache, and use it as the second resource instance set; Resource instances in the second resource instance set that do not belong to the first resource instance set are identified as resource instances to be deleted; Resource instances in the first resource instance set that do not belong to the second resource instance set are identified as resource instances to be added; For each resource instance in the intersection of the first resource instance set and the second resource instance set, obtain the first revision number of the resource instance on the server side and the second revision number of the resource instance in the local cache; In response to the fact that the first revision number and the second revision number are different, the resource instance is identified as a resource instance to be modified.

[0015] In some embodiments, synchronizing the data from the server to the local cache based on the detection result includes: For each new domain, data of each resource type under the new domain is obtained from the server, and the data is fully synchronized to the local cache. For each deleted domain, remove the data corresponding to the deleted domain from the local cache.

[0016] In some embodiments, synchronizing the data from the server to the local cache based on the detection result includes: For the resource types to be synchronized in the intersection domain, based on the resource instances to be deleted, the resource instances to be added, and the resource instances to be modified, the data of the resource types to be synchronized in the server is incrementally synchronized to the local cache.

[0017] Secondly, embodiments of this disclosure provide a data synchronization device, the device comprising: The connection module is used to establish a communication connection between the terminal and the server based on the acquired connection token. The detection module is used to perform multi-level synchronous detection based on the data in the server and the data in the local cache of the terminal, and obtain the detection results; A synchronization module is used to synchronize data from the server to the local cache based on the detection results; The disconnect module is used to release the connection token and disconnect the communication connection between the terminal and the server.

[0018] Thirdly, embodiments of this disclosure provide an electronic device, including: Memory; Processor; and Computer programs; The computer program is stored in memory and configured to be executed by a processor to implement the method as described in the first aspect.

[0019] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method as described in the first aspect.

[0020] Fifthly, embodiments of this disclosure also provide a computer program product comprising a computer program or instructions that, when executed by a processor, implement the method as described in the first aspect.

[0021] The data synchronization method, apparatus, electronic device, and storage medium provided in this disclosure establish a communication connection between a terminal and a server based on an acquired connection token. Based on data in the server and data in the terminal's local cache, multi-level synchronization detection is performed to obtain detection results. Based on these results, data from the server is synchronized to the local cache, the connection token is released, and the communication connection between the terminal and the server is disconnected. Compared to existing technologies, this disclosure establishes and maintains the communication connection with the server through a connection token mechanism, ensuring token release and connection disconnection after synchronization. This mechanism effectively guarantees the stability and exclusivity of the network connection during critical synchronization operations, improving the reliability of the entire synchronization process. Multi-level synchronization detection allows for precise change location from coarse to fine, achieving truly accurate incremental synchronization, avoiding full-scale overload, greatly improving synchronization efficiency, increasing the accuracy of data synchronization results, and reducing data synchronization overhead, with significant advantages, especially in large-scale data scenarios. Attached Figure Description

[0022] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0023] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 A flowchart of a data synchronization method provided in this embodiment of the disclosure; Figure 2 A flowchart of a data synchronization method provided in another embodiment of this disclosure; Figure 3 A flowchart of a data synchronization method provided in another embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of the data synchronization device provided in the embodiments of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0025] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0026] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0027] In cloud computing virtual network environments, virtual gateway proxies, as a key component connecting the control plane and the data plane, need to manage a large amount of network resource configuration data, such as virtual private networks, virtual interfaces, routing rules, and quality of service policies. This configuration data is typically cached at multiple levels to improve access performance, including: remote central databases (such as MySQL), distributed central caches (such as Redis), local memory on proxy nodes, and local persistent files.

[0028] However, when the system restarts, the network fails, or the system runs for an extended period, inconsistencies may arise between different cache layers. Therefore, an efficient synchronization mechanism is needed to ensure data integrity. Existing technical solutions suffer from problems such as low data synchronization efficiency, low data synchronization accuracy, and high data synchronization overhead.

[0029] To address this problem, this disclosure provides a data synchronization method, which will be described below with reference to specific embodiments.

[0030] Figure 1 This is a flowchart illustrating a data synchronization method provided in an embodiment of this disclosure. The method is executed by an electronic device, which can be a portable mobile device such as a smartphone, tablet, laptop, in-vehicle navigation device, or smart sports equipment; or a fixed device such as a personal computer, smart home appliance, or server. The server can be a single server, a server cluster, a distributed cluster, or a centralized cluster. This method can be applied to data synchronization scenarios.

[0031] It is understood that the data synchronization method provided in this disclosure can also be applied in other scenarios.

[0032] The following is about Figure 1 The data synchronization method shown is described below. This method can be applied to electronic devices, specifically virtual gateway proxies. The specific steps included in this method are as follows: S101. Establish a communication connection between the terminal and the server based on the obtained connection token.

[0033] In this step, after the virtual gateway agent starts, it sends a request to the server to acquire a connection token. This connection token can be a mutex lock or a flag, indicating that the virtual gateway agent on the terminal is about to perform an operation to synchronize data on the server and data in the terminal's local cache. After successfully acquiring the connection token, the virtual gateway agent can establish a high-priority, protected persistent connection based on it. This step ensures that subsequent synchronization operations are not unexpectedly interfered with by other processes or connection management policies, thus guaranteeing the connection reliability of the synchronization process.

[0034] S102. Based on the data in the server and the data in the local cache of the terminal, perform multi-level synchronization detection to obtain the detection results.

[0035] The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, as well as the differences between the data version in the server and the data version in the terminal.

[0036] In this step, after establishing a connection, the virtual gateway proxy can perform multi-level synchronization detection based on data on the server and data in the local cache of the terminal to obtain the detection results. This multi-level synchronization detection includes domain-level synchronization detection, resource-level synchronization detection, and instance-level synchronization detection. Through a progressive detection logic of "first detecting domain-level synchronization, then resource-level synchronization, and finally instance-level synchronization," comprehensive synchronization verification from macro to micro levels is achieved. This solves the problems of inefficiency and resource waste caused by full-scale comparison in traditional synchronization schemes. While improving synchronization efficiency, reducing resource consumption, and enhancing system stability, it also provides fundamental support for advanced functions such as multi-tenant architecture and incremental synchronization, demonstrating significant technological advancement and practical value.

[0037] S103. Based on the detection results, synchronize the data in the server to the local cache.

[0038] In this step, the virtual gateway proxy can synchronize the data on the server to the local cache based on the detection results.

[0039] S104. Release the connection token and disconnect the communication connection between the terminal and the server.

[0040] In this step, after all synchronization operations are completed, the virtual gateway agent releases the connection token and disconnects the communication connection between the terminal and the server. The virtual gateway agent returns the previously acquired connection token and disconnects the communication connection to ensure no resource leakage. Subsequently, the virtual gateway agent enters normal operation and begins processing network data plane traffic.

[0041] This embodiment establishes a communication connection between the terminal and the server based on an acquired connection token. Multi-level synchronization detection is performed based on data on the server and data in the terminal's local cache to obtain detection results. Based on these results, data on the server is synchronized to the local cache, the connection token is released, and the communication connection between the terminal and the server is disconnected. Compared to existing technologies, this embodiment establishes and maintains the communication connection with the server using a connection token mechanism, ensuring token release and connection disconnection after synchronization. This mechanism effectively guarantees the stability and exclusivity of the network connection during critical synchronization operations, improving the reliability of the entire synchronization process. Multi-level synchronization detection allows for precise change location from coarse to fine, achieving truly accurate incremental synchronization, avoiding full-scale overload, greatly improving synchronization efficiency, increasing the accuracy of data synchronization results, and reducing data synchronization overhead, with significant advantages, especially in large-scale data scenarios.

[0042] Compared with existing technologies, the disclosed solution has the following significant differences and technical advantages: First, compared to the full reload method, this disclosure performs multi-level synchronization detection based on the data in the server and the data in the local cache of the terminal to obtain the detection results. By introducing a multi-level synchronization detection mechanism, data synchronization is further performed based on the detection results. This eliminates the need to pull all the data from the server, thus solving the problem of long data synchronization time in the full reload method. It can reduce data synchronization time, improve data synchronization efficiency, and thus reduce service interruption time. It can support hot start scenarios and reduce the waste of network bandwidth and computing resources.

[0043] Secondly, compared to the overall version number comparison scheme, this disclosure performs multi-level synchronization detection. This multi-level synchronization detection refers to detecting the differences between the virtual private network (VPN) on the server and the VPN on the terminal, as well as the differences between the data version on the server and the data version on the terminal. Based on the detection results, targeted synchronization is performed. This can detect the differences in VPNs with finer granularity. When data under a VPN changes, it is not necessary to pull all data under that VPN from the server; only the changed data under that VPN needs to be pulled. This solves the problem of large data synchronization volume in the overall version number comparison scheme, achieves fine-grained synchronization control, reduces the amount of data synchronization, and ensures the consistency between the local cache and the data on the server, thereby improving the accuracy of the data synchronization results.

[0044] Third, compared with the timestamp comparison method, this disclosure introduces a multi-level synchronization detection mechanism to further synchronize data based on the detection results. This can solve the problem of inaccurate data synchronization results of the timestamp comparison method and improve the accuracy of data synchronization results. The multi-level synchronization detection can detect the differences between the virtual private networks of the server and the terminal, that is, it can detect the situation of data deletion, and thus realize data synchronization in incremental deletion scenarios.

[0045] Fourth, compared to event-driven synchronization solutions, this disclosure achieves lightweight connection management through a connection token mechanism, without relying on additional infrastructure such as event buses and message queues. It can solve complex problems such as event loss and message out-of-order in event-driven synchronization solutions, and is simple to implement, easy to deploy, and has low operation and maintenance costs. Data synchronization based on detection results can improve the accuracy of data synchronization results.

[0046] Fifth, compared to the hash comparison method, this disclosure performs multi-level synchronization detection. The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, as well as the differences between the data version in the server and the data version in the terminal. This does not incur additional computational overhead. Through hierarchical detection logic, it can solve the problem that the hash comparison method cannot identify specific change locations. It can identify changed data, and only needs to synchronize data based on the detection results, without the need for full synchronization, which can improve the accuracy of data synchronization results.

[0047] Figure 2 A flowchart of a data synchronization method provided in another embodiment of this disclosure is shown below. Figure 2 As shown, the method includes the following steps: S201. Establish a communication connection between the terminal and the server based on the obtained connection token.

[0048] Specifically, the implementation process and principle of S201 and S101 are the same, and will not be repeated here.

[0049] S202. Based on the first set of virtual private networks in the server and the second set of virtual private networks in the local cache, perform domain-level synchronization detection to obtain the first detection result.

[0050] In this step, domain-level synchronization detection is performed. The virtual gateway proxy performs domain-level synchronization detection based on the first set of virtual private networks (VPNs) on the server and the second set of VPNs in the local cache, obtaining a first detection result. Specifically, the first detection result is obtained based on the differences between the first and second VPN sets, thus determining the changes to the VPNs.

[0051] In some embodiments, S202 may include, but is not limited to, S2021, S2022, and S2023: S2021. Obtain the identifiers of the existing virtual private networks on the server side to form the first set of virtual private networks.

[0052] In this step, the virtual gateway proxy first obtains a list of all currently existing valid domain (Virtual Private Network) identifiers from the server, forming a first set of Virtual Private Networks. For example, the first set of Virtual Private Networks is {"VPC-A", "VPC-B", "VPC-C"}.

[0053] S2022. Obtain the identifiers of the virtual private networks stored in the local cache to form a second set of virtual private networks.

[0054] In this step, the virtual gateway agent reads the list of virtual private network (VPC) identifiers from its local cache to form a second VPC set. For example, the second VPC set is {"VPC-A", "VPC-B", "VPC-D"}.

[0055] S2023. Compare the first virtual private network set with the second virtual private network set to obtain the first detection result, which includes newly added domains, deleted domains, and intersection domains.

[0056] Among them, the newly added domains are virtual private networks that belong to the first virtual private network set but not to the second virtual private network set, the deleted domains are virtual private networks that belong to the second virtual private network set but not to the first virtual private network set, and the intersection domains are the domains in the intersection of the first virtual private network set and the second virtual private network set.

[0057] In this step, the virtual gateway proxy obtains the first detection result through operations between the two sets. The first detection result includes three types of domains: 1) Newly added domains (in the first virtual private network set but not in the second virtual private network set), elaborating on the example above, the newly added domain is {"VPC-C"}, which requires full data retrieval during subsequent synchronization; 2) Deleted domains (in the second virtual private network set but not in the first virtual private network set), the deleted domain is {"VPC-D"}, which needs to be completely cleaned up locally during subsequent synchronization; 3) Intersection domains (the intersection of the two virtual private network sets), the intersection domains are {"VPC-A", "VPC-B"}, requiring further incremental synchronization at the resource level in the next step. This step solves the problem of ineffective identification of domain additions and deletions.

[0058] This embodiment identifies newly added, deleted, and intersection domains at the domain level using simple set operations. The algorithm has low complexity, fast execution speed, and can quickly define the scope of the domains to be processed. By identifying "deleted domains" through set difference, it solves the problem of ineffective data deletion detection and achieves complete support for data lifecycle management.

[0059] S203. If the first detection result includes the intersection domain, then for any resource type in the intersection domain, based on the first version number corresponding to the resource type on the server side and the second version number corresponding to the resource type in the local cache, perform resource-level synchronization detection to obtain the second detection result.

[0060] The intersection domain refers to the virtual private networks in the intersection of the first set of virtual private networks and the second set of virtual private networks.

[0061] In this step, resource-level synchronization detection is performed. If the first detection result includes an intersection domain, then for each intersection domain (such as "VPC-A"), the virtual gateway proxy traverses all resource types (such as Virtual Interface (VIF) and Route) under that intersection domain. For each resource type, based on the first version number of that resource type on the server and the second version number recorded locally, resource-level synchronization detection is performed to obtain the second detection result, which determines the resource types to be synchronized in the intersection domain.

[0062] In some embodiments, when the resource type is a nested resource type, the step of performing resource-level synchronization detection based on the first version number corresponding to the resource type on the server and the second version number corresponding to the resource type in the local cache to obtain a second detection result includes: recursively traversing the data storage structure of the nested resource type on the server to locate the version number field of the nested resource type stored on the server to obtain the first version number corresponding to the nested resource type on the server; recursively traversing the data storage structure of the nested resource type in the local cache to locate the version number field of the nested resource type stored in the local cache to obtain the second version number corresponding to the nested resource type in the local cache; if the first version number is the same as the second version number, it is determined that the second detection result does not include the resource type to be synchronized; if the first version number is different from the second version number, it is determined that the second detection result includes the resource type to be synchronized.

[0063] This application enables a three-level synchronization detection mechanism to be seamlessly adapted to nested resource structures. This solves the problem that traditional synchronization methods struggle to handle complex object relationships, allowing the method to be applied to a wider range of cloud computing resource configuration and management scenarios, thus enhancing the practicality and universality of the solution.

[0064] S204. If the second detection result includes the resource type to be synchronized, then based on the first resource instance set of the resource type to be synchronized on the server side and the first revision number of each resource instance, and the second resource instance set of the resource type to be synchronized in the local cache and the second revision number of each resource instance, perform instance-level synchronization detection to obtain the third detection result.

[0065] In this step, instance-level synchronization detection is performed. For resource types marked as to be synchronized (such as routes of "VPC-A"), the virtual gateway proxy performs instance-level synchronization detection based on the first set of resource instances of the resource type to be synchronized on the server side and the first revision number of each resource instance, as well as the second set of resource instances of the resource type to be synchronized on the local cache and the second revision number of each resource instance, to obtain a third detection result. Specifically, the third detection result is obtained by comparing the set operation with the revision number.

[0066] In some embodiments, Figure 2 Steps S202, S203, and S204 shown can be used as Figure 1 One specific implementation of step S102 shown.

[0067] This embodiment employs a three-layer progressive synchronous detection architecture. First, it filters at the coarsest domain granularity. Then, it compares version numbers at the resource type granularity for domains of interest. Finally, it performs precise comparisons only on changed resource types at the instance granularity. This layered filtering mechanism significantly reduces unnecessary fine-grained comparison operations, concentrating computational and network overhead on the subset of data that has actually changed, thus resolving the issues of inefficiency and insufficient accuracy.

[0068] In some embodiments, S204 performs instance-level synchronization detection based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, and the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, to obtain a third detection result, including S2041, S2042, S2043, S2044, S2045, and S2046: S2041. Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored on the server side, and use it as the first resource instance set.

[0069] In this step, for the resource type to be synchronized (such as routes for "VPC-A"), the virtual gateway proxy obtains the identifiers of all resource instances under that resource type, forming a first resource instance set. For example, the first resource instance set is {"route-1", "route-2"}.

[0070] S2042. Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored in the local cache, and use it as the second resource instance set.

[0071] Simultaneously, the virtual gateway proxy retrieves a set of resource instance identifiers for the resource type to be synchronized from the local cache, forming a second resource instance set. For example, the second resource instance set is {"route-1", "route-3"}.

[0072] S2043. Identify resource instances in the second resource instance set that do not belong to the first resource instance set as resource instances to be deleted.

[0073] In this step, the virtual gateway proxy identifies resource instances in the second resource instance set that do not belong to the first resource instance set as resource instances to be deleted. After set operation, {"route-3"} is identified as a resource instance to be deleted.

[0074] S2044. Identify resource instances in the first resource instance set that do not belong to the second resource instance set as resource instances to be added.

[0075] In this step, the virtual gateway proxy identifies resource instances in the first resource instance set that do not belong to the second resource instance set as resource instances to be added. After set operation, {"route-2"} is identified as a resource instance to be deleted.

[0076] S2045. For each resource instance in the intersection of the first resource instance set and the second resource instance set, obtain the first revision number of the resource instance on the server and the second revision number of the resource instance in the local cache.

[0077] For each resource instance in the intersection of the first and second resource instance sets, such as "route-1", compare the first revision number and the second revision number. For example, if the first revision number is rev10 and the second revision number is rev10, no further processing is needed. If they are different, execute S2046.

[0078] S2046. In response to the fact that the first revision number and the second revision number are different, the resource instance is identified as a resource instance to be modified.

[0079] If the first revision number and the second revision number are different, for example, for the resource instance "route-1", the first revision number is rev10 and the second revision number is rev5, then the resource instance is identified as a resource instance to be modified.

[0080] This embodiment comprehensively utilizes set operations and revision number comparison at the instance level. It accurately locates newly added and deleted instances by using set difference; and accurately locates instances whose content has been modified by comparing the revision numbers of shared instances. This combined strategy achieves complete and accurate identification of data changes (additions, deletions, and modifications), reaching instance-level synchronization precision, ensuring strict consistency between local cache and server-side data, and overcoming the shortcomings of insufficient precision.

[0081] S205. Based on the detection results, synchronize the data in the server to the local cache.

[0082] Specifically, the implementation process and principle of S205 and S103 are the same, and will not be repeated here.

[0083] In some embodiments, when the resource to be synchronized is a sub-resource nested within a parent resource, obtaining the set of resource instance identifiers and their revision numbers from the server and local cache includes: recursively traversing the internal structure of the parent resource instance, locating and extracting the instance identifiers and their revision numbers of each sub-resource, for subsequent set comparison and revision number comparison.

[0084] A special processing flow is implemented for synchronizing complex resources with nested structures, such as the Quality of Service (QoS) policy `vmqoss` and its internal rate-limiting sub-resource `vmratelimits`. In the resource-level synchronization detection sub-step, it is found that the version number of `VPC-A.vmratelimits_version` is 4 on the server side and 3 on the local side, indicating a version inconsistency. Therefore, the nested resource type `vmratelimits` is marked as needing synchronization. In the instance-level synchronization detection, since `vmratelimits` is a nested resource, its identifier and revision number are stored in a multi-level index structure, nested within the `vmqoss` resource object. Its data storage structure is: `VPC-A → vmqoss instance ID → vmratelimits → sub-instance ID`. The following special logic will be executed: 1) Recursive traversal to obtain the instance set: The proxy needs to recursively traverse the internal structure of each "vmqoss" instance object under "VPC-A" in the server and local cache in order to collect the identifiers and revision numbers of all "vmratelimits" sub-instances, thereby forming a first resource instance set and a second resource instance set that can be compared.

[0085] 2) Comparison of nested sub-instances and revision numbers: After obtaining the flattened set of sub-instances, perform set difference operation and revision number comparison to identify vmratelimits sub-instances that need to be deleted, added, or modified.

[0086] 3) Location-based update: When performing synchronization, for a vmratelimits child instance that needs to be updated, its parent vmqoss instance must be precisely located, and the update operation must be performed in the internal structure of the parent instance to maintain the integrity of the data model.

[0087] This embodiment demonstrates the excellent scalability and support for complex business models of this application. Through recursive traversal and data flattening, this application can seamlessly adapt the three-level synchronization detection mechanism to nested resource structures. This solves the problem that traditional synchronization methods struggle to handle complex object relationships, enabling the method to be applied to a wider range of cloud computing resource configuration and management scenarios, thus enhancing the practicality and universality of the solution.

[0088] S206. Release the connection token and disconnect the communication connection between the terminal and the server.

[0089] Specifically, the implementation process and principle of S206 and S104 are the same, and will not be repeated here.

[0090] In some embodiments, if an exception occurs during the synchronization process, an error log is recorded and the virtual gateway agent is exited.

[0091] This embodiment establishes a communication connection between the terminal and the server based on the acquired connection token. Domain-level synchronization detection is performed based on a first set of virtual private networks (VPNs) on the server and a second set of VPNs in the local cache, yielding a first detection result. Further, if the first detection result includes an intersection domain, for any resource type within the intersection domain, resource-level synchronization detection is performed based on the first version number of the resource type on the server and the second version number of the resource type in the local cache, yielding a second detection result. Next, if the second detection result includes a resource type to be synchronized, instance-level synchronization detection is performed based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, as well as the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, yielding a third detection result. Finally, based on the detection results, data on the server is synchronized to the local cache, the connection token is released, and the communication connection between the terminal and the server is disconnected. This method, as described in this embodiment, employs a three-layer progressive synchronous detection architecture. First, it filters at the coarsest domain granularity. Then, it compares version numbers at the resource type granularity for domains of interest. Finally, it delves into the instance granularity for precise comparisons only for changed resource types. This layered filtering mechanism significantly reduces unnecessary fine-grained comparison operations, resolving the issues of inefficiency and insufficient accuracy.

[0092] Figure 3 A flowchart of a data synchronization method provided in another embodiment of this disclosure is shown below. Figure 3 As shown, the method includes the following steps: S301. Establish a communication connection between the terminal and the server based on the obtained connection token.

[0093] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.

[0094] S302. Based on the first set of virtual private networks in the server and the second set of virtual private networks in the local cache, perform domain-level synchronization detection to obtain the first detection result.

[0095] Specifically, the implementation process and principle of S302 and S202 are the same, and will not be repeated here.

[0096] S303. If the first detection result includes an intersection domain, then the server-side resource version number is compared with the second version number.

[0097] In this step, for each intersection domain (e.g., "VPC-A"), the virtual gateway proxy traverses all resource types under it (e.g., Virtual Interface VIF, Route). For each resource type, it retrieves the server resource version number on the server side from Redis (e.g., VPC-A.vifs_version = 5) and compares it with the locally recorded local resource version number (e.g., local.VPC-A.vifs_version = 5).

[0098] S304. If the server-side resource version number is the same as the second version number, then the second detection result does not include the resource type to be synchronized.

[0099] In this step, if the version numbers are found to be the same, then this type of resource is considered not to need to be synchronized.

[0100] S305. If the server-side resource version number is different from the second version number, then the second detection result is determined to include the resource type to be synchronized.

[0101] In this step, if it is determined that the version numbers are different, for example, the server version number is 3 while the local version number is 2, the resource type version numbers are not the same, then it is considered that this type of resource needs to be synchronized and marked as a resource type to be synchronized.

[0102] This embodiment uses version number comparison at the resource type level. Each resource type maintains an independent version number, which increments whenever any instance within the type changes. By comparing version numbers once, it can be determined whether the entire resource type has changed since the last synchronization. If there are no changes, the synchronization of all instances under that type is skipped. This avoids the huge overhead of comparing a large number of unchanged instances one by one, thus improving synchronization efficiency.

[0103] S306. If the second detection result includes the resource type to be synchronized, then based on the first resource instance set of the resource type to be synchronized on the server and the first revision number of each resource instance, and the second resource instance set of the resource type to be synchronized in the local cache and the second revision number of each resource instance, perform instance-level synchronization detection to obtain the third detection result.

[0104] Specifically, the implementation process and principle of S306 and S204 are the same, and will not be repeated here.

[0105] S307. For each new domain, retrieve the data of each resource type under the new domain from the server and synchronize the data to the local cache.

[0106] In this step, for the newly added domain "VPC-C", since there is no data on its local machine, a full synchronization method is adopted: the complete data of all resource types under "VPC-C" is pulled from the server and written to the local cache.

[0107] S308. For each deleted field, remove the data corresponding to the deleted field from the local cache.

[0108] In this step, for the deleted domain "VPC-D", a cleanup method is used: "VPC-D" and all its resource data are completely removed from local memory and file cache.

[0109] This embodiment implements differentiated synchronization strategies for "newly added fields" and "deleted fields." Newly added fields undergo full synchronization because there is no local caching, making a full fetch the most efficient initialization method. For deleted fields, the local cache is directly cleared. This differentiated approach demonstrates the method's intelligence, optimizing processing paths for different scenarios while ensuring data integrity.

[0110] S309. For the resource types to be synchronized in the intersection domain, based on the resource instances to be deleted, the resource instances to be added, and the resource instances to be modified, the incremental data of the resource types to be synchronized on the server side is synchronized to the local cache.

[0111] In this step, for the resource instances to be synchronized identified in the intersection domain "VPC-A", an incremental synchronization method is used: delete the local instance "route-3"; pull and create the complete data of the newly added instance "route-2"; if there are instances with different revision numbers, pull their latest data to update the local cache.

[0112] This embodiment establishes a communication connection between the terminal and the server based on the acquired connection token. Domain-level synchronization detection is performed based on a first set of virtual private networks (VPNs) on the server and a second set of VPNs in the local cache, yielding a first detection result. Then, if the first detection result includes an intersection domain, the server-side resource version number is compared with a second version number. If the server-side resource version number and the second version number are the same, it is determined that the second detection result does not include the resource type to be synchronized; if the server-side resource version number and the second version number are different, it is determined that the second detection result includes the resource type to be synchronized. Further, if the second detection result includes the resource type to be synchronized, instance-level synchronization detection is performed based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, as well as the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, yielding a third detection result. Next, for each newly added domain, data for each resource type under the newly added domain is obtained from the server and fully synchronized to the local cache. For each deleted domain, data corresponding to the deleted domain is removed from the local cache. Furthermore, for the resource types to be synchronized in the intersection domain, based on the resource instances to be deleted, the resource instances to be added, and the resource instances to be modified, the incremental data of the resource types to be synchronized in the server is synchronized to the local cache. Compared with the prior art, the embodiments of this disclosure demonstrate the intelligence of the synchronization method by implementing differentiated synchronization strategies for the "new domain" and the "deleted domain," optimizing the processing path in different scenarios while ensuring data integrity. For the intersection domain, incremental synchronization is performed based on the instances to be deleted, the instances to be added, and the instances to be modified detected at the instance level. Only the data of newly added and modified instances is retrieved, and only the data of expired instances is deleted, while most of the unchanged instance data is retained and reused in the local cache. This minimizes the amount of data transmitted over the network and the local cache update operations, which is the core of achieving efficient hot restart and fast recovery, directly addressing the stringent requirements for synchronization performance under large-scale deployment.

[0113] The solutions in the embodiments of this disclosure can be used individually or in combination without conflict. For example, S103, synchronizing data from the server to the local cache based on the detection result, and S305, determining that the second detection result includes the type of resource to be synchronized if the server resource version number is different from the second version number, can be used in combination without specific limitation.

[0114] Figure 4 This is a schematic diagram of the structure of a data synchronization device provided in an embodiment of this disclosure. The data synchronization device can be an electronic device as described in the above embodiment, or it can be a component or assembly within that electronic device. The data synchronization device provided in this embodiment can execute the processing flow provided in the data synchronization method embodiment, such as... Figure 4 As shown, the data synchronization device 50 includes: a connection module 51, a detection module 52, a synchronization module 53, and a disconnection module 54; wherein, the connection module 51 is used to establish a communication connection between the terminal and the server based on the acquired connection token; the detection module 52 is used to perform multi-level synchronization detection based on the data in the server and the data in the local cache of the terminal, and obtain the detection result, wherein the multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network of the terminal, and the differences between the data version of the server and the data version of the terminal; the synchronization module 53 is used to synchronize the data in the server to the local cache based on the detection result; the disconnection module 54 is used to release the connection token and disconnect the communication connection between the terminal and the server.

[0115] Optionally, when the detection module 52 performs multi-level synchronization detection based on the data in the server and the data in the local cache of the terminal to obtain the detection result, it is specifically used to: perform domain-level synchronization detection based on the first virtual private network set in the server and the second virtual private network set in the local cache to obtain a first detection result; if the first detection result includes an intersection domain, then for any resource type in the intersection domain, perform resource-level synchronization detection based on the first version number corresponding to the resource type in the server and the second version number corresponding to the resource type in the local cache to obtain a second detection result; the intersection domain is the virtual private network in the intersection of the first virtual private network set and the second virtual private network set; if the second detection result includes a resource type to be synchronized, then for the resource type to be synchronized, perform instance-level synchronization detection based on the first resource instance set of the resource type to be synchronized in the server and the first revision number of each resource instance, and the second resource instance set of the resource type to be synchronized in the local cache and the second revision number of each resource instance to obtain a third detection result.

[0116] Optionally, when the detection module 52 performs domain-level synchronization detection based on the first virtual private network set in the server and the second virtual private network set in the local cache to obtain the first detection result, it is specifically used to: obtain the identifiers of the virtual private networks currently existing in the server to form the first virtual private network set; obtain the identifiers of the virtual private networks stored in the local cache to form the second virtual private network set; compare the first virtual private network set with the second virtual private network set to obtain the first detection result, wherein the first detection result includes newly added domains, deleted domains, and intersection domains; wherein, the newly added domains are virtual private networks that belong to the first virtual private network set but not to the second virtual private network set, and the deleted domains are virtual private networks that belong to the second virtual private network set but not to the first virtual private network set.

[0117] Optionally, when the detection module 52 performs resource-level synchronization detection based on the first version number corresponding to the resource type on the server and the second version number corresponding to the resource type in the local cache, and obtains the second detection result, it is specifically used to: compare the server-side resource version number with the second version number; if the server-side resource version number is the same as the second version number, then determine that the second detection result does not include the resource type to be synchronized; if the server-side resource version number is not the same as the second version number, then determine that the second detection result includes the resource type to be synchronized.

[0118] Optionally, when the detection module 52 performs instance-level synchronization detection based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, and the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, and obtains a third detection result, it is specifically used to: obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored on the server as the first resource instance set; obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored in the local cache as the second resource instance set; identify resource instances in the second resource instance set that do not belong to the first resource instance set as resource instances to be deleted; identify resource instances in the first resource instance set that do not belong to the second resource instance set as resource instances to be added; for each resource instance in the intersection of the first resource instance set and the second resource instance set, obtain the first revision number of the resource instance on the server and the second revision number of the resource instance in the local cache; and in response to the first revision number and the second revision number being different, identify the resource instance as a resource instance to be modified.

[0119] Optionally, when the synchronization module 53 synchronizes the data in the server to the local cache based on the detection result, it is specifically used to: for each newly added domain, obtain the data of each resource type under the newly added domain from the server and synchronize the data to the local cache in full; for each deleted domain, remove the data corresponding to the deleted domain from the local cache.

[0120] Optionally, when the synchronization module 53 synchronizes the data in the server to the local cache based on the detection result, it is specifically used to: for the resource type to be synchronized in the intersection domain, based on the resource instance to be deleted, the resource instance to be added, and the resource instance to be modified, incrementally synchronize the data of the resource type to be synchronized in the server to the local cache.

[0121] Figure 4 The data synchronization device shown in the embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0122] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 5 It shows a schematic diagram of a structure suitable for implementing the electronic device 600 in the embodiments of this disclosure. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0123] like Figure 5 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603 to implement the data synchronization method as described in the embodiments of this disclosure. Various programs and data required for the operation of electronic device 600 are also stored in RAM 603. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0124] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0125] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the data synchronization method described above. In such embodiments, the computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from ROM 602. When the computer program is executed by processing device 601, it performs the functions defined above in the methods of embodiments of this disclosure.

[0126] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0127] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0128] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0129] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: The terminal establishes a communication connection with the server based on the obtained connection token. Based on the data in the server and the data in the local cache of the terminal, multi-level synchronization detection is performed to obtain the detection results. The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, as well as the differences between the data version in the server and the data version in the terminal. Based on the detection results, the data in the server is synchronized to the local cache; Release the connection token and disconnect the communication connection between the terminal and the server.

[0130] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also execute other steps of the above embodiments.

[0131] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0132] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0133] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0134] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.

[0135] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0136] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0137] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0138] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A data synchronization method, characterized in that, The method includes: The terminal establishes a communication connection with the server based on the obtained connection token. Based on the data in the server and the data in the local cache of the terminal, multi-level synchronization detection is performed to obtain the detection results. The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, as well as the differences between the data version in the server and the data version in the terminal. Based on the detection results, the data in the server is synchronized to the local cache; Release the connection token and disconnect the communication connection between the terminal and the server.

2. The method according to claim 1, characterized in that, The process involves performing multi-level synchronization detection based on data from the server and data from the terminal's local cache to obtain detection results, including: Based on the first set of virtual private networks in the server and the second set of virtual private networks in the local cache, domain-level synchronization detection is performed to obtain the first detection result. If the first detection result includes an intersection domain, then for any resource type in the intersection domain, based on the first version number corresponding to the resource type on the server and the second version number corresponding to the resource type in the local cache, a resource-level synchronization detection is performed to obtain a second detection result; the intersection domain is the virtual private network in the intersection of the first virtual private network set and the second virtual private network set; If the second detection result includes a resource type to be synchronized, then for the resource type to be synchronized, based on the first resource instance set and the first revision number of each resource instance on the server side, and the second resource instance set and the second revision number of each resource instance in the local cache, an instance-level synchronization detection is performed to obtain a third detection result.

3. The method according to claim 2, characterized in that, The first virtual private network set in the server and the second virtual private network set in the local cache are used to perform domain-level synchronization detection to obtain a first detection result, including: Obtain the identifiers of the virtual private networks currently existing in the server, and form a first set of virtual private networks; Obtain the identifiers of the virtual private networks stored in the local cache to form a second set of virtual private networks; By comparing the first set of virtual private networks with the second set of virtual private networks, a first detection result is obtained, which includes newly added domains, deleted domains, and intersection domains. The newly added domain is a virtual private network that belongs to the first virtual private network set but not to the second virtual private network set, and the deleted domain is a virtual private network that belongs to the second virtual private network set but not to the first virtual private network set.

4. The method according to claim 2, characterized in that, The process involves performing a resource-level synchronization check based on the first version number corresponding to the resource type on the server and the second version number corresponding to the resource type in the local cache, to obtain a second check result, including: Compare the server-side resource version number with the second version number; If the server-side resource version number is the same as the second version number, then it is determined that the second detection result does not include the resource type to be synchronized; If the server-side resource version number is different from the second version number, then the second detection result is determined to include the resource type to be synchronized.

5. The method according to claim 2, characterized in that, The third detection result is obtained by performing instance-level synchronization detection based on the first set of resource instances of the resource type to be synchronized on the server and the first revision number of each resource instance, and the second set of resource instances of the resource type to be synchronized in the local cache and the second revision number of each resource instance, and includes: Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored on the server, and use it as the first resource instance set; Obtain the set of resource instance identifiers belonging to the resource type to be synchronized stored in the local cache, and use it as the second resource instance set; Resource instances in the second resource instance set that do not belong to the first resource instance set are identified as resource instances to be deleted; Resource instances in the first resource instance set that do not belong to the second resource instance set are identified as resource instances to be added; For each resource instance in the intersection of the first resource instance set and the second resource instance set, obtain the first revision number of the resource instance on the server side and the second revision number of the resource instance in the local cache; In response to the fact that the first revision number and the second revision number are different, the resource instance is identified as a resource instance to be modified.

6. The method according to claim 3, characterized in that, The step of synchronizing the data from the server to the local cache based on the detection results includes: For each new domain, data of each resource type under the new domain is obtained from the server, and the data is fully synchronized to the local cache. For each deleted domain, remove the data corresponding to the deleted domain from the local cache.

7. The method according to claim 5, characterized in that, The step of synchronizing the data from the server to the local cache based on the detection results includes: For the resource types to be synchronized in the intersection domain, based on the resource instances to be deleted, the resource instances to be added, and the resource instances to be modified, the data of the resource types to be synchronized in the server is incrementally synchronized to the local cache.

8. A data synchronization device, characterized in that, include: The connection module is used to establish a communication connection between the terminal and the server based on the acquired connection token. The detection module is used to perform multi-level synchronization detection based on the data in the server and the data in the local cache of the terminal, and obtain the detection result. The multi-level synchronization detection refers to detecting the differences between the virtual private network in the server and the virtual private network in the terminal, and the differences between the data version in the server and the data version in the terminal. A synchronization module is used to synchronize data from the server to the local cache based on the detection results; The disconnect module is used to release the connection token and disconnect the communication connection between the terminal and the server.

9. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.