Graph database adjacency list cache management method and system based on dynamic weight
By using a dynamic weight management method, the problem of supernode adjacency lists being squeezed out by ordinary nodes in graph databases is solved, improving cache hit rate and query performance, and achieving efficient utilization of cache space.
Patent Information
- Application Number
- CN202511622024.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-11-07
AI Technical Summary
In graph databases, the adjacency list of supernodes has a low cache hit rate due to slow access frequency or large space occupation, and general caching algorithms such as LRU or LFU cannot effectively solve the performance problem of supernodes.
A dynamic weight-based cache management method is adopted. The super node adjacency list is protected by inherent weights, and the overall weight of cache items is dynamically adjusted by combining the popularity value and the smooth increment strategy to ensure efficient use of cache space.
It improves cache hit rate, protects the adjacency table of super nodes with high access costs from being squeezed out by ordinary nodes, and at the same time takes into account the access needs of popular ordinary nodes, thus improving overall query performance.
Smart Images

Figure CN121071190A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of graph database management, in particular to a graph database adjacency list cache management method and system based on dynamic weights. BACKGROUND
[0002] In a graph database, to ensure write performance, the physical storage of edges is usually scattered, which leads to the non-continuous storage of the adjacency list of a single node on the disk. Querying the neighbors of a node is a high-frequency operation, especially in a multi-hop query scenario. The association relationship of a graph often conforms to a power-law distribution, and there are a small number of super nodes with a large number of connection edges. These super nodes have a high access probability, but their huge adjacency list makes the disk reading operation very time-consuming and becomes a performance bottleneck.
[0003] Caching the adjacency list in memory is a common acceleration method. However, general cache algorithms such as LRU or LFU perform poorly in this scenario. Multi-hop queries will scan a large number of ordinary nodes, and their adjacency lists will quickly fill the cache space. Although the adjacency list of a super node is important and huge, it is easily replaced out of the cache due to the relatively slow accumulation of access frequency or large space occupation, resulting in a low cache hit rate and failing to effectively solve the performance problem of super node access. SUMMARY
[0004] Embodiments of the present application provide a graph database adjacency list cache management method and system based on dynamic weights, an electronic device and a storage medium to at least solve the problem in related technologies that the adjacency list of a super node in a graph database is crowded out by ordinary nodes, resulting in a low cache hit rate.
[0005] In a first aspect, embodiments of the present application provide a graph database adjacency list cache management method based on dynamic weights, which includes: receiving a request for querying the adjacency list of a node, and finding the cache item corresponding to the adjacency list; in a case where the request does not hit any cache item, generating a new cache item according to the adjacency list of the node, determining the inherent weight of the cache item based on the inherent attribute of the node, setting the hotness value of the cache item as an initial hotness value, and obtaining the comprehensive weight of the cache item based on the inherent weight and the hotness value; in a case where the request hits a cache item, obtaining the historical hotness value of the cache item, determining a new hotness value based on a smooth increment strategy and the historical hotness value, and performing weighted summation on the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item; in a case where the cache space is insufficient, deleting the cache item with the smallest comprehensive weight.
[0006] In some embodiments, determining the new hotness value based on the smooth increment strategy and the historical hotness value comprises: determining a hotness decay value according to the decay factor and the historical hotness value; obtaining a current access additional value based on the decay factor; obtaining the new hotness value according to the hotness decay value and the current access additional value based on an exponential smoothing model.
[0007] In some embodiments, the exponential smoothing model comprises: H_new = H_old * α + (1 - α) wherein H_new is the new hotness value, H_old is the historical hotness value, α is the decay factor, H_old * α is the hotness decay value, and (1 - α) is the current access additional value.
[0008] In some embodiments, the method further comprises: periodically globally decaying the hotness values of all cache items based on a global decay factor; updating the comprehensive weight of the corresponding cache item according to the decayed hotness value.
[0009] In some embodiments, the inherent attribute comprises the degree of the node, and the calculation formula of the inherent weight comprises: I = C * log(1 + degree) wherein I is the inherent weight, C is a constant, and degree is the degree of the node.
[0010] In some embodiments, the weighted sum of the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item comprises: obtaining the hit rate of the cache item and the trend of the hit rate; determining a balance factor based on the trend of the hit rate; weighting and summing the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item according to the balance factor.
[0011] In some embodiments, after generating the new cache item according to the adjacency list of the node, the method further comprises: determining the storage location of the new cache item inside the cache according to the inherent weight; based on the storage location, searching the new cache item and its metadata into the cache, wherein the metadata comprises the inherent weight, the hotness value, and the comprehensive weight.
[0012] Secondly, embodiments of this application provide a graph database adjacency list cache management system based on dynamic weights, the system comprising: The lookup module is used to receive requests to query the adjacency table of nodes and to look up the cached entries corresponding to the adjacency table; The first weight determination module is used to generate a new cache item based on the adjacency list of the node when the request does not hit any cache item, determine the inherent weight of the cache item based on the inherent attributes of the node, set the popularity value of the cache item as the initial popularity value, and obtain the comprehensive weight of the cache item based on the inherent weight and the popularity value. The second weight determination module is used to obtain the historical popularity value of the cache item when the request hits a certain cache item, determine a new popularity value based on the smooth increment strategy and the historical popularity value, and perform a weighted summation of the new popularity value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item. The cache replacement module is used to delete the cache item with the lowest overall weight when there is insufficient cache space.
[0013] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the dynamic weight-based graph database adjacency list cache management method as described in the first aspect above.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the dynamic weight-based graph database adjacency list cache management method described in the first aspect above.
[0015] Compared to related technologies, the graph database adjacency list cache management method based on dynamic weights provided in this application protects the adjacency list of super nodes with high access costs through inherent weights, preventing the adjacency list of super nodes from being squeezed out by ordinary nodes. At the same time, it takes into account popular ordinary nodes through popularity values, so that the cache space is used efficiently, always retaining the "most valuable" data and improving the overall cache hit rate. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart of a graph database adjacency list cache management method based on dynamic weights according to an embodiment of this application; Figure 2This is a structural block diagram of a graph database adjacency list cache management system based on dynamic weights according to an embodiment of this application; Figure 3 This is a schematic diagram of the internal structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0018] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.
[0019] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0020] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.
[0021] A graph database is a database that uses a graph structure for semantic queries. It uses nodes, edges, and attributes to represent and store data.
[0022] A node is the basic unit in a graph data model, used to represent an entity.
[0023] An edge is a directed or undirected line connecting two nodes, used to represent the relationship between the nodes.
[0024] An adjacency list is a data structure used to represent graphs, which stores a list of all neighboring nodes that are directly connected to each node.
[0025] Degree refers to the number of edges connected to a node.
[0026] Supernodes are nodes in a graph database whose degree is much higher than the average level.
[0027] Multi-hop query is a type of graph query that requires traversing multiple nodes connected by multiple edges.
[0028] This embodiment provides a graph database adjacency table cache management method based on dynamic weights. Figure 1 This is a flowchart of a graph database adjacency list cache management method based on dynamic weights according to an embodiment of this application, as follows: Figure 1 As shown, the process includes the following steps: Step S101: Receive a request to query the adjacency table of a node and search for the corresponding cached item in the adjacency table.
[0029] In this embodiment, the cache uses key-value storage, where the key represents the unique identifier of the node and the value represents the adjacency list of the node.
[0030] Each cached item corresponds to a metadata entry, which includes: popularity value, inherent weight, and comprehensive weight.
[0031] The popularity score (H) is a numerical value used to reflect the recent popularity of visits.
[0032] The intrinsic weight (I) is a static weight value calculated based on the node's intrinsic attributes (such as the node's degree).
[0033] The overall weight (W) is the final weight value composed of the popularity value (H) and the inherent weight (I), i.e., W = f(H,I).
[0034] Receive a request to query the adjacency table of a node, search for the cached entry in the adjacency table. If no corresponding cached entry is found, proceed to step S102; if a corresponding cached entry is found, proceed to step S103.
[0035] In step S102, if the request does not hit any cached item, a new cached item is generated based on the node's adjacency list, the inherent weight of the cached item is determined based on the node's inherent attributes, and the popularity value of the cached item is set as the initial popularity value. The comprehensive weight of the cached item is obtained based on the inherent weight and the popularity value.
[0036] If the request fails, the node's adjacency list is loaded from disk and inserted into the cache, while its metadata is initialized.
[0037] Calculate the inherent weight (I): Determine the inherent weight of the cache item based on the inherent attributes of the node.
[0038] Optionally, the node's inherent weight can be calculated based on its degree. The calculation formula is as follows: I = C * log(1 + degree) Where I is the inherent weight, degree is the degree of the node, and C is a configurable constant.
[0039] The higher the degree of a node, the greater its inherent weight, ensuring that supernodes possess high inherent weight from the outset. This inherent weight reflects the potential access value and high disk loading cost of a supernode.
[0040] Initialize heat value (H): The initial value can be set to 0 or a base value.
[0041] Calculate the initial comprehensive weight (W): When the initial popularity value is 0, the initial W = I.
[0042] This method sets the initial overall weight of cached items, so that super nodes have a high weight even if they have not been accessed, thus protecting them in cache contention.
[0043] In some embodiments, after generating a new cache entry based on the node's adjacency list in step S102, the method further includes: Step S1021: Determine the storage location of the new cache item within the cache based on its inherent weight.
[0044] Step S1022: Based on the storage location, retrieve the new cache item and its metadata into the cache, where the metadata includes inherent weight, popularity value and comprehensive weight.
[0045] Items with high inherent weights can be placed in cache areas with lower access latency, thereby improving the access efficiency of frequently accessed supernodes.
[0046] Step S103: If a request hits a cache item, obtain the historical popularity value of the cache item, determine a new popularity value based on the smooth increment strategy and the historical popularity value, and perform a weighted summation of the new popularity value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item.
[0047] In some embodiments, step S103, which determines the new heat value based on a smooth incremental strategy and historical heat values, includes: Step S1031: Determine the heat decay value based on the decay factor and historical heat values.
[0048] Step S1032: Based on the attenuation factor, obtain the additional value for this visit.
[0049] Step S1033: Based on the exponential smoothing model, a new popularity value is obtained according to the popularity decay value and the additional value of this visit.
[0050] In some embodiments, the exponential smoothing model includes: H_new = H_old *α + (1 -α) Where H_new is the new popularity value, H_old is the historical popularity value, α is the decay factor, H_old * α is the popularity decay value, and (1 - α) is the additional value for this visit.
[0051] It should be noted that the attenuation factor α is set according to the actual scenario; for example, α can be set to 0.9 based on historical data.
[0052] This embodiment uses a smooth increment strategy to update the popularity value instead of simply adding 1, so that cached items that are frequently accessed recently can quickly increase their popularity, but the accumulation of popularity has an upper limit, avoiding the long-term dominance of historical access records.
[0053] The overall weight W is recalculated using the new heat value H_new and the inherent weight I. Optionally, the formula for calculating the overall weight W is as follows: W = β * I + (1 - β) * H_new Here, β is the balancing factor. The balancing factor β can be a fixed value selected based on the actual situation, or it can be a dynamic value that changes with the hit rate.
[0054] This embodiment uses a comprehensive weighting to ensure that the inherent value of a node and its recent popularity jointly determine its importance.
[0055] In some embodiments, step S103 involves a weighted sum of the new popularity value and the inherent weight of the cached item to obtain the comprehensive weight of the cached item, including: Step S1034: Obtain the hit rate of cached items and the trend of the hit rate.
[0056] Step S1035: Determine the balance factor based on the trend of the hit rate.
[0057] Step S1036: Based on the balance factor, the new popularity value and the inherent weight of the cache item are weighted and summed to obtain the comprehensive weight of the cache item.
[0058] A fixed beta cannot adapt to all workloads. When access patterns change drastically, it may be necessary to dynamically adjust the weighting of intrinsic value and recent popularity.
[0059] This embodiment introduces a feedback control loop to monitor the changing trend of cache hit rate.
[0060] If the hit rate continues to decline, the system automatically increases β, making the weights more inclined to protect high-cost nodes (which may have been due to scanning access to super nodes).
[0061] If the hit rate is stable or increasing, β can be appropriately reduced to give higher weight to recent popularity (which may be during a period of frequent hot queries).
[0062] This embodiment transforms the algorithm from "static configuration" to "adaptive dynamic tuning," resulting in stronger robustness.
[0063] In some embodiments, the method further includes: Based on a global decay factor, the popularity value of all cached items is periodically decayed globally. The overall weight of the corresponding cache item is updated based on the decayed popularity value.
[0064] Periodically (e.g., every second), globally decay the heat value (H) of all cached items. For example: H = H * γ, where γ is the global decay factor, such as 0.95.
[0065] Global decay enables the algorithm to adaptively forget old access patterns and prioritize the retention of recently active items.
[0066] Step S104: If the cache space is insufficient, delete the cache item with the lowest overall weight.
[0067] When cache space is insufficient and a new item needs to be inserted, the cache item with the lowest current overall weight (W) is selected for eviction. Because super nodes inherently have a high weight (I), even if their popularity value (H) decays due to brief periods of inactivity, their overall weight W is unlikely to drop to the lowest level, effectively preventing them from being "squeezed out" of the cache by ordinary nodes. The overall weight takes into account both super nodes and popular ordinary nodes, so the eviction mechanism naturally tends to evict items that are neither super nodes nor recently popular.
[0068] Through the above steps, the inherent weights protect the adjacency lists of super nodes with high access costs, preventing them from being overwhelmed by ordinary nodes. By using a popularity value (H) and a periodic decay mechanism, the algorithm can sensitively capture and respond to changes in access patterns, protecting both super nodes and ordinary nodes that suddenly become popular. The comprehensive weight design ensures efficient use of cache space, always retaining the "most valuable" data and improving the overall cache hit rate. Furthermore, the algorithm in this application has low computational cost, requiring only the maintenance of a small number of values and simple arithmetic operations, resulting in extremely low overhead.
[0069] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0070] This embodiment also provides a graph database adjacency list cache management system based on dynamic weights. This system is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the terms "module," "unit," "subunit," etc., can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0071] Figure 2This is a structural block diagram of a graph database adjacency list cache management system based on dynamic weights according to an embodiment of this application, such as... Figure 2 As shown, the system includes: The lookup module 21 is used to receive requests to query the adjacency table of nodes and to look up the corresponding cached entries in the adjacency table.
[0072] The first weight determination module 22 is used to generate a new cache item based on the adjacency list of the node when the request does not hit any cache item, determine the inherent weight of the cache item based on the inherent attributes of the node, set the popularity value of the cache item to the initial popularity value, and obtain the comprehensive weight of the cache item based on the inherent weight and popularity value.
[0073] The second weight determination module 23 is used to obtain the historical popularity value of a cache item when a request hits a cache item, determine a new popularity value based on a smooth increment strategy and the historical popularity value, and perform a weighted summation of the new popularity value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item.
[0074] The cache replacement module 24 is used to delete the cache item with the lowest overall weight when there is insufficient cache space.
[0075] In some embodiments, the second weight determination module 23 includes: The heat decay module is used to determine the heat decay value based on the decay factor and historical heat values.
[0076] Access the additional module to obtain the additional value for this access based on the decay factor.
[0077] The popularity update module is used to obtain a new popularity value based on the popularity decay value and the additional value of this visit, using an exponential smoothing model.
[0078] In some embodiments, the exponential smoothing model includes: H_new = H_old *α + (1 -α) Where H_new is the new popularity value, H_old is the historical popularity value, α is the decay factor, H_old * α is the popularity decay value, and (1 - α) is the additional value for this visit.
[0079] In some embodiments, the system further includes: a global decay module, used to periodically decay the popularity value of all cached items based on a global decay factor; and to update the comprehensive weight of the corresponding cached items according to the decayed popularity value.
[0080] In some embodiments, the inherent properties include the degree of the node; the formula for calculating the inherent weight includes: I = C * log(1 + degree) Where I is the inherent weight, C is a constant, and degree is the degree of the node.
[0081] In some embodiments, the second weight determination module 23 includes: The hit rate change module is used to obtain the hit rate of cached items and the trend of hit rate changes.
[0082] The parameter determination module is used to determine the balance factor based on the trend of the hit rate.
[0083] The comprehensive weight calculation module is used to perform a weighted summation of the new popularity value and the inherent weight of the cached item based on the balance factor, so as to obtain the comprehensive weight of the cached item.
[0084] In some embodiments, the first weight determination module 22 includes: The location determination module is used to determine the storage location of new cache items within the cache based on their inherent weights.
[0085] The insertion module is used to retrieve new cache items and their metadata into the cache based on their storage location. The metadata includes inherent weight, popularity value, and comprehensive weight.
[0086] Through the aforementioned system, inherent weights protect the adjacency lists of supernodes with high access costs, preventing them from being overwhelmed by ordinary nodes. By using a popularity value (H) and a periodic decay mechanism, the algorithm can sensitively capture and respond to changes in access patterns, protecting both supernodes and ordinary nodes that suddenly become popular. The comprehensive weight design ensures efficient use of cache space, always retaining the "most valuable" data and improving the overall cache hit rate. Furthermore, the algorithm in this application has low computational cost, requiring only the maintenance of a small number of values and simple arithmetic operations, resulting in extremely low overhead.
[0087] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0088] This embodiment also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0089] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0090] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program: S1 receives a request to query the adjacency table of a node and searches for the corresponding cached item in the adjacency table.
[0091] S2, if the request does not hit any cached item, generate a new cached item based on the node's adjacency list, determine the inherent weight of the cached item based on the node's inherent attributes, set the cached item's popularity value to the initial popularity value, and obtain the cached item's comprehensive weight based on the inherent weight and popularity value.
[0092] S3: If a request hits a cache item, obtain the historical popularity value of the cache item, determine a new popularity value based on the smooth increment strategy and the historical popularity value, and perform a weighted sum of the new popularity value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item.
[0093] S4: If the cache space is insufficient, delete the cache item with the lowest overall weight.
[0094] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0095] In one embodiment, Figure 3 This is a schematic diagram of the internal structure of an electronic device according to an embodiment of this application, such as... Figure 3 As shown, an electronic device is provided, which can be a server, and its internal structure diagram can be as follows. Figure 3 As shown, this electronic device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a dynamic weight-based graph database adjacency list cache management method.
[0096] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0097] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0098] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0099] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A dynamic weight-based graph database adjacency list cache management method, characterized in that, The method comprises: receiving a request for querying a node adjacency list, and searching for a cache item corresponding to the adjacency list; in a case where the request does not hit any cache item, generating a new cache item according to the adjacency list of the node, determining an inherent weight of the cache item based on inherent attributes of the node, setting a hotness value of the cache item as an initial hotness value, and obtaining a comprehensive weight of the cache item based on the inherent weight and the hotness value; in a case where the request hits a cache item, obtaining a historical hotness value of the cache item, determining a new hotness value based on a smooth increment strategy and the historical hotness value, and performing weighted summation on the new hotness value and the inherent weight of the cache item to obtain a comprehensive weight of the cache item; in a case where cache space is insufficient, deleting a cache item with the smallest comprehensive weight.
2. The method of claim 1, wherein, The determination of the new hotness value based on the smooth increment strategy and the historical hotness value comprises: determining a hotness decay value according to a decay factor and the historical hotness value; obtaining a current access additional value based on the decay factor; obtaining the new hotness value based on an exponential smoothing model according to the hotness decay value and the current access additional value.
3. The method of claim 2, wherein, The exponential smoothing model comprises: H_new = H_old *α+ (1 -α) wherein H_new is the new hotness value, H_old is the historical hotness value, α is the decay factor, H_old *α is the hotness decay value, and (1 -α) is the current access additional value.
4. The method of claim 1, wherein, The method further comprises: periodically performing global decay on the hotness values of all cache items based on a global decay factor; and updating the comprehensive weight of the corresponding cache item according to the decayed hotness value.
5. The method of claim 1, wherein, The inherent attributes comprise the degree of the node, and the calculation formula of the inherent weight comprises: I = C * log(1 + degree) wherein I is the inherent weight, C is a constant, and degree is the degree of the node.
6. The method of claim 1, wherein, The weighted summation of the new hotness value and the inherent weight of the cache item to obtain the comprehensive weight of the cache item comprises: obtaining a hit rate of the cache item and a change trend of the hit rate; determining a balance factor based on the change trend of the hit rate; performing weighted summation on the new hotness value and the inherent weight of the cache item according to the balance factor to obtain the comprehensive weight of the cache item.
7. The method of claim 1, wherein, After the generation of the new cache item according to the adjacency list of the node, the method further comprises: determining a storage location of the new cache item inside the cache according to the inherent weight; and based on the storage location, searching the new cache item and metadata thereof into the cache, wherein the metadata comprises the inherent weight, the hotness value, and the comprehensive weight.
8. A dynamic weight based graph database adjacency list cache management system, comprising: The system comprises: a searching module configured to receive a request for querying a node adjacency list, and search for a cache item corresponding to the adjacency list. The first weight determination module is configured to generate a new cache entry according to an adjacency list of the node when the request does not hit any cache entry, determine an inherent weight of the cache entry based on inherent attributes of the node, set a hotness value of the cache entry as an initial hotness value, and obtain a comprehensive weight of the cache entry based on the inherent weight and the hotness value. The second weight determination module is configured to obtain a historical hotness value of the cache entry when the request hits a certain cache entry, determine a new hotness value based on a smooth increment strategy and the historical hotness value, and obtain a comprehensive weight of the cache entry by weighted summation of the new hotness value and the inherent weight of the cache entry. The cache replacement module is configured to delete a cache entry with the smallest comprehensive weight when the cache space is insufficient.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the dynamic weight-based graph database adjacency list cache management method in any one of claims 1 to 7.
10. A storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to implement the dynamic weight-based graph database adjacency list cache management method in any one of claims 1 to 7.
Citation Information
Patent Citations
Cache data processing method, device and system
CN109491619A
Real-time indexing method and system for efficient combined query of power big data
CN112765178A
Cache content management method and device, electronic equipment and storage medium
CN114461681A
Database active and passive cache optimization method based on data access mode
CN116775713A
Quick response edge caching method for graph data
CN118012911A
