Local cache refreshing system and method, electronic equipment and storage medium
Through the combination of memory event management module, data storage module and local cache refresh module, and the use of scheduled tasks and incremental data mechanism, the problem of cache inconsistency in multi-instance deployment is solved, and efficient local cache refresh and consistency management are achieved.
Patent Information
- Application Number
- CN202510716182.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-12
AI Technical Summary
Existing technologies cannot effectively solve the problem of cache data inconsistency between instances in a local cache system with multi-instance deployment, resulting in users obtaining incorrect data or system operation errors.
A combination of memory event management module, data storage module and local cache refresh module is adopted to achieve real-time refresh and consistency verification of local cache by generating, storing and processing memory events, using scheduled tasks and incremental data mechanism.
It reduces the full data transmission overhead, improves the accuracy and consistency of cache refresh, reduces system redundancy, and ensures data consistency among multiple instances.
Smart Images

Figure CN120631933A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a local cache refresh system, method, electronic device and storage medium. Background Art
[0002] With the rapid development of mobile internet technology and the surge in the number of internet users, application systems face unprecedented performance challenges. To meet growing user demands and ensure high availability and reliability of application system services, clustered multi-instance deployment technology has emerged as a key solution for improving system performance and ensuring service stability.
[0003] Currently, the vast majority of application systems use distributed cache databases as their cache layer. While local caches deployed across multiple instances offer numerous advantages, they also face challenges such as non-sharing of cached data and inconsistent refreshes between instances. Inconsistent cache data between different instances can result in users accessing incorrect or outdated data in certain situations, and in severe cases, can even lead to system errors, resulting in a poor user experience. Currently, local cache refreshes across different instances are achieved by relying on middleware components to store business data changes and notify change messages. This requires deploying additional middleware clusters, considering communication and task scheduling between the middleware cluster and the service cluster, and functionally considering whether messages are consumed, consumed repeatedly, lost, or in what order. Alternatively, polling is used to refresh the local cache of each instance in turn, without guaranteeing real-time cache refreshes. Therefore, existing technologies cannot meet the requirements for cache consistency across multiple instances. Summary of the Invention
[0004] The present invention provides a local cache refresh system, method, electronic device and storage medium to solve the problem of inconsistency in local caches between different instances.
[0005] According to one aspect of the present invention, a local cache refresh system is provided, which includes a memory event management module, a data storage module, and a local cache refresh module corresponding to each instance in a target cluster; wherein,
[0006] A memory event management module, configured to generate corresponding memory events in response to event requests and send the memory events to the data storage module;
[0007] The data storage module receives memory events and stores them;
[0008] Each local cache refresh module is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate a memory event processing task based on the memory event incremental data, execute the memory event processing task, and return the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module can summarize and compare the received execution results and determine the target execution result.
[0009] Optionally, the memory event includes a cache refresh event; the memory event management module includes a memory event generation unit, the memory event generation unit is used to receive a cache refresh request, extract information from the cache refresh request, obtain characteristic information, and generate a cache refresh event based on the characteristic information, wherein the characteristic information includes at least a memory event type, an event start time, an event end time, first instance information, and data to be refreshed, and the memory event type includes one or more of a business data refresh event type and a system configuration information refresh event type.
[0010] Optionally, the memory event includes a cache query event; the memory event management module also includes a cache query unit, which is used to receive a cache query request and generate a cache query event based on the cache query request, wherein the cache query event includes at least the second instance information and the data to be queried.
[0011] Optionally, the local cache refresh module includes a cache refresh unit and an execution result notification unit; the cache refresh unit is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate memory event processing tasks corresponding to each memory event in the memory event incremental data based on the memory event incremental data, build a pending task queue based on the memory event processing tasks corresponding to each memory event in the memory event incremental data, start executing the pending task queue, assign a corresponding refresher to each memory event processing task in the pending task queue according to the memory event type corresponding to each memory event processing task in the pending task queue, execute the corresponding memory event processing task through the refresher, obtain the task execution result corresponding to the pending task queue, and send the task execution result corresponding to the pending task queue to the execution result notification unit; the execution result notification unit receives the task execution result, generates subscription information based on the task execution result, and publishes the subscription information to the memory event management module, wherein the subscription information includes the task execution result.
[0012] Optionally, the memory event processing task carries cache refresh parameters, which include one or more of the memory event retry count threshold and the memory event execution result return parameters; the memory event management module also includes a cache refresh configuration unit, which is used to receive a cache refresh configuration modification request and update the cache refresh parameters based on the cache refresh configuration modification request.
[0013] Optionally, the cache refresh unit is also used to obtain task execution failure data, add memory events in the task execution failure data to the pending task queue, so as to re-execute the memory event processing task in the task execution failure data, and add one to the execution times corresponding to the re-executed memory event processing task, obtain the memory event retry count threshold, and when the execution times corresponding to any memory event processing task are greater than the memory event retry count threshold, generate exception information based on the memory event processing task, and feed back the exception information to the information display end for display; and / or obtain the memory event execution result return parameter, and if the memory event execution result return parameter is a return identifier, the execution result execution return processing is performed.
[0014] Optionally, the memory event management module receives the task execution results returned by each instance in the target cluster, performs consistency verification on the task execution results of the same memory event processing task in each instance in the target cluster, obtains the verification results, and determines the target processing results of each memory event processing task based on the verification results.
[0015] According to another aspect of the present invention, a local cache refresh method is provided, comprising:
[0016] Generate a corresponding memory event in response to the event request through the memory event management module, and send the memory event to the data storage module;
[0017] Receive memory events through the data storage module and store the memory events;
[0018] The local cache refresh module set on each instance in the target cluster obtains memory event incremental data from the data storage module based on the scheduled task, generates a memory event processing task based on the memory event incremental data, executes the memory event processing task, and returns the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results to determine the target execution result.
[0019] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0020] at least one processor; and
[0021] a memory communicatively connected to at least one processor; wherein,
[0022] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the local cache refresh method of any embodiment of the present invention.
[0023] According to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the local cache refresh method of any embodiment of the present invention when executed.
[0024] The technical solution of the embodiment of the present invention provides a local cache refresh system, which includes a memory event management module, a data storage module and a local cache refresh module corresponding to each instance in the target cluster; wherein the memory event management module is used to generate corresponding memory events in response to event requests and send the memory events to the data storage module; the data storage module receives memory events and stores memory events, thereby realizing the generation of corresponding memory events according to event requests by the memory event management module and storing memory events, realizing the decoupling of event processing and storage through modular design, improving the flexibility and maintainability of the system, and ensuring the uniformity of data format for subsequent analysis and tracing; each local cache The memory refresh module is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate a memory event processing task based on the memory event incremental data, execute the memory event processing task, and return the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module can summarize and compare the received execution results and determine the target execution result. It realizes local cache refresh through the scheduled incremental refresh mechanism, reduces the full data transmission overhead, improves system performance, generates and executes memory event processing tasks based on memory event incremental data, realizes task-based processing to complete cache refresh, and uses the result comparison mechanism to ensure data accuracy, avoid single point errors, and improve the accuracy and consistency of cache refresh. Through this solution, it is realized that the local cache refresh module set on the instance in the cluster is used to execute the memory event processing task generated according to the memory incremental data, reduce the full data transmission overhead, and realize cache refresh of multiple instances under the application system based on the memory event mechanism, greatly reducing the redundancy of system equipment, ensuring local cache consistency, solving the problem of local cache inconsistency between different instances, and improving the accuracy and consistency of cache refresh.
[0025] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 This is a structural diagram of a local cache refresh system provided by the first embodiment of the present invention;
[0028] Figure 2 This is a schematic diagram of a cache query process applicable to an embodiment of the present invention;
[0029] Figure 3 This is a flow chart of a cache refresh process applicable to an embodiment of the present invention;
[0030] Figure 4 This is a flow chart of a local cache refresh method provided by Embodiment 2 of the present invention;
[0031] Figure 5 This is a flow chart of a local cache refresh method applicable to an embodiment of the present invention;
[0032] Figure 6 It is a structural diagram of an electronic device that implements the local cache refresh method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions 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 embodiments described are only 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 ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0034] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] Example 1
[0036] Figure 1 This is a structural diagram of a local cache refresh system provided by the first embodiment of the present invention. Figure 1 As shown, the system includes a memory event management module 110, a data storage module 120, and a local cache refresh module 130 corresponding to each instance in the target cluster; wherein the memory event management module 110 is used to generate corresponding memory events in response to event requests and send the memory events to the data storage module 120; the data storage module 120 receives memory events and stores the memory events; each local cache refresh module 130 is used to obtain memory event incremental data from the data storage module 120 based on a scheduled task, generate a memory event processing task based on the memory event incremental data, execute the memory event processing task, and return the execution result corresponding to the memory event processing task to the memory event management module 110, so that the memory event management module 110 summarizes and compares the received execution results and determines the target execution result. Among them, the target cluster can be specifically understood as a cluster that needs to refresh the cache, and the target cluster includes multiple instances. The instance specifically represents an entity that integrates computing power, storage capacity and communication resources. The instance can be a computer, a server, or a container composed of one or more Pods. In order to complete the local cache refresh and ensure the data consistency of each instance in the target cluster, a local cache refresh module 130 is set in each instance in the target cluster. Local cache specifically refers to. Memory events can be specifically understood as various events related to the use, management and operation of memory. Memory events include but are not limited to cache refresh events and cache query events. For example, when business data changes, a corresponding cache refresh event will be generated; memory events are composed of at least one element of event type, event start time, event end time, target instance to be cache refreshed, event priority, data change content, and whether to return execution results. Cache refresh events can be specifically understood as a type of refresh event related to cache in memory events, which refers to the operation of updating or replacing data in the cache under specified conditions. Cache refresh methods include but are not limited to timed refresh and event triggering. Timed refresh is to update the data in the cache at fixed time intervals. Event triggering refers to triggering the update of the cache through time notification when business data changes. A cache query event is a cache-related query type event within a memory event. It is used to view the cache status within an instance. For example, if inconsistent responses to user access requests are detected, a cache query event can be triggered. Cache query events can be used to query cache details within the instance and further determine whether there is a cache inconsistency issue.
[0037] Specifically, after receiving an event request, the memory event management module 110 first parses the request and generates a corresponding memory event, such as a cache query event or a cache refresh event, according to a preset event generation rule, and then sends the encapsulated memory event to the data storage module 120 in accordance with the specified data format and transmission protocol; after receiving the memory event, the data storage module 120 will verify and classify the memory event, select a suitable storage structure for persistent storage based on the attributes of the memory event, and generate a unique event identifier for subsequent tracking; wherein, the attributes of the cache event include but are not limited to the event type, timestamp and associated data identifier, and the storage structure includes but is not limited to database tables, file storage and distributed storage. Each local cache refresh module 130 polls the data storage module 120 at a set fixed time interval or based on an event trigger mechanism, obtains the newly added memory event incremental data according to the event identifier or timestamp obtained last time, and after parsing the memory event incremental data, generates a memory event processing task according to the event processing logic, and schedules the local processing engine to execute the task. After the execution is completed, the execution result is returned to the memory event management module 110. For example, the execution result containing information such as task execution status, processing result data, and time consumption can be encapsulated into a response message and returned to the memory event management module 110 in an asynchronous or synchronous manner; after the memory event management module 110 receives the execution results of each local cache refresh module 130, it first performs format unification processing, and then summarizes the results based on the event identifier. By comparing the consistency of the processing results of different modules, the integrity of the verification result data and the matching degree with the expected result, the target execution result is finally determined. After obtaining the target execution result, the target execution result can also be transmitted to the data storage module 120, and the event storage module stores the execution result of the corresponding memory event, which is convenient for subsequent query and problem tracing, improves the management of memory events, and helps to improve system stability.
[0038] In this embodiment, a closed-loop process of event generation, event storage, event processing, and result verification is formed through modular design. The responsibilities of each module are clear and the coupling is low, which is convenient for independent development, testing and maintenance; scheduled tasks combined with incremental data acquisition mechanism can not only reduce invalid data transmission, but also ensure the real-time processing of events and reduce system resource consumption; persistent storage of memory events provides data support for event tracing, troubleshooting and performance analysis, and improves system observability; the parallel processing mechanism of multiple local cache refresh modules can use distributed computing capabilities to improve event processing efficiency, and the result summary and comparison mechanism ensures the accuracy of processing results through multiple verifications, which is especially suitable for scenarios with high requirements for data consistency; the system architecture has good scalability, and can cope with the growth of event volume by adding local cache refresh modules or expanding the capacity of data storage modules to meet the needs of business scale expansion.
[0039] Optionally, the memory event includes a cache refresh event; the memory event management module 110 includes a memory event generation unit, the memory event generation unit is used to receive a cache refresh request, extract information from the cache refresh request, obtain characteristic information, and generate a cache refresh event based on the characteristic information, wherein the characteristic information includes at least a memory event type, an event start time, an event end time, first instance information, and data to be refreshed, and the memory event type includes one or more of a business data refresh event type and a system configuration information refresh event type.
[0040] Among them, the cache refresh event can be specifically understood as an operation event triggered when any instance in the target cluster needs to update the local cache. The characteristic information specifically represents the information associated with the operation event of the instance, including but not limited to the memory event type, event start time, event end time, first instance information and data to be refreshed. The memory event type specifically represents the classification identifier used to identify the specific operation attributes and processing logic of the memory event. In the cache refresh scenario of the system, it can include one or more of the business data refresh event type and the system configuration information refresh event type. The first instance information specifically represents the target instance that needs to be cache refreshed.
[0041] Specifically, after receiving the cache refresh request, the memory event generation unit parses the cache refresh request, extracts the characteristic information in the cache refresh request, and then generates a corresponding cache refresh event according to the event generation template based on the characteristic information. For example, the characteristic information can be extracted through the regular matching or protocol parsing method built into the memory event generation unit, and the extracted characteristic information can be encapsulated as a memory refresh event according to a predefined data structure. Exclusive processing logic and priority can be assigned to different event types, and a unique event ID can be generated for tracking; finally, the complete event object is serialized and stored in the message queue or directly passed to the storage module.
[0042] In this embodiment, feature extraction and event generation are performed through the memory event generation unit, thereby improving the system's compatibility with heterogeneous requests through a standardized feature extraction mechanism and supporting unified access to multi-source systems; event type segmentation enables independent optimization of refresh strategies for business data and system configurations, thereby improving cache update efficiency; time dimension features provide data support for performance monitoring, facilitating the discovery of refresh bottlenecks; instance information implements event tracing and accelerates fault location; different refresh frequencies and processes can be formulated based on the real-time requirements of business data and the stability requirements of system configurations to optimize resource allocation; unified event type identification facilitates event classification management, tracking statistics, and anomaly investigation, providing a basis for refined control of cache update strategies in distributed systems, ensuring that cache consistency maintenance for different types of data is more targeted and efficient.
[0043] Optionally, the memory event includes a cache query event; the memory event management module 110 also includes a cache query unit, which is used to receive a cache query request and generate a cache query event based on the cache query request, wherein the cache query event includes at least the second instance information and the data to be queried.
[0044] The second instance information specifically represents data related to the instance on which the cache query request needs to be executed, including but not limited to the instance name, and can be extracted from the cache refresh query request.
[0045] Specifically, after receiving a cache query request, the cache query unit of the memory event management module 110 first parses the cache query request structure and extracts information in the request, which includes at least the instance identifier to be queried and the data to be queried, and determines the extracted instance identifier to be queried as the second instance information. At the same time, the query conditions are obtained from the request body as the data to be queried, wherein the query conditions include but are not limited to the business data type and the cache identifier; then, the second instance information and the data to be queried are encapsulated into a cache query event according to a predefined event model, a unique event ID is generated and a timestamp is attached; finally, the generated cache query event object is serialized and stored in a message queue or directly passed to the data storage module 120.
[0046] In this embodiment, by parsing the cache query request and extracting key information, the information is encapsulated into a cache query event with a unique ID and timestamp according to a predefined model. The entire process achieves the accuracy of information extraction and standardized processing of event generation, thereby improving the efficiency of cache queries; the event processing mechanism enables query requests to be recorded, monitored and audited, thereby improving the observability of the system; the standardized event model reduces the coupling between the cache query unit and other components, enhances the scalability of the system, and is particularly suitable for collaborative query scenarios of multi-instance caches under a microservice architecture.
[0047] Optionally, the local cache refresh module 130 includes a cache refresh unit and an execution result notification unit; the cache refresh unit is used to obtain memory event incremental data from the data storage module 120 based on a scheduled task, generate memory event processing tasks corresponding to each memory event in the memory event incremental data based on the memory event incremental data, build a pending task queue based on the memory event processing tasks corresponding to each memory event in the memory event incremental data, start executing the pending task queue, assign a corresponding refresher to each memory event processing task in the pending task queue according to the memory event type corresponding to each memory event processing task in the pending task queue, execute the corresponding memory event processing task through the refresher, obtain the task execution result corresponding to the pending task queue, and send the task execution result corresponding to the pending task queue to the execution result notification unit; the execution result notification unit receives the task execution result, generates subscription information based on the task execution result, and publishes the subscription information to the memory event management module 110, wherein the subscription information includes the task execution result.
[0048] Among them, the memory event incremental data can be specifically understood as a collection of memory event data that is newly added or has changed status after the last data synchronization operation in the data storage module 120. This type of data can be marked with timestamps, version numbers, etc., and only contains events generated since the last synchronization, such as data creation, update, deletion and other operation records, rather than all historical data. It aims to reduce the amount of data transmission and processing overhead by synchronizing only the changed parts, ensure the data consistency between the memory cache and the storage module, and rely on event types and operation records to provide accurate incremental update basis for subsequent cache refresh, task processing, etc., which is a key data form for achieving efficient memory data management. For example, event data generated or updated after the last synchronization time point can be filtered out from the data storage module 120 based on markers such as timestamps or version numbers; then the filtered event data is checked for legitimacy, and records with incorrect formats or incomplete records are eliminated to obtain memory event incremental data.
[0049] Specifically, the local cache refresh module 130 consists of a cache refresh unit and an execution result notification unit. The cache refresh unit can obtain memory event incremental data from the data storage module 120 through a scheduled task, convert it into corresponding memory event processing tasks, and build a queue of pending tasks. The cache refresh unit assigns a dedicated refresher to execute the task based on the memory event type of the task and sends the execution result to the execution result notification unit. After receiving the execution result, the execution result notification unit generates subscription information containing the task execution status and publishes it to the memory event management module 110.
[0050] In this embodiment, automatic synchronization of cached incremental data is achieved through a timing mechanism. The memory event type corresponding to each memory event processing task is assigned a corresponding refresher to each memory event processing task, and local refresh is performed to ensure orderly and efficient processing. Data consistency is maintained with the help of an execution result subscription notification mechanism, and the modular design reduces coupling and improves system maintainability and processing efficiency.
[0051] In a specific embodiment, Figure 2 The flowchart of a cache query is shown in the figure. The main function of the cache query unit is to query the cache content of all instances or specified instances under the cluster. The total number of cache objects under the instance, the list of different types of cache objects, the details of a certain cache object, etc. can be queried. The user can create a memory event of the cache query type to query the cache content under the instance and obtain the query result. When the local cache refresh unit receives the cache query event and recognizes that there is a return query result identifier in the memory event, each instance of the service cluster publishes a subscription message through the cache refresh result notification module. After receiving the subscription message, the cache query unit counts the execution results of each instance memory event, summarizes and processes the execution results of each instance memory event, and obtains the cache content of all instances or a certain instance under the cluster. If the cache refresh unit returns the memory event execution result, the refresh results of the cache refresh unit can be summarized and compared to obtain the final execution result of the memory event. The execution result is stored in the data storage unit, and the target execution result can also be sent to the client and displayed to the user.
[0052] Optionally, the memory event processing task carries cache refresh parameters, which include one or more of the memory event retry count threshold and the memory event execution result return parameters; the memory event management module 110 also includes a cache refresh configuration unit, which is used to receive a cache refresh configuration modification request and update the cache refresh parameters based on the cache refresh configuration modification request.
[0053] Specifically, when a memory event processing task is created, it carries cache refresh parameters, which include but are not limited to the memory event retry count threshold and part or all of the content in the memory event execution result return parameter; the cache refresh configuration unit receives a cache refresh configuration modification request sent externally, and dynamically updates the cache refresh parameters based on the request content. The updated parameters will be applied to subsequently generated memory event processing tasks.
[0054] In this embodiment, the retry strategy and result return method can be adjusted according to different business scenarios and real-time needs; reasonably setting the retry threshold can avoid infinite retry and consume resources, improve fault handling efficiency, and enhance system reliability; by customizing the result return parameters, it is convenient to monitor the system operation status, and the data that needs to be returned can be returned, and the results that do not need to be returned do not need to be returned, thereby reducing resource consumption; the separation of configuration units and processing tasks reduces coupling and facilitates system maintenance and expansion.
[0055] Optionally, the cache refresh unit is also used to obtain task execution failure data, add memory events in the task execution failure data to the pending task queue, so as to re-execute the memory event processing task in the task execution failure data, and add one to the execution times corresponding to the re-executed memory event processing task, obtain the memory event retry count threshold, and when the execution times corresponding to any memory event processing task are greater than the memory event retry count threshold, generate exception information based on the memory event processing task, and feed back the exception information to the information display end for display; and / or obtain the memory event execution result return parameter, and if the memory event execution result return parameter is a return identifier, the execution result execution return processing is performed.
[0056] Specifically, in the process of constructing tasks to be processed, the cache refresh unit, in addition to generating memory event processing tasks from the memory event incremental data in the data storage module 120, also obtains task execution failure data from the failed task queue. After obtaining the task execution failure data, the memory event in the task execution failure data is added to the task queue to be processed for re-execution, and the number of re-executed task executions is increased by one. At the same time, the memory event retry count threshold is obtained. When the number of executions of any task exceeds the memory event retry count threshold, it indicates that the task execution is abnormal, and then abnormal information is generated according to the task name and execution count of the task and fed back to the information display terminal for display; or, in the case of obtaining the memory event execution result return parameter, if the parameter is a return identifier, the execution result is returned; if the parameter is a non-return identifier, there is no need to return the execution result.
[0057] In this embodiment, by re-queuing failed tasks and controlling the number of retries, the reliability of the system in handling exceptions is improved, avoiding task loss due to accidental failures and preventing the waste of resources by infinite retries; the exception information is fed back to the display end to facilitate timely discovery and resolution of problems, thereby enhancing the observability of the system; the execution results are returned and processed according to parameters, making the result feedback more flexible, meeting the needs of different scenarios, and improving the adaptability and interactivity of the system.
[0058] In a specific embodiment, Figure 3The flowchart of a cache refresh process shown is that the cache refresh unit is mainly used to refresh business data to the local cache. Because different types of memory events require different cache refresh actions, different types of cache refreshers are established according to different memory event types. The cache refresher obtains the corresponding memory event through the scheduled task. In order to ensure the consistency and real-time performance of the cache refresh, different scheduled task strategies can be maintained through the cache refresh configurator. The cache refresh unit pulls the business data to be refreshed from the data storage unit according to the type of memory event and the changed content. The cache refresher maintains two task queues: a task queue to be executed and a failed task queue. The task queue to be executed contains memory events to be executed; the failed task queue contains memory events that failed to execute last time. The detailed workflow is as follows. Figure 3 As shown: For memory events that fail to execute, they are placed in the failure queue and the execution count is increased by 1. The cache refresh unit retries the failed memory event. If successful, the cache refresh is successful and it is removed from the failure queue. If the number of failures reaches the configured upper limit, the cache refresh result notifier notifies the user of the refresh failure instance information and the failed data content for manual processing.
[0059] Optionally, the memory event management module 110 receives the task execution results returned by each instance in the target cluster, performs consistency verification on the task execution results of the same memory event processing task in each instance in the target cluster, obtains the verification results, and determines the target processing results of each memory event processing task based on the verification results.
[0060] Specifically, the memory event management module 110 receives the execution results returned by each instance in the target cluster for the same memory event processing task, compares and verifies these results, for example, checking whether the data version, operation status code, or key data fields are consistent, and obtains a verification result. If the results are consistent, the consistent result is selected as the target processing result. If there is a conflict, a preset strategy such as retry, manual intervention, or priority-based selection is triggered. Successfully processed cache refresh events and related information are then stored in the data storage module 120.
[0061] In this embodiment, by verifying the execution results returned by the memory event processing task, data consistency of memory event processing in a cluster environment is achieved, data divergence is avoided, and instance anomalies can be discovered in a timely manner through inconsistent results, thereby improving the accuracy of system decision-making in a distributed environment. It also supports the horizontal expansion of the cluster architecture, ensures the correctness of multi-instance collaborative processing through a unified verification mechanism, and significantly enhances the reliability and fault self-discovery capability of memory event processing in distributed systems.
[0062] The technical solution of this embodiment provides a local cache refresh system, which includes a memory event management module, a data storage module and a local cache refresh module corresponding to each instance in the target cluster; wherein the memory event management module is used to generate corresponding memory events in response to event requests and send the memory events to the data storage module; the data storage module receives memory events and stores the memory events; each local cache refresh module is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate a memory event processing task based on the memory event incremental data, execute the memory event processing task, and return the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results and determines the target execution result. Through this solution, it is achieved that the memory event processing task generated according to the memory incremental data is executed by relying on the local cache refresh module set on the instance in the cluster, reducing the full data transmission overhead, and realizing the cache refresh of multiple instances under the application system based on the memory event mechanism, greatly reducing the redundancy of system equipment, ensuring local cache consistency, solving the problem of local cache inconsistency between different instances, and improving the accuracy and consistency of cache refresh.
[0063] The local cache refresh system provided by the embodiment of the present invention can execute the local cache refresh method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0064] Example 2
[0065] Figure 4 This is a flow chart of a local cache refresh method provided by the second embodiment of the present invention. This embodiment is applicable to the case of performing local cache refresh. The method can be executed by a local cache refresh system. The local cache refresh system can be implemented in the form of hardware and / or software. The local cache refresh system can be configured in electronic devices such as computers and servers. Figure 4 As shown, the method includes:
[0066] S410: The memory event management module generates a corresponding memory event in response to the event request, and sends the memory event to the data storage module.
[0067] Specifically, the memory event management module is called. After receiving the event request, the memory event management module generates the corresponding memory event according to the information in the time request according to the preset event generation algorithm, assigns a unique identifier to the event and adds metadata such as timestamp, and then serializes the generated memory event and sends it to the data storage module for persistent storage.
[0068] In this embodiment, a standardized event generation mechanism is used to ensure the uniqueness and traceability of events, and an asynchronous sending method is used to improve the system's concurrent processing capabilities. This decoupling of event generation logic and data storage is achieved, facilitating system maintenance and expansion. At the same time, persistent storage of events ensures data integrity, providing a reliable basis for subsequent event tracking, analysis, and system troubleshooting.
[0069] S420: Receive memory events through a data storage module and store the memory events.
[0070] Specifically, the data storage module is called, and the data storage module receives the memory events sent by the memory event management module through the interface, and then performs information parsing, format verification and integrity checking on the memory events. After ensuring data compliance, the information in the memory event is written into the corresponding storage medium according to the event type and predefined storage rules, and the storage status and index information are recorded for subsequent retrieval. The information in the memory event includes but is not limited to the memory event type, event time information and event content. The storage medium can be a database, file system or distributed storage.
[0071] In this embodiment, a standardized data reception and verification mechanism is used to ensure the accuracy and integrity of memory event storage, support multiple storage media adaptation to improve system compatibility, an indexing mechanism optimizes event retrieval efficiency, and persistent storage ensures that event data is not lost, providing reliable data support for system fault recovery, historical event tracing, and data analysis. At the same time, modular design achieves decoupling from the event management module, enhancing system maintainability.
[0072] S430. The local cache refresh module set on each instance in the target cluster obtains memory event incremental data from the data storage module based on the scheduled task, generates a memory event processing task based on the memory event incremental data, executes the memory event processing task, and returns the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results to determine the target execution result.
[0073] Specifically, the local cache refresh module of each instance in the target cluster is called, and the local cache refresh module is triggered by a scheduled task. The incremental pull strategy is used to obtain the timestamped memory event incremental data from the data storage module. The memory event processing task is generated and executed based on the memory event incremental data, and the execution result is returned to the memory event management module. The memory event management module summarizes and compares the results and determines the target execution result. For example, each instance can encapsulate the execution result and return the structured data containing the version number, processing status code and data verification value to the memory event management module. The module performs consistency verification on the results through a majority voting mechanism or priority arbitration. When a result conflict occurs, it automatically triggers the abnormal task to be retried or marked as manual intervention, and finally determines the target execution result.
[0074] In this embodiment, automatic incremental updates of cached data of each instance in the cluster are achieved through scheduled tasks, reducing the full synchronization overhead; distributed processing improves task execution efficiency and supports horizontal expansion of the cluster; the summary and comparison mechanism of execution results ensures data consistency and can promptly detect and handle anomalies; the independent processing of each instance is combined with centralized result management, which not only improves the system's concurrency capability, but also facilitates unified management and control, and enhances the reliability and maintainability of the system.
[0075] In a specific embodiment, Figure 5 The flowchart of a local cache refresh method is shown. The user operates the application system to generate changes such as addition, deletion, and modification of business data; the memory event management module determines the type of business data that has changed, generates memory events of the corresponding type, and adds memory events to the data storage module, wherein the memory event types include refresh-type memory events, i.e., adding, deleting, and modifying the business data in the instance business memory; query-type memory events, i.e., querying the specified memory data status within the instance; and configuration modification-type memory events, i.e., modifying the technical parameters of the system. The generated memory events and the changed business data are stored in the data storage module; the local cache refresh module in each instance of the service cluster establishes a scheduled task for regularly refreshing the cache, and regularly incrementally pulls the newly added memory events from the data storage unit. After obtaining the memory events, it determines whether the start time of the memory events is earlier than the current time. If so, the memory events to be executed are added to the task queue to be executed, and the memory events to be executed are taken out from the task queue in turn. According to the different types of memory events, they are assigned to different cache refreshers to perform the memory cache refresh operation. At this point, the local cache refresh operation of all instances is completed.
[0076] The technical solution of this embodiment is to generate corresponding memory events in response to event requests through the memory event management module, and send the memory events to the data storage module; receive memory events through the data storage module and store the memory events; obtain memory event incremental data from the data storage module based on the scheduled tasks through the local cache refresh modules set on each instance in the target cluster, generate memory event processing tasks based on the memory event incremental data, execute the memory event processing tasks, and return the execution results corresponding to the memory event processing tasks to the memory event management module, so that the memory event management module summarizes and compares the received execution results and determines the target execution results. This solution is used to rely on the local cache refresh modules set on the instances in the cluster to execute the memory event processing tasks generated according to the memory incremental data, reduce the full data transmission overhead, and realize the cache refresh of multiple instances under the application system based on the memory event mechanism, greatly reduce the redundancy of system equipment, ensure local cache consistency, solve the problem of local cache inconsistency between different instances, and improve the accuracy and consistency of cache refresh.
[0077] Example 3
[0078] Figure 6 1 is a structural diagram of an electronic device provided in Example 3 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0079] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0080] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0081] The processor 11 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the local cache refresh method.
[0082] In some embodiments, the local cache refresh method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the local cache refresh method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the local cache refresh method in any other appropriate manner (e.g., by means of firmware).
[0083] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0084] Computer programs for implementing the local cache refresh method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0085] Example 4
[0086] Embodiment 4 of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a processor to execute a local cache refresh method, the method comprising:
[0087] Generate a corresponding memory event in response to the event request through the memory event management module, and send the memory event to the data storage module;
[0088] Receive memory events through the data storage module and store the memory events;
[0089] The local cache refresh module set on each instance in the target cluster obtains memory event incremental data from the data storage module based on the scheduled task, generates a memory event processing task based on the memory event incremental data, executes the memory event processing task, and returns the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results and determines the target execution result.
[0090] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0091] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0092] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0093] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0094] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0095] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A local cache refresh system, characterized in that: The system includes a memory event management module, a data storage module and a local cache refresh module corresponding to each instance in the target cluster; wherein, The memory event management module is configured to generate a corresponding memory event in response to an event request, and send the memory event to the data storage module; The data storage module receives the memory event and stores the memory event; Each of the local cache refresh modules is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate a memory event processing task based on the memory event incremental data, execute the memory event processing task, and return the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results to determine the target execution result.
2. The system according to claim 1, wherein: The memory event includes a cache refresh event; the memory event management module includes a memory event generation unit, the memory event generation unit is used to receive a cache refresh request, extract information from the cache refresh request, obtain characteristic information, and generate a cache refresh event based on the characteristic information, wherein the characteristic information at least includes a memory event type, an event start time, an event end time, first instance information and data to be refreshed, and the memory event type includes one or more of a business data refresh event type and a system configuration information refresh event type.
3. The system according to claim 1, wherein: The memory event includes a cache query event; the memory event management module also includes a cache query unit, which is used to receive a cache query request and generate a cache query event based on the cache query request, wherein the cache query event includes at least second instance information and data to be queried.
4. The system according to claim 1, wherein: The local cache refresh module includes a cache refresh unit and an execution result notification unit; The cache refresh unit is used to obtain memory event incremental data from the data storage module based on a scheduled task, generate memory event processing tasks corresponding to each memory event in the memory event incremental data based on the memory event incremental data, build a pending task queue based on the memory event processing tasks corresponding to each memory event in the memory event incremental data, start executing the pending task queue, allocate a corresponding refresher to each memory event processing task in the pending task queue according to the memory event type corresponding to each memory event processing task in the pending task queue, execute the corresponding memory event processing task through the refresher, obtain the task execution result corresponding to the pending task queue, and send the task execution result corresponding to the pending task queue to the execution result notification unit; The execution result notification unit receives the task execution result, generates subscription information based on the task execution result, and publishes the subscription information to the memory event management module, wherein the subscription information includes the task execution result.
5. The system according to claim 4, characterized in that The memory event processing task carries a cache refresh parameter, wherein the cache refresh parameter includes one or more of a memory event retry count threshold and a memory event execution result return parameter; The memory event management module further includes a cache refresh configuration unit, which is configured to receive a cache refresh configuration modification request and update the cache refresh parameters based on the cache refresh configuration modification request.
6. The system according to claim 5, characterized in that The cache refresh unit is further configured to obtain task execution failure data, add memory events in the task execution failure data to the pending task queue, re-execute the memory event processing task in the task execution failure data, and add one to the execution count corresponding to the re-executed memory event processing task to obtain the memory event retry count threshold. When the execution count corresponding to any memory event processing task is greater than the memory event retry count threshold, generate exception information based on the memory event processing task, and feed the exception information back to the information display terminal for display. And / or, obtaining the memory event execution result return parameter, and if the memory event execution result return parameter is a return identifier, performing return processing on the execution result.
7. The system according to claim 5, characterized in that The memory event management module receives the task execution results returned by each instance in the target cluster, performs consistency verification on the task execution results of the same memory event processing task in each instance in the target cluster, obtains the verification result, and determines the target processing result of each memory event processing task based on the verification result.
8. A local cache refresh method, characterized in that: include: Generate a corresponding memory event in response to the event request through the memory event management module, and send the memory event to the data storage module; Receiving the memory event through the data storage module and storing the memory event; The local cache refresh module set on each instance in the target cluster obtains memory event incremental data from the data storage module based on the scheduled task, generates a memory event processing task based on the memory event incremental data, executes the memory event processing task, and returns the execution result corresponding to the memory event processing task to the memory event management module, so that the memory event management module summarizes and compares the received execution results to determine the target execution result.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the local cache refresh method described in claim 8.
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 processor to implement the local cache refresh method described in claim 8 when executed.