Cache management method and device, electronic equipment and readable storage medium

By constructing a topological dependency graph and a topological sorting algorithm, the problem of inconsistent update order between cache and database in a distributed cache system is solved, and data consistency between cache and database and efficient operation of the system are achieved.

CN120596527APending Publication Date: 2025-09-05CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510673492.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

In high-concurrency scenarios, the update order between the distributed cache and the database is inconsistent, resulting in poor cache consistency.

Method used

By constructing a topological dependency graph, analyzing the dependencies between events, determining the execution order of events, and using a topological sorting algorithm to ensure the sequentiality and consistency of cache update operations.

Benefits of technology

In high-concurrency scenarios, ensure the consistency of cache and database data, avoid inconsistency issues between cache and database data, and improve system response speed and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120596527A_ABST
    Figure CN120596527A_ABST
Patent Text Reader

Abstract

The invention discloses a cache management method and device, electronic equipment and a readable storage medium, relates to the technical field of big data, and aims to solve the problem of poor cache consistency. The method comprises the steps that a topological dependency graph is constructed based on generated N events, nodes in the topological dependency graph are used for representing the events, and directed edges between nodes corresponding to a first event and nodes corresponding to a second event in the topological dependency graph are used for representing a dependency relationship between the first event and the second event, the first event and the second event are any two events in the N events; determining an execution sequence of the N events based on the topological dependency graph; and executing the N events according to the execution sequence. According to the embodiment of the invention, the cache consistency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data technology, and in particular to a cache management method, device, electronic device and readable storage medium. Background Art

[0002] With the rapid development of internet technology, the storage and access of massive amounts of data have become core challenges for various systems. In environments with high concurrency and large data volumes, relying solely on databases to provide data services often leads to performance bottlenecks. In this context, distributed caching, with its high read and write speed, scalability, and stress resistance, has become a key technology for improving system performance. Distributed caching reduces direct database access by storing frequently accessed data in memory, thereby improving system responsiveness and reducing database pressure.

[0003] However, in high-concurrency scenarios, when multiple threads concurrently access the same data, the update order between the cache and the database is easily inconsistent, causing the cache data to be out of sync with the database data, resulting in poor cache consistency. Summary of the Invention

[0004] Embodiments of the present invention provide a cache management method, device, electronic device, and readable storage medium to solve the problem of poor cache consistency.

[0005] In a first aspect, an embodiment of the present invention provides a cache management method, including:

[0006] Constructing a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent that the first event and the second event have a dependency relationship, wherein the first event and the second event are any two events among the N events, where N is a positive integer;

[0007] Determining an execution order of the N events based on the topological dependency graph;

[0008] Execute N of the events in the execution order.

[0009] Optionally, determining the execution order of the N events based on the topological dependency graph includes:

[0010] Constructing a dependency matrix based on the dependency relationship of the events, wherein the element in the i-th row and j-th column of the dependency matrix is ​​used to represent whether event i depends on event j, and both i and j are positive integers less than or equal to N;

[0011] A topological sorting algorithm is used to determine the execution order of the N events based on the dependency matrix.

[0012] Optionally, the dependency relationship includes:

[0013] A time dependency relationship, where the time dependency relationship is used to indicate that, when the second event needs to be executed before the first event, the first event depends on the second event;

[0014] A data dependency relationship is used to represent that, when data generated by the second event is used by the first event, the first event depends on the second event.

[0015] Optionally, the method further includes:

[0016] determining a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates;

[0017] The cache is updated based on the target time window.

[0018] Optionally, the system load level is negatively correlated with the length of the target time window;

[0019] And / or, the event arrival frequency is negatively correlated with the length of the target time window.

[0020] Optionally, the system load level is determined based on the number of requests, resource consumption of each of the requests, and total available resource capacity;

[0021] And / or, the event arrival frequency is used to represent the number of events processed by the system per unit time.

[0022] In a second aspect, an embodiment of the present invention further provides a cache management device, including:

[0023] a construction module, configured to construct a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent a dependency relationship between the first event and the second event, wherein the first event and the second event are any two events among the N events, where N is a positive integer;

[0024] A first determining module, configured to determine an execution order of the N events based on the topological dependency graph;

[0025] An execution module is used to execute N of the events according to the execution order.

[0026] Optionally, the cache management device further includes:

[0027] a second determining module, configured to determine a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates;

[0028] An updating module is configured to update the cache based on the target time window.

[0029] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a memory, a processor, and a program stored in the memory and executable on the processor;

[0030] The processor is used to read the program in the memory to implement the steps in the cache management method as described in the first aspect.

[0031] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium for storing a program, which, when executed by a processor, implements the steps in the cache management method as described in the first aspect.

[0032] In an embodiment of the present invention, a topological dependency graph is first constructed based on the N generated events; then, the execution order of the N events is determined based on the topological dependency graph; and finally, the N events are executed according to the execution order. By analyzing the dependencies between events, this embodiment of the present invention ensures that data operations on the cache and database are strictly sequential in high-concurrency scenarios, avoiding inconsistencies between cache and database data caused by concurrent write operations, thereby improving cache and database consistency. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in describing the embodiments of the present invention. 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 paying any creative labor.

[0034] Figure 1 is a flow chart of a cache management method provided by an embodiment of the present invention;

[0035] Figure 2 is an example diagram of a topology dependency graph provided by an embodiment of the present invention;

[0036] Figure 3 is a structural diagram of a cache management device provided by an embodiment of the present invention;

[0037] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0039] The embodiment of the present application provides a cache management method, which aims to ensure the order and consistency of cache update operations by analyzing the dependencies between events. Figure 1 As shown, the method specifically includes the following steps:

[0040] Step 101: construct a topological dependency graph based on the N events generated, where the nodes in the topological dependency graph are used to represent the events, and the directed edges between the nodes corresponding to the first event and the nodes corresponding to the second event in the topological dependency graph are used to represent that there is a dependency relationship between the first event and the second event, where the first event and the second event are any two events among the N events, and N is a positive integer.

[0041] For example, the events generated by the system include cache read operations, cache write operations, cache update operations, database read operations, database write operations, etc. In a distributed system, there may be dependencies between various events, and the execution order of events will affect the final state of the system.

[0042] Optionally, in some embodiments, the dependency relationship includes the following two situations:

[0043] The first case involves a temporal dependency, where a first event depends on a second event, provided that the second event must execute before the first. This means that certain events must execute in a specific time order. For example, a write operation must execute before a read operation to ensure the latest data is read. Therefore, a database write operation must complete before a database read operation, and a cache write operation must complete before a cache read operation.

[0044] The second case involves data dependencies, which indicate that a first event depends on a second event if the data generated by the second event is used by the first event. Specifically, if event A generates data that will be used by event B, then event B depends on event A. For example, a cache update depends on a database write because the cache must maintain consistency with the database; otherwise, stale data may be read. Therefore, the database write must complete before the cache update.

[0045] In order to describe the dependency relationship between events, in step 101, by monitoring the generation of all events, a real-time topology dependency graph is constructed based on the N generated events, and the topology dependency graph is a directed graph.

[0046] For example, the topological dependency graph is denoted as G = (V, E). V is a set of nodes, which represent events generated by the system. Each event can be an operation such as a cache read (R), cache write (W), database read (DBR), or database write (DBW). E is a set of edges, with directed edges representing the dependencies between events.

[0047] In specific implementations, the representation of dependency relationships using directed edges can be customized based on actual circumstances and is not specifically limited. For example, as an optional implementation, if the execution of event a depends on event b, there is a directed edge in the topological dependency graph from node b to node a, where node b represents event b and node a represents event a. As another optional implementation, if the execution of event a depends on event b, there is a directed edge in the topological dependency graph from node a to node b.

[0048] It should be understood that not all events may have dependencies. Events without dependencies can be executed one after another or synchronously, and the order of execution may not be limited. The following is an example of a specific embodiment. Assume that in a multi-node distributed e-commerce system, the system needs to process multiple operations such as user product inquiries, inventory updates, order generation, payment processing, etc. These operations are events. The specific events are shown in Table 1:

[0049] Table 1 Event description

[0050]

[0051] In this scenario, there are complex dependencies between events. For example, user A's query operation R1 depends on user B's (the administrator's) inventory update operation DBW1, and cache update operation W1 depends on database write operation DBW1. There is also a dependency between user C's order creation operation DBW2 and cache update operation W2.

[0052] In this embodiment, based on the above events, the following can be constructed: Figure 2 The topological dependency graph shown, Figure 2The topological dependency graph shown can be described as a directed graph G = (V, E), where the vertex set V = {R1, R2, R3, DBW1, DBW2, DBW3, W1, W2}, and the vertex set is used to represent all events; the edge set E = {(DBW1→W1), (W1→R1), (DBW2→W2), (W1→R2), (DBW1→DBW3), (DBW3→W1)}, and the edge set is used to represent the dependency relationship between events.

[0053] It should be understood that in Figure 2 In the example, DBW2→W2→R3 is separated out because it handles an independent event chain related to orders and has no direct dependency on inventory updates. By isolating order-related operations, the system can process both order and inventory operations in parallel, reducing mutual blocking between operations and improving the system's concurrent processing capabilities and overall performance. This design ensures the independence of different operation chains, maximizing system efficiency.

[0054] Step 102: Determine the execution order of the N events based on the topology dependency graph.

[0055] After obtaining the topological dependency graph, the execution order of the N times can be determined based on the topological dependency graph. In topological dependency analysis, the execution order of events in the system can be described by a dependency matrix. Optionally, in some embodiments, step 102 includes:

[0056] Constructing a dependency matrix based on the dependency relationship of the events, wherein the element in the i-th row and j-th column of the dependency matrix is ​​used to represent whether event i depends on event j, and both i and j are positive integers less than or equal to N;

[0057] A topological sorting algorithm is used to determine the execution order of the N events based on the dependency matrix.

[0058] The goal of topological sorting is to find a linear order such that for each edge (a→b), event a must be executed before event b. Specifically, for N events, a dependency matrix M of size N×N is constructed, where the element M in the i-th row and j-th column of the dependency matrix M is ij It is used to characterize whether event i depends on event j, as shown below:

[0059]

[0060] By operating the dependency matrix M, the dependency representation data of all events can be obtained, and the dependency representation data can be used as the input of the topological sorting algorithm.

[0061] Based on the dependency representation data, the execution order of N events can be determined by a topological sorting algorithm. The specific content of the topological sorting algorithm is not limited here. For example, in some embodiments, the topological sorting algorithm is a Kahn algorithm. In other embodiments, the topological sorting algorithm is a depth-first search algorithm.

[0062] Step 103: Execute N of the events in the execution order.

[0063] After determining the execution order of the N events, each event can be executed sequentially according to the execution order. For example, in some embodiments, events with dependencies are strictly executed in this order to ensure consistency between cache updates and database operations, thereby avoiding cache inconsistencies. Events without direct dependencies can be processed in parallel, improving the system's concurrent processing capabilities and overall performance.

[0064] In specific implementations, event dependencies are dynamic. As the system runs, new events are constantly generated, and the dependencies change accordingly. In some embodiments, a dynamic topology dependency graph is maintained during system operation, and the dependencies in the topology dependency graph are updated in real time.

[0065] Optionally, in some embodiments, the system automatically detects new events and updates the topology dependency graph, ensuring that the topology dependency graph is up to date before each event is executed. To maintain dynamic dependencies, the system performs dependency analysis on each newly generated event, inserts it into the corresponding position in the topology dependency graph based on its data dependencies and / or time dependencies, and re-sorts the topology to obtain the latest execution order.

[0066] In the embodiments of the present application, by constructing a topological dependency graph between events, the system can identify and manage the execution order of different events, ensuring the coordination and consistency between cache updates and database operations, thereby avoiding the occurrence of cache inconsistencies. The embodiments of the present application are not only applicable to single-node systems, but can also be effectively applied in multi-node distributed systems. By effectively managing data updates and synchronization across nodes, system consistency under complex dependencies can be ensured.

[0067] Optionally, in some embodiments, the method further comprises:

[0068] determining a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates;

[0069] The cache is updated based on the target time window.

[0070] It should be understood that in a distributed cache system, cached data typically needs to be updated regularly to ensure data consistency between the cache and the database. The length of the target time window determines the frequency of cache updates. If the cache update frequency is too low, the data in the cache may be out of sync with the database for a long time, resulting in inconsistencies between the cache and database. If the update frequency is too high, the system will frequently refresh the cache, consuming a large amount of resources and affecting system performance.

[0071] In this embodiment, the target time window length is determined based on the system load level and / or event arrival frequency, and the cache update time window is dynamically adjusted. Specifically, in this embodiment, the target time window length is dynamically shortened or extended based on the system load level and / or event arrival frequency, ensuring that the cache update timing can adapt to the system state.

[0072] In this embodiment, the length of the target time window is dynamically adjusted based on the system load level and / or event arrival frequency. For example, when the system load level is high (e.g., when resources such as CPU and memory are nearing bottlenecks), the system prioritizes consistency and responsiveness, thereby shortening the target time window. This speeds up the synchronization frequency between the cache and the database, reduces the window period for data inconsistency, and prevents data dirty reads caused by latency.

[0073] When events arrive frequently but the system load is acceptable (for example, in flash sales), the processing pressure on a single event is low, but the request volume is extremely high. To reduce frequent cache refreshes and lock contention, the system will appropriately extend the target time window and consolidate batches of events for unified processing. This effectively improves overall throughput through batch processing, reducing system jitter and resource consumption.

[0074] The system load level can be obtained by monitoring the load state of the system, and the system load level is used to determine whether the system is in a high load state or a low load state. Optionally, in some embodiments, the system load level is determined based on the number of requests, the resource consumption of each request, and the total available resource capacity. It should be understood that in some embodiments, the request is a request to execute an event.

[0075] Specifically, let the system load level be L, then L satisfies:

[0076]

[0077] Where n is the total number of requests in the current time window, R i is the resource consumption of the i-th request, and C is the total available resource capacity of the system.

[0078] In some embodiments, in addition to monitoring system load, the system also monitors event arrival frequency, i.e., the number of events processed per unit time. Events may include cache update requests, database read / write requests, and the like, which are not described in detail here. Optionally, in some embodiments, the event arrival frequency is used to represent the number of events processed by the system per unit time.

[0079] Specifically, let the event arrival frequency be f event , then f event satisfy:

[0080]

[0081] Among them, N event For the time interval T interval The total number of events processed by the system.

[0082] As a specific embodiment, after determining that the system load level is L and the event arrival frequency f event After that, the system will calculate the event arrival frequency f according to the system load level L and event arrival frequency f. event Dynamically adjust the length of the target time window T window .

[0083] Optionally, in some embodiments, the system load level is negatively correlated with the length of the target time window. Optionally, in some embodiments, the event arrival frequency is negatively correlated with the length of the target time window.

[0084] Specifically, when L is high and f event When L is also high, the system will shorten the length of the target time window, thereby accelerating cache updates and reducing the risk of data inconsistency in concurrent situations; conversely, when L is low and f event When the value is also low, the system will appropriately extend the time window to merge more events for processing, thereby improving the resource utilization of the system.

[0085] For example, in some embodiments, T window It can be calculated by the following formula:

[0086]

[0087] Where k is a preset constant used to adjust the benchmark length of the target time window, and α is a control parameter used to control the degree of influence of the arrival frequency of conditional events on the target time window.

[0088] In some embodiments, the length of the target time window may be dynamically adjusted based on other indicators such as a cache hit rate, which are not specifically limited here.

[0089] For ease of understanding, the following is an example of a specific implementation. Assume that for a large e-commerce platform, users can view the inventory of goods and place orders to purchase. Each time a user places an order, the system needs to update the inventory in the database and ensure that the data in the cache is consistent with the database. Assume that the system has a large number of concurrent requests during a flash sale, and all users are bidding for the same product at the same time. Assume that the initial inventory of this product is 1,000 pieces, and the number of user requests during the flash sale is very large, and the system has to handle a large number of concurrent read and write operations. During the flash sale, the system receives the following events:

[0090] E1: User A purchased 5 items (inventory decreased by 5);

[0091] E2: User B purchased 3 items (inventory decreased by 3);

[0092] E3: User C queries product inventory;

[0093] E4: The system automatically updates the cache.

[0094] In this embodiment, a corresponding topological dependency graph can be constructed based on the dependencies of the four events described above. Specifically, E3 (user C's database read operation) depends on E1 and E2 (database write operations). This means that the database write operation for inventory update must be completed before the latest inventory can be read. E4 (cache update operation) depends on E1 and E2. This means that the cache update operation must be performed after the database update. Therefore, the system processes E1 and E2 first, and then E3 and E4, avoiding database read operations or cache updates before the database write operation is completed.

[0095] In this example, the system detects a high frequency of events during a flash sale. Therefore, the dynamic control window extends the processing window (i.e., the target time window). This increases the likelihood that E1 and E2 can be processed within the same processing window. In this case, E1 and E2 can be processed together rather than separately, effectively reducing system overhead. Once the inventory updates for E1 and E2 are complete, the system processes E3 (inventory query) and E4 (cache update), ensuring that User C receives the latest inventory and that the cached data remains synchronized with the database.

[0096] In this embodiment, by monitoring system load levels and / or event arrival frequency in real time, the time windows for cache updates and data synchronization are dynamically adjusted, thereby improving system efficiency and ensuring data consistency in high-concurrency and dynamic load scenarios. Compared to traditional fixed time window mechanisms, the dynamic time window control in this embodiment can adaptively adjust the cache update frequency based on the actual system runtime conditions, thereby better balancing system performance and data consistency, and avoiding the cache lag or frequent expiration issues caused by fixed expiration times.

[0097] As a specific example, by combining a topology dependency graph with a mechanism for dynamically adjusting target time windows, this approach not only considers data consistency during cache updates but also dynamically monitors information such as request frequency and system load, allowing for real-time adjustments to cache null values ​​and blacklist settings to prevent malicious requests from impacting the database. By integrating cache consistency maintenance with cache penetration protection, this embodiment can more effectively filter invalid requests, reduce system load, and enhance overall system security and stability.

[0098] The embodiment of the present application further provides a cache management system for implementing the above cache management method. Exemplarily, the cache management system includes a dependency analysis module, a dynamic control window module, an event management module, and a cache management module.

[0099] Topology Dependency Analysis Module: This module is used to analyze the dependencies of various events in the system (including read and write requests, cache updates, database operations, and so on) and construct a topology dependency graph. Different events may have data or time-order dependencies. Using the topology dependency graph, the system can clearly identify which events need to be executed sequentially and which can be processed in parallel. This allows the system to effectively identify dependencies between events, ensuring the sequential and consistent nature of data updates in high-concurrency scenarios.

[0100] Dynamic Control Window Module: This module is used to dynamically adjust the event processing time window by monitoring the system's load status, event frequency, cache hit rate, and other indicators in real time. This setting reduces frequent cache updates and database accesses by extending the processing window and merging multiple concurrent events in high-load scenarios. Conversely, shortening the processing window improves the real-time nature of event processing and ensures timely synchronization of cached data when the system load is low. This setting allows the system to adaptively adjust cache update strategies based on real-time conditions, avoiding cache lag or frequent expiration issues caused by fixed expiration times.

[0101] Event Management Module: The event management module manages various events within the system, including read and write operations, cache updates, and database queries. Working in conjunction with the topology dependency analysis module and the dynamic window control module, the event management module ensures that all events are executed in the correct order and dynamically adjusts event processing strategies based on system load. The event management module identifies concurrency conflicts and avoids data inconsistencies caused by concurrent writes or reads. Through the event management module, the system efficiently schedules various events, prioritizing critical events and ensuring system stability and consistency in high-concurrency scenarios.

[0102] Cache management module: The cache management module is responsible for specific cache operations. The cache management module is closely integrated with the event management module. It identifies the validity of cached data through the topology dependency analysis module, and determines the cache update timing based on the strategy of the dynamic control window module. The cache management module can perform cache reading, updating, and invalidation operations based on the real-time status of the system to ensure that the data in the cache is always synchronized with the database. In some embodiments, in order to deal with the problem of cache penetration, the cache management module also provides a data null value setting, and combines the blacklist mechanism to filter frequent invalid requests, effectively reducing the pressure on the database.

[0103] See Figure 3 , an embodiment of the present invention further provides a cache management device 300. Figure 3 This is one of the structural diagrams of the cache management device 300 provided in the embodiment of the present invention. Figure 1 The cache management method shown is similar, so the implementation of the cache management device 300 can refer to the implementation of the cache management method, and the repeated parts are not repeated.

[0104] like Figure 3 As shown, the cache management device 300 includes:

[0105] A construction module 301 is configured to construct a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent a dependency relationship between the first event and the second event, where the first event and the second event are any two events from the N events, where N is a positive integer.

[0106] A first determining module 302 is configured to determine an execution order of the N events based on the topological dependency graph;

[0107] The execution module 303 is configured to execute the N events according to the execution order.

[0108] Optionally, the cache management device 300 further includes:

[0109] a second determining module, configured to determine a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates;

[0110] An updating module is configured to update the cache based on the target time window.

[0111] Optionally, the first determining module 302 includes:

[0112] A construction unit, configured to construct a dependency matrix based on the dependency relationships of the events, wherein the element in the i-th row and j-th column of the dependency matrix is ​​used to represent whether event i depends on event j, and both i and j are positive integers less than or equal to N;

[0113] A determining unit is configured to determine an execution order of the N events based on the dependency matrix by using a topological sorting algorithm.

[0114] Optionally, the dependency relationship includes:

[0115] A time dependency relationship is used to represent that, when the second event needs to be executed before the first event, the first event depends on the second event.

[0116] a data dependency relationship, where the data dependency relationship is used to indicate that, when data generated by the second event is used by the first event, the first event is dependent on the second event;

[0117] Optionally, the system load level is negatively correlated with the length of the target time window;

[0118] And / or, the event arrival frequency is negatively correlated with the length of the target time window.

[0119] Optionally, the system load level is determined based on the number of requests, resource consumption of each of the requests, and total available resource capacity;

[0120] And / or, the event arrival frequency is used to represent the number of events processed by the system per unit time.

[0121] The cache management device 300 provided in the embodiment of the present invention can execute the cache management method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.

[0122] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection of some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0123] In addition, the functional units in various embodiments of the present invention may be integrated into a single processing unit, each unit may be physically included separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional units.

[0124] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute some steps of the cache management method described in various embodiments of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program code.

[0125] like Figure 4 As shown, an embodiment of the present invention further provides an electronic device 400, including: a processor 401, configured to read a program in a memory 402, and execute the following steps:

[0126] Constructing a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent that the first event and the second event have a dependency relationship, wherein the first event and the second event are any two events among the N events, where N is a positive integer;

[0127] Determining an execution order of the N events based on the topological dependency graph;

[0128] Execute N of the events in the execution order.

[0129] Optionally, the processor 401 is further configured to read a program in the memory 402 and execute the following steps:

[0130] Constructing a dependency matrix based on the dependency relationship of the events, wherein the element in the i-th row and j-th column of the dependency matrix is ​​used to represent whether event i depends on event j, and both i and j are positive integers less than or equal to N;

[0131] A topological sorting algorithm is used to determine the execution order of the N events based on the dependency matrix.

[0132] Optionally, the dependency relationship includes:

[0133] A time dependency relationship, where the time dependency relationship is used to indicate that, when the second event needs to be executed before the first event, the first event depends on the second event;

[0134] A data dependency relationship is used to represent that, when data generated by the second event is used by the first event, the first event depends on the second event.

[0135] Optionally, the processor 401 is further configured to read a program in the memory 402 and execute the following steps:

[0136] determining a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates;

[0137] The cache is updated based on the target time window.

[0138] Optionally, the system load level is negatively correlated with the length of the target time window;

[0139] And / or, the event arrival frequency is negatively correlated with the length of the target time window.

[0140] Optionally, the system load level is determined based on the number of requests, resource consumption of each of the requests, and total available resource capacity;

[0141] And / or, the event arrival frequency is used to represent the number of events processed by the system per unit time.

[0142] The electronic device 400 provided in the embodiment of the present invention can execute the above-mentioned cache management method embodiment, and its implementation principle and technical effects are similar, which will not be described in detail in this embodiment.

[0143] An embodiment of the present application also provides a readable storage medium, on which a program is stored. When the program is executed by a processor, the various processes of the above-mentioned cache management method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0144] Among them, the readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disk, hard disk, magnetic tape, magneto-optical disk (MO), etc.), optical storage (such as compact disk (CD), digital video disc (DVD), Blu-ray Disc (BD), high-definition versatile disc (HVD), etc.), and semiconductor memory (such as read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read only memory (EEPROM), non-volatile memory (NAND FLASH), solid state drive (SSD)), etc.

[0145] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0146] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD-ROM), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0147] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A cache management method, characterized in that: include: Constructing a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent that the first event and the second event have a dependency relationship, wherein the first event and the second event are any two events among the N events, where N is a positive integer; Determining an execution order of the N events based on the topological dependency graph; Execute N of the events in the execution order.

2. The method according to claim 1, characterized in that Determining the execution order of the N events based on the topological dependency graph includes: Constructing a dependency matrix based on the dependency relationship of the events, wherein the element in the i-th row and j-th column of the dependency matrix is ​​used to represent whether event i depends on event j, and both i and j are positive integers less than or equal to N; A topological sorting algorithm is used to determine the execution order of the N events based on the dependency matrix.

3. The method according to claim 1, characterized in that The dependencies include: A time dependency relationship, where the time dependency relationship is used to indicate that, when the second event needs to be executed before the first event, the first event depends on the second event; A data dependency relationship is used to represent that, when data generated by the second event is used by the first event, the first event depends on the second event.

4. The method according to claim 1, wherein The method further comprises: determining a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates; The cache is updated based on the target time window.

5. The method according to claim 4, characterized in that The system load level is negatively correlated with the length of the target time window; And / or, the event arrival frequency is negatively correlated with the length of the target time window.

6. The method according to claim 4 or 5, characterized in that The system load level is determined based on the number of requests, the resource consumption of each of the requests, and the total available resource capacity; And / or, the event arrival frequency is used to represent the number of events processed by the system per unit time.

7. A cache management device, characterized in that: include: a construction module, configured to construct a topological dependency graph based on the N generated events, wherein nodes in the topological dependency graph are used to represent the events, and a directed edge between a node corresponding to a first event and a node corresponding to a second event in the topological dependency graph is used to represent a dependency relationship between the first event and the second event, wherein the first event and the second event are any two events among the N events, where N is a positive integer; A first determining module, configured to determine an execution order of the N events based on the topological dependency graph; An execution module is used to execute N of the events according to the execution order.

8. The cache management device according to claim 7, wherein: The cache management device also includes: a second determining module, configured to determine a length of a target time window based on a system load level and / or an event arrival frequency, wherein the length of the target time window is used to characterize a frequency of cache updates; An updating module is configured to update the cache based on the target time window.

9. An electronic device comprising: A memory, a processor, and a program stored in the memory and executable on the processor; characterized in that: The processor is configured to read a program in a memory to implement the steps of the cache management method according to any one of claims 1 to 6.

10. A readable storage medium for storing a program, characterized in that: When the program is executed by a processor, the steps of the cache management method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Event-driven scheduling using directed acyclic graphs

    CN110402431A

  • Reordering workloads to improve cross-thread concurrency in processor-based devices

    CN119631056A

  • Internet of Things edge gateway adaptive data caching and synchronizing method, system and device and storage medium

    CN119652904A

  • Task management method, system, device and medium based on graph structure

    CN119781961A