Data synchronization and cache management method and system based on offline priority architecture, storage medium and electronic device

By caching data when devices are offline and synchronizing it when the network is restored, combined with version control and cache management strategies, conflicts and inconsistencies in data synchronization and cache management are resolved, achieving data consistency and efficient management, and improving user experience and performance.

CN119988487BActive Publication Date: 2026-07-24SICHUAN XUNYOU NETWORK TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SICHUAN XUNYOU NETWORK TECH
Filing Date
2024-12-27
Publication Date
2026-07-24

Smart Images

  • Figure CN119988487B_ABST
    Figure CN119988487B_ABST
Patent Text Reader

Abstract

The application provides a data synchronization and cache management method and system based on an offline priority architecture, a storage medium and an electronic device, wherein the method comprises: intercepting a network request and locally caching target data when the device is in an offline state; automatically synchronizing the locally cached target data with a server when the device restores network connection; based on a version control mechanism, detecting and resolving conflicts in the data synchronization process; based on a cache management mechanism, periodically checking the validity of the locally cached target data after the data synchronization is completed; and based on an update or expiration strategy, optimizing the target data according to the validity check result. The application has enhanced data consistency and integrity, automatically detects and resolves data conflicts, avoids data loss or errors, improves user experience, has more efficient data management and storage, and has better compatibility and cross-platform support.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer data processing technology, and in particular to a data synchronization and caching management method, system, storage medium, and electronic device based on an offline-first architecture. Background Technology

[0002] With the widespread adoption of internet applications and smart devices, offline data access and manipulation have become crucial for enhancing user experience. Especially in situations with unstable or no network connectivity, maintaining application availability and ensuring data consistency has become a critical challenge in current web development.

[0003] Existing offline support technologies typically employ a simple "Last-Writer-Wins (LWW)" strategy for data synchronization. However, this strategy is prone to data conflicts and inconsistencies and cannot effectively handle complex cache management issues. Furthermore, large applications often face difficulties in cache management when offline, with expired caches and redundant data frequently degrading application performance and user experience.

[0004] Therefore, there is an urgent need for a more intelligent and reliable offline-first architecture to solve problems such as data synchronization, cache management, and user experience. Summary of the Invention

[0005] One of the objectives of this invention is to provide a data synchronization and cache management method based on an offline-first architecture, which addresses the deficiencies of existing technologies mentioned above.

[0006] This invention provides a data synchronization and cache management method based on an offline-first architecture, comprising:

[0007] When the device is offline, network requests are intercepted and target data is cached locally; wherein, the target data includes at least: static resources, dynamic data, and user data operations;

[0008] When the device restores its network connection, it will automatically synchronize the target data cached locally with the server.

[0009] Based on version control mechanisms, conflict detection and resolution are performed during the data synchronization process.

[0010] After data synchronization is complete, the validity of the target data in the local cache is checked periodically based on the cache management mechanism;

[0011] Based on the update or expiration strategy, the target data is optimized according to the validity check results.

[0012] Optionally, the version control mechanism includes:

[0013] Version conflicts that occurred during the data synchronization process;

[0014] Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

[0015] Optionally, the cache management mechanism includes:

[0016] Based on multiple validity check strategies, the validity of the target data cached locally is checked at preset time intervals.

[0017] Optionally, the update or expiration policy includes:

[0018] When the validity check results indicate that the target data needs to be updated, the target data should be updated.

[0019] When the validity check results indicate that the target data needs to be removed, the target data is removed.

[0020] This invention provides a data synchronization and caching management system based on an offline-first architecture, comprising:

[0021] The caching module is used to intercept network requests and cache target data locally when the device is offline; wherein the target data includes at least: static resources, dynamic data, and user data operations;

[0022] The synchronization module is used to automatically synchronize the locally cached target data with the server when the device restores its network connection.

[0023] The resolution module is used to detect and resolve conflicts during the data synchronization process based on version control mechanisms.

[0024] The inspection module is used to periodically check the validity of the target data in the local cache based on the cache management mechanism after data synchronization is completed;

[0025] The optimization module is used to optimize target data based on the validity check results, according to the update or expiration policy.

[0026] Optionally, the version control mechanism includes:

[0027] Version conflicts that occurred during the data synchronization process;

[0028] Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

[0029] Optionally, the cache management mechanism includes:

[0030] Based on multiple validity check strategies, the validity of the target data cached locally is checked at preset time intervals.

[0031] Optionally, the update or expiration policy includes:

[0032] When the validity check results indicate that the target data needs to be updated, the target data should be updated.

[0033] When the validity check results indicate that the target data needs to be removed, the target data is removed.

[0034] The present invention provides a computer-readable storage medium storing a computer program, wherein a processor executes the computer program to implement the method described in any of the above embodiments.

[0035] An electronic device provided by an embodiment of the present invention includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in any of the above embodiments.

[0036] The present invention has achieved the following beneficial effects:

[0037] Enhanced data consistency and integrity: Ensure data consistency and integrity after network recovery through version-controlled data synchronization strategies.

[0038] Automatically detects and resolves data conflicts to prevent data loss or errors and improve user experience: Provides full offline functionality, allowing users to seamlessly access and manipulate data without a network connection; when the network is restored, the data is automatically synchronized to ensure users always see the latest information.

[0039] More efficient data management and storage: By adopting advanced local storage technology and efficient data management mechanisms, it can better handle large amounts of data and complex data structures, and improve the performance and response speed of applications in offline states.

[0040] Better compatibility and cross-platform support: Through standardized technologies and extensive testing, compatibility across various browsers and devices is ensured. Users receive a consistent offline experience regardless of the device they use.

[0041] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.

[0042] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0043] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0044] Figure 1 This is a schematic diagram of a data synchronization and cache management method based on an offline priority architecture in an embodiment of the present invention;

[0045] Figure 2 This is a schematic diagram of a data synchronization and caching management system based on an offline priority architecture, as described in an embodiment of the present invention. Detailed Implementation

[0046] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0047] This invention provides a data synchronization and cache management method based on an offline-first architecture, such as... Figure 1 As shown, it includes:

[0048] S1. When the device is offline, intercept network requests and cache target data locally; wherein, the target data includes at least: static resources, dynamic data, and user data operations; wherein, static resources typically refer to files that do not change or change very little after being stored on the server side, and these files can be directly sent to the client for display or use; dynamic data refers to data that changes according to user operations or system status, and this data is usually generated by server or client programs and dynamically sent to the client when needed; user data operations refer to the operation records of users on relevant data on the system, etc.

[0049] S2. When the device restores network connectivity, it automatically synchronizes the locally cached target data with the server.

[0050] S3. Based on the version control mechanism, perform conflict detection and resolution during the data synchronization process;

[0051] S4. After data synchronization is complete, periodically check the validity of the target data in the local cache based on the cache management mechanism;

[0052] S5. Based on the update or expiration strategy, optimize the target data according to the validity check results.

[0053] The present invention has achieved the following beneficial effects:

[0054] Enhanced data consistency and integrity: Ensure data consistency and integrity after network recovery through version-controlled data synchronization strategies.

[0055] Automatically detects and resolves data conflicts to prevent data loss or errors and improve user experience: Provides full offline functionality, allowing users to seamlessly access and manipulate data without a network connection; when the network is restored, the data is automatically synchronized to ensure users always see the latest information.

[0056] More efficient data management and storage: By adopting advanced local storage technology and efficient data management mechanisms, it can better handle large amounts of data and complex data structures, and improve the performance and response speed of applications in offline states.

[0057] Better compatibility and cross-platform support: Through standardized technologies and extensive testing, compatibility across various browsers and devices is ensured. Users receive a consistent offline experience regardless of the device they use.

[0058] The version control mechanism includes:

[0059] Version conflicts that occurred during the data synchronization process;

[0060] Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

[0061] Version conflicts include: concurrent modification conflicts (multiple users or nodes modify the same data item), deletion and modification conflicts (one node deletes data while another node modifies the data), and merge version conflicts (different nodes' synchronization states are based on different historical versions, resulting in the inability to merge updates correctly).

[0062] Correspondingly, solutions include: timestamp priority (comparing the timestamps of commits from each node, the latest modification is considered the valid version), version priority (each synchronization node has its own version number, and the newest version is applied first), and merge priority (if different parts of the data are modified, they are merged). Version control mechanisms are systems used to manage and track file changes, widely used in software development and other fields that require managing document modifications. They help teams collaborate, record historical versions, and revert to previous versions when necessary.

[0063] The cache management mechanism includes:

[0064] Based on multiple validity check strategies, the validity of the target data cached locally is checked at preset time intervals.

[0065] Validity check strategies include: verifying whether the data still meets the requirements of the application or system, and whether updates are needed.

[0066] Cache management mechanisms are a series of strategies and methods used in computer systems to manage the storage and access of cached data. A cache is a high-speed storage layer used for temporary data storage, with the aim of accelerating data access and reducing latency.

[0067] The update or expiration policy includes:

[0068] When the validity check results indicate that the target data needs to be updated, the target data should be updated.

[0069] When the validity check results indicate that the target data needs to be removed, the target data is removed.

[0070] Update or expiration policies are a crucial component of cache management. Their primary task is to ensure that cached data is updated (to maintain its up-to-dateness) or removed at appropriate times (to prevent expired data from consuming cache space). Typically, specific validity criteria (such as data timestamps, access frequency, and usage patterns) are used to determine whether data has expired or needs updating. By making reasonable update and expiration decisions, excessive expired data can be avoided in the cache, thereby improving system response speed, reducing cache pollution, and optimizing storage space utilization.

[0071] In one embodiment, when synchronizing locally cached target data with the server, the process is performed based on a data synchronization mechanism.

[0072] The steps for obtaining data synchronization are as follows:

[0073] S21. Based on the interaction trajectory between the user and the device within the most recent preset time, determine whether to enter the mechanism planning time;

[0074] In S21, the most recent preset time can be the most recent 20 minutes; the user moves in reality and generates a movement trajectory, and the user continuously interacts with the device. The generated interaction information is set on the real-world location of the user during the interaction on the movement trajectory, and finally the movement trajectory is used as the interaction trajectory; the interaction trajectory reflects the user's actual work and interaction with the device, so it can be used to determine whether to enter the mechanism planning time; the mechanism planning time is the time when the user can perform data synchronization mechanism planning;

[0075] S22. When it is determined to be an entry, assist the user in planning a data synchronization mechanism;

[0076] In S22, subsequent operations are only performed after it is confirmed that the user is entering the system, which improves the appropriateness of the timing of assisting the user and thus enhances the user experience. Secondly, after it is confirmed that the user is entering the system, the system also assists the user in planning the data synchronization mechanism, which improves the efficiency of the user in planning the data synchronization mechanism and further enhances the user experience.

[0077] In one embodiment, S21, determining whether to enter the mechanism planning time based on the interaction trajectory between the user and the device within the most recent preset time period includes:

[0078] S211. Determine multiple target trajectory nodes from the interaction trajectory; wherein, during determination, a target trajectory node is determined at preset intervals starting from the starting point of the interaction trajectory.

[0079] In S211, the interval distance can be 10 meters; the target trajectory node is a real location where an interaction occurs between a user and a device.

[0080] S211. Based on the first set of constraints, determine multiple sets of target trajectory nodes from each target trajectory node;

[0081] S212. When the set of each target trajectory node meets the second set constraint condition, it is determined that it is the time to enter the mechanism planning.

[0082] The first set of constraints includes:

[0083] Condition A1: The same set of target trajectory nodes contains more than N target trajectory nodes; where N is the floor value of the product of the total number of target trajectory nodes and a preset scaling factor; in condition A1, the scaling factor can be 0.2.

[0084] as well as,

[0085] Condition A2: The trajectory scenarios involved in each target trajectory node in the same set of target trajectory nodes are the same or there is a first scenario association relationship between each pair of them; In condition A2, the trajectory scenario involved is the scene in the user's real environment where the target trajectory node is located, which can be a work scene, etc.; The first scenario association relationship can be the same scene type, or the scene belongs to different sub-scenes for completing the same work task, etc.

[0086] The second set of constraints includes:

[0087] Condition B1: All the trajectory scenarios involved in each pair of adjacent target trajectory node sets have a second scenario association relationship; In Condition B1, the second scenario association relationship refers to the scenario transition relationship that represents the planning of a data synchronization mechanism when the user has a work gap. For example, the user moves from a high-intensity work state scenario A to a low-intensity work or idle state scenario B.

[0088] or,

[0089] Condition B2 states that the absolute value of the difference in the number of target trajectory nodes in each pair of adjacent target trajectory node sets does not exceed the absolute value threshold. In condition B2, assuming target trajectory node set A contains 5 nodes and set B contains 8 nodes, the absolute value of the difference in their numbers is |5-8| = 3. The absolute value threshold can be 5. This condition reflects the relative stability of user behavior over a period of time. If the difference in the number of nodes between each pair of adjacent target trajectory node sets does not exceed the threshold, it means that the user's behavioral trajectory fluctuates less over time, and scene transitions are relatively smooth. This is crucial for planning data synchronization mechanisms because if the user's scene transitions are too drastic (e.g., a large difference in the number of nodes), it may indicate a significant change in activity patterns, potentially leading to the failure or instability of the data synchronization mechanism. Conversely, smaller fluctuations indicate that the user's activity remains stable over a certain period, making it easier to plan the data synchronization mechanism.

[0090] This invention introduces interactive trajectories to determine whether to enter a mechanism planning opportunity, improving the efficiency and accuracy of opportunity determination. Under the constraints of the first set of constraints, a set of target trajectory nodes that can be used to determine whether to enter a mechanism planning opportunity are selected from the interactive trajectory. This eliminates the need for comprehensive analysis of the interactive trajectory, enabling targeted analysis, reducing system analysis resources, and improving the efficiency of opportunity determination. Under the constraints of the second set of constraints, the determination of whether to enter a mechanism planning opportunity is quickly made based on each set of target trajectory nodes, improving the accuracy of opportunity entry determination and enhancing the applicability of the system.

[0091] In one embodiment, S22, the mechanism for assisting users in planning data synchronization includes:

[0092] S2201. Generate a visualization model based on multimodal modeling criteria; wherein, the multimodal modeling criteria include at least: target data and data synchronization history;

[0093] In S2201, the data synchronization history is the historical record of data synchronization between the local cache and the server; the visualization model is a three-dimensional model that visualizes the basis for multimodal modeling.

[0094] S2202. When providing a user with a visual model, if the user requests assistance, multiple analysis intentions are determined based on the user's viewing history of the visual model.

[0095] In S2202, when users view the visualization model, the visualization model can be pushed to the user's smart terminal and other devices. When users view the visualization model, a viewing history is generated, which includes at least: the type of content viewed, the location of the content viewed, and the viewing time. When users view the visualization model, the data synchronization mechanism is analyzed. Therefore, the user's analysis intent can be determined based on this. The analysis intent represents how the user wants to analyze the visualization model.

[0096] S2203. Identify multiple sets of primary data source regions from the visualization model; wherein, the data from each data source region within the same primary data source region set is related to an analytical intent;

[0097] In S2203, a large amount of display data is distributed on the visualization model. The area where the display data is located is the data source area. Data related to analysis intent means that the data needs to be used when performing the analysis intent.

[0098] S2204. Extract multiple first model slices from the visualization model; wherein, the same first model slice contains all data source regions in a first data source region set;

[0099] In S2204, a model slice refers to a local model extracted from a visualization model;

[0100] S2205, Allows users to view each first model slice;

[0101] In S2205, when a user views each first model slice, they will see the first model slices that match their different analytical intentions in sequence, thus obtaining assistance.

[0102] S2206. Whenever a first model slice actively overlaps with other first model slices and the overlap exceeds the overlap threshold, or a first model slice passively overlaps with other first model slices, feature extraction is performed on at least two overlapping first model slices to obtain a feature set; wherein, active overlap refers to the overlap between other first model slices in the visualization model caused by the update of the analysis intent leading to the update of the first data source region set and thus the update of the first model slice; passive overlap refers to the overlap between first model slices and other first model slices caused by user operations;

[0103] In S2206, the overlap threshold can be 10%. Whenever a first model slice actively overlaps with another first model slice and the overlap exceeds the overlap threshold, or a first model slice passively overlaps with another first model slice, it indicates that the user analysis has made further progress in planning how to implement the data synchronization mechanism, and it is necessary to provide further assistance to the user. The features extracted in the feature set should include at least: the data source region within the overlapping area, the data source region of each of the two model slices, the overlap maintenance time, the overlap growth time, etc.

[0104] S2207. Based on the feature set, generate data source search rules; wherein, the data source search rules are the rules for searching the data source areas where data related to each feature in the feature set is located;

[0105] In S2207, for example: if the overlapping area is located in a specific geographic region or data block in the feature set, the search rules will point to these specific regions; for another example: if the overlap duration or growth time is long, the search rules may involve data within a specific time period, which may require synchronization or preprocessing; for yet another example: if the data in the overlapping area comes from region A, while slices A and B come from different data sources, then rules need to be designed based on the information in the feature set to retrieve the data in region A.

[0106] S2208. Based on the data source search rules, multiple sets of secondary data source regions are searched from the visualization model;

[0107] S2209. Extract multiple second model slices from the visualization model; wherein, the same second model slice contains all data source regions in a second data source region set;

[0108] S2210, for users to view each second model slice;

[0109] S2211. When the duration of non-overlapping between the first model slices exceeds the duration threshold, attempt to receive the planned data synchronization mechanism input by the user; if the attempt fails, based on the knowledge base of each analysis intent, generate mechanism planning suggestions according to the data of all data source regions in the first and second model slices.

[0110] In S2211, the duration threshold can be 10 minutes. When the duration of non-overlapping between the first model slices exceeds the duration threshold, it indicates that the user has basically completed the planning of the data synchronization mechanism and is attempting to receive the planned data synchronization mechanism input by the user. The knowledge base contains mechanism planning suggestions corresponding to different data under the analysis intent, and the knowledge base can store a large amount of expert experience related to the data synchronization mechanism.

[0111] S2212, Providing users with suggestions on the planning mechanism;

[0112] S2213. Receive the planned data synchronization mechanism from the user based on the mechanism planning suggestions.

[0113] In this embodiment of the invention, the use of multimodal modeling provides users with a comprehensive analytical foundation, thereby helping them formulate more accurate data synchronization strategies. The visualization model presents data as three-dimensional graphics, enabling users to more intuitively understand the data and its relationships, thus improving the efficiency and accuracy of the planning process. By displaying the first and second model slices, users can view data regions under different analytical intentions, helping them gradually analyze and determine the most suitable data synchronization solution. Based on the user's viewing history and analytical intentions, the system can provide personalized assistance in real time, enabling users to make decisions more efficiently. When active or passive overlap occurs between model slices, the system automatically extracts features and generates data source search rules based on overlapping areas, time, and other information, making the entire data synchronization planning process more intelligent and dynamically responding to user needs and adjusting strategies.

[0114] This invention provides a data synchronization and caching management system based on an offline-first architecture, such as... Figure 2 As shown, it includes:

[0115] Cache module 1 is used to intercept network requests and cache target data locally when the device is offline; wherein the target data includes at least: static resources, dynamic data, and user data operations;

[0116] Synchronization module 2 is used to automatically synchronize the locally cached target data with the server when the device restores its network connection;

[0117] Module 3 is used to detect and resolve conflicts during the data synchronization process based on version control mechanisms.

[0118] Module 4 is used to periodically check the validity of the target data in the local cache based on the cache management mechanism after data synchronization is completed;

[0119] Optimization module 5 is used to optimize target data based on the validity check results, according to the update or expiration strategy.

[0120] The version control mechanism includes:

[0121] Version conflicts that occurred during the data synchronization process;

[0122] Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

[0123] The cache management mechanism includes: checking the validity of target data in the local cache at preset time intervals based on multiple validity check strategies.

[0124] The update or expiration strategy includes: updating the target data when the validity check result indicates that the target data needs to be updated;

[0125] When the validity check results indicate that the target data needs to be removed, the target data is removed.

[0126] This invention provides a computer-readable storage medium storing a computer program, which is executed by a processor to implement the method described in any of the above embodiments.

[0127] This invention provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in any of the above embodiments.

[0128] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A data synchronization and cache management method based on an offline-first architecture, characterized in that, include: When the device is offline, network requests are intercepted and target data is cached locally; wherein, the target data includes at least: static resources, dynamic data, and user data operations; When the device restores its network connection, it automatically synchronizes the locally cached target data with the server. This synchronization is performed based on a data synchronization mechanism, which is established through the following steps: Based on the interaction trajectory between the user and the device within the most recent preset time, determine whether to enter the mechanism planning time; When it is determined that it is the right time to enter the mechanism planning, assist users in planning the data synchronization mechanism; The step of determining whether to enter the mechanism planning time based on the interaction trajectory between the user and the device within the most recent preset time includes: Multiple target trajectory nodes are determined from the interaction trajectory; wherein, during determination, a target trajectory node is determined at preset intervals starting from the starting point of the interaction trajectory. Based on the first set of constraints, multiple sets of target trajectory nodes are determined from each target trajectory node; When the set of target trajectory nodes meets the second set constraint condition, it is determined that it is the time to enter the mechanism planning. The first set of constraints includes: Condition A1: The same set of target trajectory nodes contains more than N target trajectory nodes; where N is the floor value of the product of the total number of target trajectory nodes and a preset scaling factor; and, Condition A2: The trajectory scenarios involved in each target trajectory node in the same target trajectory node set are the same or there is a first scenario association relationship between each pair of them; The second set of constraints includes: Condition B1: All trajectory scenes involved in each pair of adjacent target trajectory node sets have a second scene association relationship; or, Condition B2: The absolute value of the difference in the number of target trajectory nodes in each pair of adjacent target trajectory node sets does not exceed the absolute value threshold. Based on version control mechanisms, conflict detection and resolution are performed during the data synchronization process. After data synchronization is complete, the validity of the target data in the local cache is checked periodically based on the cache management mechanism; Based on the update or expiration strategy, the target data is optimized according to the validity check results.

2. The data synchronization and cache management method based on an offline-first architecture as described in claim 1, characterized in that, The version control mechanism includes: Version conflicts that occurred during the data synchronization process; Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

3. The data synchronization and cache management method based on an offline-first architecture as described in claim 1, characterized in that, The cache management mechanism includes: Based on multiple validity check strategies, the validity of the target data cached locally is checked at preset time intervals.

4. The data synchronization and cache management method based on an offline-first architecture as described in claim 1, characterized in that, The update or expiration policy includes: When the validity check results indicate that the target data needs to be updated, the target data should be updated. When the validity check results indicate that the target data needs to be removed, the target data is removed.

5. A data synchronization and caching management system based on an offline-first architecture, characterized in that, include: The caching module is used to intercept network requests and cache target data locally when the device is offline; wherein the target data includes at least: static resources, dynamic data, and user data operations; The synchronization module is used to automatically synchronize locally cached target data with the server when the device restores network connectivity. This synchronization is performed based on a data synchronization mechanism, the steps of which are as follows: Based on the interaction trajectory between the user and the device within the most recent preset time, determine whether to enter the mechanism planning time; When it is determined that it is the right time to enter the mechanism planning, assist users in planning the data synchronization mechanism; The step of determining whether to enter the mechanism planning time based on the interaction trajectory between the user and the device within the most recent preset time includes: Multiple target trajectory nodes are determined from the interaction trajectory; wherein, during determination, a target trajectory node is determined at preset intervals starting from the starting point of the interaction trajectory. Based on the first set of constraints, multiple sets of target trajectory nodes are determined from each target trajectory node; When the set of target trajectory nodes meets the second set constraint condition, it is determined that it is the time to enter the mechanism planning. The first set of constraints includes: Condition A1: The same set of target trajectory nodes contains more than N target trajectory nodes; where N is the floor value of the product of the total number of target trajectory nodes and a preset scaling factor; and, Condition A2: The trajectory scenarios involved in each target trajectory node in the same target trajectory node set are the same or there is a first scenario association relationship between each pair of them; The second set of constraints includes: Condition B1: All trajectory scenes involved in each pair of adjacent target trajectory node sets have a second scene association relationship; or, Condition B2: The absolute value of the difference in the number of target trajectory nodes in each pair of adjacent target trajectory node sets does not exceed the absolute value threshold. The resolution module is used to detect and resolve conflicts during the data synchronization process based on version control mechanisms. The inspection module is used to periodically check the validity of the target data in the local cache based on the cache management mechanism after data synchronization is completed; The optimization module is used to optimize target data based on the validity check results, according to the update or expiration policy.

6. The data synchronization and caching management system based on an offline-first architecture as described in claim 5, characterized in that, The version control mechanism includes: Version conflicts that occurred during the data synchronization process; Based on the conflict type and corresponding resolution strategy, the version conflict is resolved accordingly.

7. The data synchronization and caching management system based on an offline-first architecture as described in claim 5, characterized in that, The cache management mechanism includes: Based on multiple validity check strategies, the validity of the target data cached locally is checked at preset time intervals.

8. The data synchronization and caching management system based on an offline-first architecture as described in claim 5, characterized in that, The update or expiration policy includes: When the validity check results indicate that the target data needs to be updated, the target data should be updated. When the validity check results indicate that the target data needs to be removed, the target data is removed.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-4.

10. An electronic device, characterized in that, The electronic device includes a memory and a processor, wherein the memory stores a computer program and the processor executes the computer program to implement the method as described in any one of claims 1-4.