Data synchronization method and device under multi-level cache architecture, equipment and medium
By searching and updating data step by step under the multi-level cache architecture, and pushing updates based on security index and subscription information, the problem of poor data synchronization between different cache nodes is solved, and the consistency and security of cluster data are achieved.
Patent Information
- Application Number
- CN202411702337.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-04
AI Technical Summary
Under the multi-level cache architecture, the data synchronization between different cache nodes is poor, making it difficult to ensure cluster data consistency.
When the target application server receives a data update request, it searches for hit data in the multi-level cache layer step by step, updates the hit data of the local cache layer, and sends push information to the distributed system cache layer to update the data in the distributed system cache layer. According to the security index and subscription information of the cache node where the updated data in the distributed system cache layer is located, push information is sent to the local cache layer of other application servers.
Data consistency between different cache nodes in multiple cache layers is achieved, and security is ensured when cached data is synchronized.
Smart Images

Figure CN119760013A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data cache technology, and in particular to a data synchronization method, device, equipment and medium under a multi-level cache architecture. Background Art
[0002] With the explosive growth of data volume, cluster data consistency has become an important challenge. Traditional data consistency guarantee methods rely on centralized storage and transmission mechanisms, but with the development of distributed systems, this method has gradually exposed its fragility and single point failure problems. Multi-level cache technology, as an effective distributed data storage and access mechanism, is widely used to improve data access speed and system performance.
[0003] Although multi-level cache technology can improve data access speed and system performance, there are still challenges in ensuring cluster data consistency. Since data synchronization and update between caches may be delayed, data synchronization between different cache nodes is poor. Summary of the invention
[0004] In view of this, the present invention provides a data synchronization method, device, equipment and medium under a multi-level cache architecture to solve the problem of poor data synchronization between different cache nodes in cluster data.
[0005] In a first aspect, the present invention provides a data synchronization method under a multi-level cache architecture, the method comprising:
[0006] When the target application server receives a data update request, it sequentially queries each cache layer to see whether there is corresponding hit data, and determines the cache layer that first finds the hit data as the target cache layer, wherein the cache layer includes: a local cache layer and a distributed system cache layer, wherein the local cache layer is the upper cache layer of the distributed system cache layer;
[0007] If the target cache layer is a local cache layer, updating the hit data under the corresponding cache node in the target cache layer according to the data update request, and sending a first push message to the distributed system cache layer;
[0008] Update the cache data in the cache layer of the distributed system according to the first push information;
[0009] When the cache data in the cache layer of the distributed system is updated, the cache data in the local cache of other application servers is updated based on the security index and subscription information of the cache node corresponding to the updated cache data.
[0010] The method provided by the present invention searches for hit data in the multi-level cache layers step by step when the target application server receives a data update request. When the hit data is hit in the local cache layer of the target application server, the hit data in the local cache layer is updated and push information is sent to the distributed system cache layer to update the corresponding data in the distributed system cache layer. Push information is sent to the local cache layers of other application servers based on the security index of the cache node where the updated data in the distributed system cache layer is located and the specific subscription information, thereby ensuring data consistency between different cache nodes in multiple cache layers and security during cache data synchronization.
[0011] In an optional implementation, the cache layer further includes: a database, the distributed system cache layer is an upper cache layer of the database, and the method further includes:
[0012] If the target cache layer is a distributed system cache layer or a database, then according to the data update request, the hit data under the corresponding cache node in the target cache layer is updated, and the security index of the corresponding cache node in the target cache layer is obtained;
[0013] Sending second push information to the upper cache layer of the target cache layer according to the security index;
[0014] Update the cache data in the upper cache layer of the target cache layer according to the second push information;
[0015] If the upper cache layer of the target cache layer is a distributed system cache layer, sending a third push message to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0016] The cache data in the upper cache layer of the distributed system cache layer is updated according to the third push information.
[0017] In this embodiment, when the distributed system cache layer or database is the target cache layer where the hit data is located, after updating the corresponding data in the target cache layer, push information is sent to the cache layer of the upper level of the target cache layer step by step according to the security index of the cache node corresponding to the updated data, so that the upper level cache layer updates the corresponding cache data, ensures the synchronous update of the cache data, and ensures the data consistency in the corresponding cache nodes under each cache layer.
[0018] In an optional implementation, updating cache data in local caches of other application servers based on updating the security index and subscription information of the cache node corresponding to the cache data includes:
[0019] When the security index of the cache node corresponding to the updated cache data is greater than a first preset level, the cache data in the local cache of other application servers is updated based on the subscription information of the corresponding cache node in the distributed system cache layer.
[0020] In this embodiment, before pushing updated data according to subscription information within the distributed cache system, the security index of the cache node where the updated data is located is first judged. When the security index is higher than a preset level, it means that the data under the cache node may have higher permissions, that is, a faster response speed is required. Therefore, the cached data under the cache node can be pushed upward, so that the upper cache layer updates the corresponding cached data, thereby achieving faster response of high-authority data.
[0021] In an optional implementation, the sending the second push information to the upper cache layer of the target cache layer according to the security index includes:
[0022] When the target cache layer is a database, if the security index is greater than a second preset level, sending a second push message to the distributed system cache layer;
[0023] When the target cache layer is a distributed system cache layer, if the security index is greater than a first preset level, sending a second push message to the local cache layer of the target application server, the first preset level being higher than a second preset level;
[0024] When the upper cache layer of the target cache layer is a distributed system cache layer, sending the third push information to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer includes:
[0025] Determine the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0026] If the security index is greater than the first preset level, a third push message is sent to the upper cache layer of the distributed system cache layer.
[0027] In this embodiment, when the target cache layers are the database and distributed system cache layers respectively, different preset levels are used to compare with the security index of the corresponding cache nodes, so as to decide whether to send push information to the upper-level cache layer to update the cache data of the upper layer. At the same time, after the data of the upper-level cache layer is updated, the cache layer of the upper level is updated in the same way, so that the data in the nodes with higher levels can obtain higher cache access rights and faster data processing speed.
[0028] In an optional implementation manner, the safety index is obtained as follows:
[0029] Obtaining cache access status, historical data information, and preset permission configuration rules corresponding to the cache node;
[0030] The security index of the cache node is determined based on the permission configuration rule and the cache access status and historical data information corresponding to the cache node.
[0031] This implementation method determines the actual security index of each cache node by pre-determining the permission configuration rules based on actual needs and the cache access status and historical data information of each node. This allows dynamic adjustment of the security index to ensure that data in different cache nodes have access permissions and processing speeds that are more in line with actual needs.
[0032] In an optional implementation, updating the hit data under the corresponding cache node in the target cache layer according to the data update request includes:
[0033] Determine a primary cache node and a substitute cache node corresponding to the hit data;
[0034] Acquire the cache access status of the primary cache node, and if the cache access status is normal, update the hit data in the primary cache node according to the data update request;
[0035] If the cache access state is abnormal, the hit data in the substitute cache node is updated according to the data update request, and when it is monitored that the cache access state of the primary cache node returns to normal, the cache data in the substitute cache node is synchronized to the primary cache node.
[0036] In this embodiment, substitute nodes are set for each cache node in the cache layer, so that when the main node corresponding to the hit data is abnormal, the corresponding operation is performed by the substitute node, thereby ensuring the smoothness of data processing.
[0037] In an optional implementation manner, the cache access status is obtained as follows:
[0038] Obtain the first time when the cache node last processed a push message and the second time when the cache node last processed a pull message at a preset time interval;
[0039] When the difference between the first time and the second time is less than a preset time interval, determining that the cache access state of the cache node is abnormal;
[0040] When the difference between the first time and the second time is not less than a preset time interval, it is determined that the cache access state of the cache node is normal.
[0041] In this implementation mode, the message processing status of each cache node is obtained at a preset interval to monitor the cache nodes, so that it is possible to timely understand whether the actual cache access status of each cache node is abnormal.
[0042] In a second aspect, the present invention provides a data synchronization device under a multi-level cache architecture, the device comprising:
[0043] The data hit module is used to query whether there is corresponding hit data in each cache layer in turn when the target application server receives a data update request, and determine the cache layer where the hit data is first queried as the target cache layer. The cache layer includes: a local cache layer and a distributed system cache layer. The local cache layer is the upper cache layer of the distributed system cache layer;
[0044] A first data update module, configured to update the hit data under the corresponding cache node in the target cache layer according to the data update request when the target cache layer is a local cache layer, and send a first push message to the distributed system cache layer;
[0045] A second data updating module, configured to update cache data in the cache layer of the distributed system according to the first push information;
[0046] The data synchronization module is used to update the cache data in the local cache of other application servers based on the security index and subscription information of the cache node corresponding to the updated cache data when the cache data in the distributed system cache layer is updated.
[0047] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the data synchronization method under the multi-level cache architecture of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0048] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the data synchronization method under a multi-level cache architecture of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 It is a flowchart of a data synchronization method under a multi-level cache architecture according to an embodiment of the present invention;
[0051] Figure 2 is an example diagram of a multi-level cache architecture according to an embodiment of the present invention;
[0052] Figure 3 is a flow chart of a data synchronization method under another multi-level cache architecture according to an embodiment of the present invention;
[0053] Figure 4 is an example diagram of a state monitoring process of a cache node according to an embodiment of the present invention;
[0054] Figure 5 is an example diagram of a data processing flow under a multi-level cache architecture according to an embodiment of the present invention;
[0055] Figure 6 is an example diagram of a cache synchronization process according to an embodiment of the present invention
[0056] Figure 7 is a structural block diagram of a data synchronization device under a multi-level cache architecture according to an embodiment of the present invention;
[0057] Figure 8 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0059] With the explosive growth of data volume, cluster data consistency has become an important challenge. Traditional data consistency guarantee methods rely on centralized storage and transmission mechanisms, but with the development of distributed systems, this method has gradually exposed its fragility and single point failure problems. Multi-level cache technology, as an effective distributed data storage and access mechanism, is widely used to improve data access speed and system performance.
[0060] Although multi-level cache technology can improve data access speed and system performance, there are still challenges in ensuring cluster data consistency. Since data synchronization and update between caches may be delayed, data synchronization between different cache nodes is poor.
[0061] To this end, an embodiment of the present invention provides a data synchronization method under a multi-level cache architecture. When a target application server receives a data update request, it searches for hit data in the multi-level cache layer level by level. When it is hit in the local cache layer of the target application server, it updates the hit data in the local cache layer and sends push information to the distributed system cache layer to update the corresponding data in the distributed system cache layer, and sends push information to the local cache layer of other application servers based on the security index of the cache node where the updated data in the distributed system cache layer is located and the specific subscription information, thereby ensuring data consistency between different cache nodes in multiple cache layers and security during cache data synchronization.
[0062] According to an embodiment of the present invention, an embodiment of a data synchronization method under a multi-level cache architecture is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0063] In this embodiment, a data synchronization method under a multi-level cache architecture is provided, which can be used for a data cluster under the multi-level cache architecture described above. Figure 1 is a flow chart of a data synchronization method under a multi-level cache architecture according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0064] Step S101, when the target application server receives a data update request, it queries each level of cache layer in turn to see whether there is corresponding hit data, and determines the cache layer that first queries the hit data as the target cache layer. The cache layer includes: a local cache layer and a distributed system cache layer. The local cache layer is the upper cache layer of the distributed system cache layer.
[0065] For a cache system with a multi-level cache architecture, there are usually multiple cache layers, including the local cache layer of the application server itself and the cache layer corresponding to the distributed cluster system. When the application server receives a data update request from a requester, it will search in each cache layer in turn to see whether there is cache data corresponding to the data update request, that is, hit data, and determine the cache layer where the hit data is first found as the target cache layer.
[0066] For more information about the multi-level cache architecture, please refer to Figure 2 , is a diagram of a multi-level cache architecture according to an embodiment of the present invention. The top layer is the local cache corresponding to each of the multiple application servers, the middle layer is the distributed system cache layer, the Redis distributed system is taken as an example in the figure, and the bottom layer is the database that stores all the data.
[0067] Multi-level cache refers to setting up multiple cache levels in a computer system, each with its own storage space and access speed to optimize data access efficiency. The core idea is to use the cache hierarchy to store data at different levels, reduce direct access to the data source, thereby reducing data access latency and improving overall system performance.
[0068] In an example, when an application server A receives a data update request, such as data deletion, data modification, or data addition, the application server will first check whether there is hit data corresponding to the data update request in its local cache. If not, it will continue to perform the corresponding search operation in the lower-level distributed system cache layer. If it still does not exist, it will search for the corresponding hit data in the database and perform corresponding updates.
[0069] Step S102: if the target cache layer is a local cache layer, the hit data under the corresponding cache node in the target cache layer is updated according to the data update request, and a first push information is sent to the distributed system cache layer.
[0070] When the target application server finds the corresponding hit data in its own local cache, the search operation can be stopped and the local cache layer of the target application server can be determined as the target cache layer. For each cache layer, there are often multiple cache nodes, and each cache node is used to store specific cache data. After finding the corresponding hit data and the cache node where it is located, the hit data under the cache node is updated according to the specific data update request. At the same time, in order to ensure the data consistency in each level of cache layer, when the data in the local cache changes, it is necessary to publish push information to the distributed cache system to inform the changes in the data in the local cache layer.
[0071] Step S103: updating cache data in the cache layer of the distributed system according to the first push information.
[0072] When the distributed cache system receives the push information sent by the local cache, it will update the data in the cache layer corresponding to the hit data before the update in the local cache of the target application server according to the specific push information.
[0073] For example, the hit data corresponding to the data update request in the local cache is A, and there is data B corresponding to the hit data A in the local cache layer. The two may differ in specific data forms, but the meanings of the data they represent are the same.
[0074] When the hit data A in the local cache is updated, a push message, namely the first push message, will be sent to the distributed cache system based on the specific update situation. After receiving the push message, the distributed cache system will adaptively change its internal data B to achieve data synchronization in different cache layers.
[0075] Step S104: when the cache data in the distributed system cache layer is updated, the cache data in the local cache of other application servers is updated based on the security index and subscription information of the cache node corresponding to the updated cache data.
[0076] When the cache data in the distributed system cache layer is updated, it is necessary to determine which cache node has the cache data updated. Assuming that the node where the cache data is updated is X, cache node X has corresponding security level and subscription information. The security level is mainly used to characterize the permissions corresponding to the data under the cache node. The higher the security level, the faster the data under the cache node can be called, and the data inside it can be placed in a cache layer with a higher priority, that is, the local cache layer. Subscription information can be understood as other nodes that subscribe to the cache node in the publish-subscribe mode under the data multi-level cache architecture. These other nodes can be nodes in the upper-level cache layer, such as cache nodes in the local cache of some application servers. The level of the cache node can be fixed according to actual production needs, or it can be dynamically adjusted according to the actual operating status of the cache node, such as node access status, historical data information, etc. It can be set according to actual project needs.
[0077] According to the specific security level and subscription information of the cache node X, it is determined which cache nodes in other application servers need to perform adaptive data update based on the updated cache data in the cache node X, so as to achieve data consistency among different cache nodes.
[0078] For example, if the security level of cache node X is higher than a preset value, it means that the cache data under this node needs to be called as quickly as possible, that is, it can be placed in the local cache layer; at the same time, if cache node N subscribed to cache node X is located in the local cache layer corresponding to application server B, the cache data inside cache node N in application server B can be updated according to the specific update data in cache node A, thereby achieving data consistency in the target application server and other application servers.
[0079] The data synchronization method under the multi-level cache architecture provided in this embodiment searches for hit data in the multi-level cache layer level by level when the target application server receives a data update request. When it is hit in the local cache layer of the target application server, it updates the hit data in the local cache layer and sends push information to the distributed system cache layer to update the corresponding data in the distributed system cache layer, and sends push information to the local cache layer of other application servers based on the security index and specific subscription information of the cache node where the updated data in the distributed system cache layer is located, thereby ensuring data consistency between different cache nodes in multiple cache layers and security during cache data synchronization.
[0080] According to an embodiment of the present invention, another data synchronization method embodiment under a multi-level cache architecture is provided, which can be used for a data cluster under the above multi-level cache architecture. Figure 3 is a flow chart of a data synchronization method under another multi-level cache architecture according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0081] Step S201: When the target application server receives a data update request, it sequentially queries each cache layer to see whether there is corresponding hit data, and determines the cache layer that first finds the hit data as the target cache layer. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0082] Step S202: If the target cache layer is a local cache layer, the hit data under the corresponding cache node in the target cache layer is updated according to the data update request, and a first push message is sent to the distributed system cache layer. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0083] Step S203: Update the cache data in the distributed system cache layer according to the first push information. For a specific implementation method, refer to Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0084] Specifically, in addition to the local cache layer and the distributed system cache layer, the multi-level cache layer also includes: a database, wherein the distributed system cache is the upper cache layer of the database.
[0085] Refer to the above Figure 2 In the multi-level cache architecture, the local cache corresponding to the application server is included as the first-level cache layer, the cache corresponding to the distributed system is included as the second-level cache layer, and the bottom cache layer is the database, which has all the data.
[0086] Step S204: if the target cache layer is a distributed system cache layer or a database, the hit data under the corresponding cache node in the target cache layer is updated according to the data update request, and the security index of the corresponding cache node in the target cache layer is obtained.
[0087] It can be understood that after the target application server receives a data update request, it will search for the corresponding hit data in each cache layer layer by layer. When the corresponding hit data is not found in the local cache of the target application server, a new round of search will be performed in the distributed system cache layer. If the corresponding hit data is still not found in the distributed system cache layer, the corresponding data needs to be searched in the bottom-level database.
[0088] When there is no corresponding hit data in the local cache layer, it searches downward layer by layer. If the target cache layer is a distributed system cache layer or database, refer to the steps for updating the local cache, and similarly update the hit data in the target cache layer according to the specific data update request. At the same time, obtain the security index of the cache node where the updated hit data in the target cache layer is located, so as to determine whether to push information to the upper cache layer of the target cache layer to achieve synchronization of cache data.
[0089] Step S205: Send second push information to the upper-level cache layer of the target cache layer according to the security index.
[0090] Refer to the above Figure 1 The explanation of the security index in the illustrated embodiment is that the security index is used to characterize the permissions corresponding to the data under the cache node. The higher the security level, the faster the data under the cache node can be called, and the data inside the cache node can be placed in a cache layer with a higher priority.
[0091] If the security index of the cache node where the updated hit data in the target cache layer is located is high, it means that the cache permission of the data under the cache node is relatively high, and it can be placed in a cache layer with a higher priority, that is, the upper cache layer of the target cache layer. Therefore, a push message, that is, the second push message, can be sent to the upper cache layer of the target cache layer, so that the upper cache layer of the target cache layer can update its own cache data according to the specific push message. When the security index is low, it means that the corresponding read permission of the cache data under the cache node is low, that is, it cannot be placed in a cache layer with a higher priority, so there is no need to send push information to the upper cache layer.
[0092] In one example, whether to send push information to other cache nodes can be determined based on the security index and subscription information of the cache node where the updated hit data in the target cache layer is located. The other nodes here can be nodes located in the same cache layer or corresponding cache nodes in the previous cache layer. For details, please refer to the above Figure 1 In the illustrated embodiment, when cache data in the distributed system cache layer is updated, data synchronization across cache layers is performed based on the security index and subscription information of the cache node, which will not be described in detail here.
[0093] Specifically, in step S205, when the target cache layer is a database, if the security index is greater than a second preset level, a second push message is sent to the distributed system cache layer;
[0094] When the target cache layer is a distributed system cache layer, if the security index is greater than a first preset level, a second push message is sent to the local cache layer of the target application server, and the first preset level is higher than the second preset level.
[0095] It can be understood that, for a multi-level cache layer, when accessing data, the access priority of the local cache, the distributed system cache layer, and the database is reduced accordingly.
[0096] Therefore, when the target cache layer is a database, its upper cache layer is a distributed system cache layer. Therefore, it can be decided whether to send the second push information to its upper cache layer according to a relatively low second preset level to achieve data synchronization in the distributed system cache layer.
[0097] When the target cache layer is a distributed system cache layer, its upper cache layer is a local cache layer, so it is necessary to decide whether to send the second push information to its upper cache layer according to a relatively higher first preset level to achieve data synchronization in the local cache layer.
[0098] Step S206: Update the cache data in the upper cache layer of the target cache layer according to the second push information.
[0099] When the cache layer one level above the target cache layer receives the push information, ie, the second push information, it updates the data in the cache layer corresponding to the hit data in the target cache layer according to the specific content in the push information.
[0100] For example, assuming that the target cache layer is a distributed system cache layer, and its upper-level cache layer is the local cache layer corresponding to each application server, the local caches of multiple application servers receive the corresponding second push information. Here, application server A is taken as an example, and the same applies to the others. After receiving the specific push information, the corresponding cache node inside application server A will update the cache data in the cache node based on the specific data update status in the push information.
[0101] Specifically, when the distributed system cache layer sends push information to the upper cache layer, it can combine the specific subscription information to decide to which cache nodes in the local cache of the application server to send the push information. For details, refer to the above Figure 1 The corresponding contents in step S104 of the illustrated embodiment will not be repeated here.
[0102] In another example, assuming that the target cache layer is a database, and its upper-level cache layer is the cache layer corresponding to the distributed system, the corresponding cache nodes in the distributed system cache layer will also update the cache data in the nodes based on the specific data update status in the push information.
[0103] Further, if the upper cache layer of the target cache layer is a distributed system cache layer, a third push information is sent to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0104] The cache data in the upper cache layer of the distributed system cache layer is updated according to the third push information.
[0105] It can be understood that when the target cache layer is a database, its upper-level cache layer is the distributed system cache layer. Since the distributed system cache layer belongs to the middle layer, it still has an upper-level cache layer, that is, the local cache corresponding to each application server. Therefore, when the cache data in the cache node in the distributed system cache layer changes, it will determine whether to continue to send new push information, that is, the third push information, to the upper-level cache layer, that is, the cache node in the local cache layer, based on the security index of these changed cache nodes, so as to update the data in the local cache layer.
[0106] After the upper cache layer of the distributed system cache layer, that is, the local cache corresponding to each application server receives the third push information, the cache data of the corresponding cache node in the local cache is updated according to the specific data update status in the push information. Please refer to the above-mentioned related steps for details, which will not be repeated here.
[0107] Specifically, when the upper cache layer of the target cache layer is a distributed system cache layer, according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer, the third push information is sent to the upper cache layer of the distributed system cache layer, including:
[0108] Determine the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0109] If the security index is greater than the first preset level, a third push message is sent to the upper cache layer of the distributed system cache layer.
[0110] It can be understood that when data is updated in the distributed system cache layer due to push information sent by the database, it is necessary to determine the security index of the cache node where the updated cache data in the distributed system cache layer is located. When the security index is greater than the first preset level, push information is further sent to the upper-level cache layer, that is, the local cache layer, to achieve layer-by-layer data synchronization.
[0111] Specifically, in the above embodiment, the security index is obtained in the following manner:
[0112] Specifically, in the above embodiment, the security index is obtained in the following manner:
[0113] Step A: Obtain the cache access status, historical data information and preset permission configuration rules corresponding to the cache node.
[0114] Step B: determining the security index of the cache node based on the permission configuration rule and the cache access status and historical data information corresponding to the cache node.
[0115] It can be understood that each cache node in the multi-level cache architecture can be monitored, and the cache access status and historical data information of the cache node can be obtained in real time. The cache access status refers to the status of the cache node processing information. Specifically, whether the cache access status is good can be determined based on the time interval between the last time the cache node pushed or pulled information; historical data information refers to the data information cached by the cache node in the historical period, such as data type, data volume, etc.
[0116] At the same time, obtain specific permission configuration rules. Permission configuration rules can be understood as algorithms set by staff to calculate the security index of cache nodes based on cache access status and historical data information. After obtaining the actual cache access status and historical data information of the cache node, the security index corresponding to the cache node can be determined through specific permission configuration rules.
[0117] In another example, the security indexes corresponding to different cache nodes in each cache layer can be hard-coded according to actual production needs to ensure the stability and security of cache data synchronization.
[0118] Step S207: when the cache data in the distributed system cache layer is updated, the cache data in the local cache of other application servers is updated based on the security index and subscription information of the cache node corresponding to the updated cache data.
[0119] Specifically, in step S207, the cache data in the local cache of other application servers is updated based on the security index and subscription information of the cache node corresponding to the updated cache data, including:
[0120] When the security index of the cache node corresponding to the updated cache data is greater than the first preset level, the cache data in the local cache of other application servers is updated based on the subscription information of the corresponding cache node in the distributed system cache layer.
[0121] It can be understood that when the target cache layer is a local cache layer, a distributed system cache layer or a database, referring to the above specific steps, the cache data in the distributed system cache layer may be updated. When the cache data in the distributed system cache layer is updated, it can be determined whether to send push information to other application servers based on the security index and subscription information corresponding to the cache node where the cache data is updated. Only when the security index is greater than the first preset level, there is permission to send push information to other cache nodes based on the specific subscription information to synchronize the cache data. For the specific synchronization process, refer to Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0122] Furthermore, in the related steps of the above embodiment, updating the hit data under the corresponding cache node in the target cache layer according to the data update request includes:
[0123] Determine the primary cache node and the backup cache node corresponding to the hit data.
[0124] The cache access status of the primary cache node is obtained. If the cache access status is normal, the hit data in the primary cache node is updated according to the data update request.
[0125] If the cache access status is abnormal, the hit data in the substitute cache node is updated according to the data update request, and when it is monitored that the cache access status of the primary cache node returns to normal, the cache data in the substitute cache node is synchronized to the primary cache node.
[0126] It can be understood that for cache nodes in different cache layers, there will be corresponding substitute nodes. Therefore, in the target cache layer, there are primary cache nodes and substitute cache nodes, both of which have corresponding hit data. Therefore, it is necessary to determine the primary node and substitute node corresponding to the hit data, and obtain the cache access status of the primary cache node at the same time.
[0127] If the cache access status of the primary cache node is normal, the hit data of the primary cache node is directly updated according to the data update request, and the updated data is synchronized to the substitute node.
[0128] If the cache access status of the primary cache node is abnormal, the hit data in the substitute cache node needs to be updated according to the data update request, and when it is monitored that the cache access status of the primary cache node returns to normal, the cache data in the substitute cache node is synchronized to the primary cache node.
[0129] Furthermore, in the above steps, the cache access status is obtained as follows:
[0130] Obtain the first time when the cache node last processed a push message and the second time when the cache node last processed a pull message at a preset time interval;
[0131] When the difference between the first time and the second time is less than a preset time interval, determining that the cache access state of the cache node is abnormal;
[0132] When the difference between the first time and the second time is not less than the preset time interval, it is determined that the cache access state of the cache node is normal.
[0133] Specifically, refer to Figure 4 The illustrated embodiment is an example diagram of a status monitoring process of a cache node according to an embodiment of the present invention. As shown in the figure, the reconnection timing task is set to 5s, then the PushTime of the last message processing and the PullTime of the last message pulling of the cache node are obtained every 5s, and the difference between the two times is calculated. When the difference is less than the preset time interval, such as 10s, the cache access status of the cache node is determined to be normal; when the difference is greater than the preset time interval, the cache access status of the cache node is determined to be abnormal, and a reconnection operation is performed.
[0134] The data synchronization method under the multi-level cache architecture provided by the embodiment of the present invention searches for hit data in the multi-level cache layer level by level when the target application server receives a data update request. When it is hit in the local cache layer of the target application server, the hit data in the local cache layer is updated and push information is sent to the distributed system cache layer to update the corresponding data in the distributed system cache layer, and push information is sent to the local cache layer of other application servers according to the security index and specific subscription information of the cache node where the updated data in the distributed system cache layer is located, thereby ensuring data consistency between different cache nodes in multiple cache layers and security during cache data synchronization.
[0135] In order to facilitate understanding of the above-mentioned embodiments of the invention, an example diagram of a data processing flow under a multi-level cache architecture is provided according to an embodiment of the invention. Figure 5 As shown, the details are as follows:
[0136] First, when the application server receives a data update request, such as a write request or an update request, it first searches the local cache, i.e., L1, for a hit, that is, whether there is cache data corresponding to the data update request. If there is a hit, it is directly updated and the latest result is returned. If there is no hit, it searches L2, i.e., the distributed system cache layer, for a hit through a synchronization lock.
[0137] If there is still no hit in L2, the corresponding hit data is found in the database through Redis lock query and updated accordingly, and the local cache L1 and Redis cache L2 are written or updated, and the latest results are returned at the same time.
[0138] If L2 hits, it determines whether the L2 cache layer needs to be updated. If so, the cache is refreshed asynchronously. If not, L2 is updated according to the data update request, and the updated data is written to the local cache L1, and the latest result is returned.
[0139] Furthermore, when the application server directly updates the database, the specific cache process example is shown in the figure below: Figure 6 FIG. 1 is a diagram showing an example of a cache synchronization process according to an embodiment of the present invention.
[0140] First, after the application server directly updates the database, it deletes the corresponding cache data in the redis cache layer, and then sends cache deletion information to the redis cache layer, so that other cache nodes that have subscribed to the cache nodes corresponding to the deleted data perform corresponding cache deletions. At the same time, a pub / sub notification is sent to the local cache of the application server to delete the corresponding cache in the local cache, that is, the first-level cache.
[0141] After receiving the subscription notification, that is, the sub notification, the application server will update the time of processing the last push message, synchronize the redis offset through LLEN, and delete the local cache through PULL.
[0142] In one example, in the above method embodiment, a multi-level cache mechanism can be constructed based on the node's security index and historical data information. The security index can be calculated based on factors such as the node's terminal IP address and the number of abnormal information in the historical data information.
[0143] The node data is classified according to importance and access frequency, and the frequently accessed and highly important data is stored in the high-speed cache, and the infrequently accessed or less important data is stored in the low-speed cache.
[0144] Different cache access policies are set according to the node's security index and credit guarantee level. Nodes with higher security index and credit guarantee level can obtain higher cache access rights and faster data processing speed. When a node accesses the cache, its security index and credit guarantee level are first checked, and then cache access is performed according to the corresponding policy.
[0145] Real-time monitoring of node status and data transmission, including node security index, historical data information, cache access, etc. Dynamically adjust the node security index and credit guarantee level based on the actual performance and historical data information of the node. If a node has an abnormal situation or data inconsistency, timely measures are taken to deal with it, such as suspending node access, downgrading, etc.
[0146] At the same time, a substitute node is pre-set to replace the node for data transmission and storage when an abnormal situation occurs or the safety index is lower than the standard value. The substitute node has the same data and functions as the original node, which can ensure the continuity and consistency of data.
[0147] The following is an explanation of some of the technical background involved in the above method embodiment: Multi-level cache: Multi-level cache refers to setting up multiple cache levels in a computer system, each level has its own storage space and access speed to optimize data access efficiency. Its core idea is to utilize the hierarchical nature of the cache, store data at different levels, reduce direct access to the data source, thereby reducing data access latency and improving overall system performance.
[0148] L1 cache (first level cache): The cache closest to the CPU, with the fastest access speed but the smallest capacity. It is usually divided into data cache and instruction cache, which are used to store data and instructions respectively. L2 cache (second level cache): A cache level located between the L1 cache and the memory, with a slightly slower access speed than the L1 cache, but a larger capacity. It can serve as a supplement to the L1 cache to further reduce access to memory. pullTime: The time to pull the cache; pushTime: The time to push to the cache; 6.pub / sub: publish / subscribe; Distributed lock: A distributed lock is a synchronization mechanism across multiple service instances that allows coordinated access to shared resources between multiple service instances. The purpose is to ensure that only one service instance can access or modify shared resources at the same time, thereby avoiding data inconsistencies or conflicts.
[0149] When implementing the above method embodiment, the following specific implementation means may be combined:
[0150] Cache invalidation strategy, active invalidation: Actively invalidate the relevant cache when updating the database. This is usually achieved by deleting or invalidating the corresponding cache items after the data is updated. Ensuring that all relevant caches are deleted or invalidated immediately after updating the database can reduce the inconsistency time window between the cache and the database. Message queues and asynchronous updates.
[0151] Use message queues (such as Kafka, RabbitMQ, etc.) to asynchronously notify the cache system of database update operations. When the database is updated, a message is sent to the queue, and the cache system listens to the queue and processes these messages to update or delete cache items. This method can improve the system's response speed and throughput, but it increases the complexity and maintenance cost of the system.
[0152] Distributed locks: Use distributed locks (such as Redis's RedLock) when updating a cache or database to ensure that only one node can perform an update operation at the same time. This can avoid cache inconsistencies caused by concurrent updates, but may increase system complexity and latency.
[0153] Cache version number or timestamp: Add a version number or timestamp to the data item, and increase the version number or update time each time the data is updated. When reading data, check whether the version number or timestamp in the cache is consistent with that in the database. If not, reload the data from the database and update the cache. This method ensures that the read data is the latest, but may increase network overhead and database access.
[0154] In a multi-level cache architecture, caches are designed into multiple levels, usually including the following levels: Hardware-level cache: such as the CPU's L1, L2, and L3 caches. These caches are located inside the CPU and are used to speed up the CPU's access to main memory. They have the fastest access speed, but relatively small capacity. Operating system-level cache: such as file system cache, which speeds up file access by storing frequently accessed file data in memory. Software-level cache: includes application-level cache (such as JVM process cache), database cache (such as InnoDB buffer pool), and distributed cache (such as Redis, Memcached). These caches are used to speed up access to and processing of critical data.
[0155] The specific cache strategy determines which data is cached and how to manage the data in the cache. Common cache strategies include: Least Recently Used (LRU): replace the least recently used data with new data to ensure that the most frequently used data is always in the cache. First Ready (FIFO): replace the earliest data that enters the cache with new data. Least Frequently Used (LFU): replace the least frequently used data with new data. These strategies help optimize cache utilization and improve system performance.
[0156] To ensure that data in caches at all levels remain consistent, the following measures need to be taken: Cache update during write operations: When data is modified, update data in all cache levels at the same time. This can be achieved through write-through or write-back strategies. Expiration strategy: Set data expiration time in the cache. When data expires, the next access to the data will obtain the latest data from the next cache level or data source.
[0157] Cache update and maintenance mechanism To maintain the effectiveness and accuracy of the cache, the cache needs to be updated and maintained regularly. This includes: Cache preheating: Load hot data into the cache when the system starts or restarts to improve the performance after the system starts. Cache prefetching: Preload the data to be accessed into the cache to reduce access latency. Dynamically adjust the cache strategy: Dynamically adjust the cache size and replacement strategy according to the actual workload and access mode of the system to meet the performance requirements of different scenarios.
[0158] The multi-level cache architecture has the following advantages: Reduce memory access latency: By caching data in caches at all levels, the number of times the CPU accesses memory can be greatly reduced. Improve data utilization: Algorithms such as LRU can ensure that the most commonly used data is always in the cache, thereby improving data utilization. Optimize memory management: Through multi-level caches, you can avoid loading a large amount of data into the memory at one time, thereby effectively saving memory resources.
[0159] In this embodiment, a data synchronization device under a multi-level cache architecture is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0160] This embodiment provides a data synchronization device under a multi-level cache architecture, such as Figure 7 As shown, including:
[0161] The data hit module 401 is used to query whether there is corresponding hit data in each cache layer in turn when the target application server receives a data update request, and determine the cache layer that first queries the hit data as the target cache layer. The cache layer includes: a local cache layer and a distributed system cache layer. The local cache layer is the upper cache layer of the distributed system cache layer.
[0162] The first data update module 402 is used to update the hit data under the corresponding cache node in the target cache layer according to the data update request when the target cache layer is a local cache layer, and send a first push information to the distributed system cache layer.
[0163] The second data updating module 403 is used to update the cache data in the cache layer of the distributed system according to the first push information.
[0164] The data synchronization module 404 is used to update the cache data in the local cache of other application servers based on the security index and subscription information of the cache node corresponding to the updated cache data when the cache data in the distributed system cache layer is updated.
[0165] In some optional implementations, the cache layer further includes: a database, the distributed system cache layer is an upper cache layer of the database, and the first data update module 402 is further used to update the hit data under the corresponding cache node in the target cache layer according to the data update request when the target cache layer is the distributed system cache layer or the database, and obtain the security index of the corresponding cache node in the target cache layer;
[0166] Sending a second push message to the upper cache layer of the target cache layer according to the security index;
[0167] Update the cache data in the upper cache layer of the target cache layer according to the second push information;
[0168] If the upper cache layer of the target cache layer is a distributed system cache layer, sending a third push message to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0169] The cache data in the upper cache layer of the distributed system cache layer is updated according to the third push information.
[0170] In some optional implementations, the data synchronization module 404, when updating cached data in the local cache of other application servers based on the security index and subscription information of the cache node corresponding to the updated cached data, includes:
[0171] When the security index of the cache node corresponding to the updated cache data is greater than the first preset level, the cache data in the local cache of other application servers is updated based on the subscription information of the corresponding cache node in the distributed system cache layer.
[0172] In some optional implementations, the first data updating module 402, when sending the second push information to the upper cache layer of the target cache layer according to the security index, includes:
[0173] When the target cache layer is a database, if the security index is greater than a second preset level, sending a second push message to the distributed system cache layer;
[0174] When the target cache layer is a distributed system cache layer, if the security index is greater than a first preset level, sending a second push message to the local cache layer of the target application server, the first preset level being higher than the second preset level;
[0175] When the upper cache layer of the target cache layer is a distributed system cache layer, the first data updating module 402, when sending the third push information to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer, includes:
[0176] Determine the security index of the cache node corresponding to the updated cache data in the distributed system cache layer;
[0177] If the security index is greater than the first preset level, a third push message is sent to the upper cache layer of the distributed system cache layer.
[0178] In some optional implementations, the safety index is obtained as follows:
[0179] Obtain the cache access status, historical data information and preset permission configuration rules corresponding to the cache node;
[0180] The security index of the cache node is determined based on the permission configuration rules and the cache access status and historical data information corresponding to the cache node.
[0181] In some optional implementations, when the first data updating module 402 updates the hit data under the corresponding cache node in the target cache layer according to the data update request, it includes:
[0182] Determine the primary cache node and the backup cache node corresponding to the hit data;
[0183] Obtain the cache access status of the primary cache node. If the cache access status is normal, update the hit data in the primary cache node according to the data update request.
[0184] If the cache access status is abnormal, the hit data in the substitute cache node is updated according to the data update request, and when it is monitored that the cache access status of the primary cache node returns to normal, the cache data in the substitute cache node is synchronized to the primary cache node.
[0185] In some optional implementations, the cache access status is obtained in the following manner:
[0186] Obtain the first time when the cache node last processed a push message and the second time when the cache node last processed a pull message at a preset time interval;
[0187] When the difference between the first time and the second time is less than a preset time interval, determining that the cache access state of the cache node is abnormal;
[0188] When the difference between the first time and the second time is not less than the preset time interval, it is determined that the cache access state of the cache node is normal.
[0189] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0190] The data synchronization device under the multi-level cache architecture in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0191] The embodiment of the present invention also provides a computer device having the above Figure 7 The xxxx device shown.
[0192] See also Figure 8 , Figure 8 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 8As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 10 is taken as an example.
[0193] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0194] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0195] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0196] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0197] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0198] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0199] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0200] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A data synchronization method under a multi-level cache architecture, characterized in that: The method comprises: When the target application server receives a data update request, it sequentially queries each cache layer to see whether there is corresponding hit data, and determines the cache layer that first finds the hit data as the target cache layer, wherein the cache layer includes: a local cache layer and a distributed system cache layer, wherein the local cache layer is the upper cache layer of the distributed system cache layer; If the target cache layer is a local cache layer, updating the hit data under the corresponding cache node in the target cache layer according to the data update request, and sending a first push message to the distributed system cache layer; Update the cache data in the cache layer of the distributed system according to the first push information; When the cache data in the cache layer of the distributed system is updated, the cache data in the local cache of other application servers is updated based on the security index and subscription information of the cache node corresponding to the updated cache data.
2. The method according to claim 1, characterized in that The cache layer also includes: a database, the distributed system cache layer is an upper cache layer of the database, and the method further includes: If the target cache layer is a distributed system cache layer or a database, then according to the data update request, the hit data under the corresponding cache node in the target cache layer is updated, and the security index of the corresponding cache node in the target cache layer is obtained; Sending second push information to the upper cache layer of the target cache layer according to the security index; Update the cache data in the upper cache layer of the target cache layer according to the second push information; If the upper cache layer of the target cache layer is a distributed system cache layer, sending a third push message to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer; The cache data in the upper cache layer of the distributed system cache layer is updated according to the third push information.
3. The method according to claim 1, characterized in that: The updating of cached data in the local cache of other application servers based on the security index and subscription information of the cache node corresponding to the updated cached data includes: When the security index of the cache node corresponding to the updated cache data is greater than a first preset level, the cache data in the local cache of other application servers is updated based on the subscription information of the corresponding cache node in the distributed system cache layer.
4. The method according to claim 2, characterized in that: The sending the second push information to the upper cache layer of the target cache layer according to the security index includes: When the target cache layer is a database, if the security index is greater than a second preset level, sending a second push message to the distributed system cache layer; When the target cache layer is a distributed system cache layer, if the security index is greater than a first preset level, sending a second push message to the local cache layer of the target application server, the first preset level being higher than a second preset level; When the upper cache layer of the target cache layer is a distributed system cache layer, sending the third push information to the upper cache layer of the distributed system cache layer according to the security index of the cache node corresponding to the updated cache data in the distributed system cache layer includes: Determine the security index of the cache node corresponding to the updated cache data in the distributed system cache layer; If the security index is greater than the first preset level, a third push message is sent to the upper cache layer of the distributed system cache layer.
5. The method according to any one of claims 1 to 4, characterized in that The safety index is obtained as follows: Obtaining cache access status, historical data information, and preset permission configuration rules corresponding to the cache node; The security index of the cache node is determined based on the permission configuration rule and the cache access status and historical data information corresponding to the cache node.
6. The method according to claim 1 or 2, characterized in that: The updating of the hit data under the corresponding cache node in the target cache layer according to the data update request includes: Determine a primary cache node and a substitute cache node corresponding to the hit data; Acquire the cache access status of the primary cache node, and if the cache access status is normal, update the hit data in the primary cache node according to the data update request; If the cache access state is abnormal, the hit data in the substitute cache node is updated according to the data update request, and when it is monitored that the cache access state of the primary cache node returns to normal, the cache data in the substitute cache node is synchronized to the primary cache node.
7. The method according to claim 6, characterized in that The cache access status is obtained in the following manner: Obtain the first time when the cache node last processed a push message and the second time when the cache node last processed a pull message at a preset time interval; When the difference between the first time and the second time is less than a preset time interval, determining that the cache access state of the cache node is abnormal; When the difference between the first time and the second time is not less than a preset time interval, it is determined that the cache access state of the cache node is normal.
8. A data synchronization device under a multi-level cache architecture, characterized in that: The device comprises: The data hit module is used to query whether there is corresponding hit data in each cache layer in turn when the target application server receives a data update request, and determine the cache layer where the hit data is first queried as the target cache layer. The cache layer includes: a local cache layer and a distributed system cache layer. The local cache layer is the upper cache layer of the distributed system cache layer; A first data update module, configured to update the hit data under the corresponding cache node in the target cache layer according to the data update request when the target cache layer is a local cache layer, and send a first push message to the distributed system cache layer; A second data updating module, configured to update cache data in the cache layer of the distributed system according to the first push information; The data synchronization module is used to update the cache data in the local cache of other application servers based on the security index and subscription information of the cache node corresponding to the updated cache data when the cache data in the distributed system cache layer is updated.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data synchronization method under the multi-level cache architecture described in any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data synchronization method under the multi-level cache architecture according to any one of claims 1 to 7.
Citation Information
Cited By
Movie session data multi-level cache and low-delay synchronization method and system
CN121277992A
Digital library cloud cache and distributed resource scheduling optimization method
CN122640409A
Multi-level cache cooperative scheduling system based on distributed computing cluster of storage-computation separation
CN122861677A