A data caching method, system, storage medium and computer program product
By adopting a cleanup mechanism for overall clearing of head cache data in CAD drawing storage scenarios, the problem of cache pool expiration is solved, and the rational utilization of cache resources and the protection of computer performance is realized.
Patent Information
- Application Number
- CN202410658821.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-05-24
AI Technical Summary
In the storage scenario of CAD drawings, the direct application of the traditional tail-limited item update mechanism leads to unstable timeliness of cached data, which is prone to the problem of cache pool expiration.
A data cache method is proposed, and the first clearing mechanism is used to clear the head cache data or the entire cache pool in the cache pool, and the clearing mechanism is triggered by setting the query weight level and query frequency difference.
It effectively avoids the expired cache pool, rationally utilizes cache resources, reduces the consumption of computer performance by the cleaning mechanism, and improves data query efficiency.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer-aided design (CAD), and in particular to a data caching method, system, storage medium and computer program product. Background Art
[0002] With the development of information network technology, in order to improve the efficiency of data query calculation, cache control functions are often provided. For example, a cache control layer is added to the server to obtain data in advance and save it to the memory. If the data queried by the user is in the cache, the data is directly obtained from the cache and returned to the user, thereby improving data query efficiency.
[0003] Moreover, in the prior art, considering the limited storage space, factors such as the size of the request amount are usually used to update the cache data of the limited items at the end (in other words, the prior art adopts a mechanism for updating the limited items at the end). For example, CN111984889A discloses a caching method and system. It sorts the cache resources in the cache queue based on the characteristic value, releases a preset number of cache resources at the end of the cache queue after sorting, and then saves the target cache resources corresponding to the target URL into the cache queue. The cache resources with the lowest number of requests and the infrequent access can be released in time, thereby ensuring the effectiveness of the cache resources in the cache queue, avoiding the waste of cache resources, and alleviating the problem of time-consuming queries caused by indiscriminate caching in the prior art, thereby affecting the running speed of the software.
[0004] However, the applicant has found that if the traditional tail finite item update mechanism is directly applied to the storage scenario of CAD drawings, the timeliness of the cached data is very unstable, that is, the problem of cache pool expiration is very likely to occur. Summary of the invention
[0005] The object of the present invention is to provide a data caching method to partially solve or alleviate the above-mentioned deficiencies in the prior art, to avoid cache pool expiration, and to reduce the consumption of computer performance by the clearing mechanism while reasonably utilizing cache resources.
[0006] In order to solve the above-mentioned technical problems, the present invention specifically adopts the following technical solutions:
[0007] A first aspect of the present invention is to provide a data caching method, comprising the steps of:
[0008] S100 provides a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the magnitude of the first query frequency of the first query condition;
[0009] S101 obtains a second query condition and a third query condition input by a user within a first time, as well as a second query frequency and a third query frequency of the second query condition and the third query condition within the first time;
[0010] S102 uses a first clearing mechanism to determine whether the second query condition triggers a clearing mechanism. If so, S103 is executed to clear at least a portion of the data in the cache pool. The first clearing mechanism requires that the clearing mechanism be triggered when the second query condition meets the following two conditions:
[0011] (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is a first query condition whose query weight level is greater than a set level;
[0012] (2) The difference between the second query frequency and the third query frequency is greater than a second set value;
[0013] Wherein, at least a part of the data includes: the characteristic value corresponding to the specific query condition.
[0014] In some embodiments, before S100, the step further includes:
[0015] Determine whether the clearing rate of the feature value corresponding to the query condition input by the user is greater than a preset rate; if so, execute S100.
[0016] In some embodiments, before S100, the step further includes:
[0017] Determine whether the data size of the feature value corresponding to the query condition input by the user is smaller than a preset size; if so, execute S100.
[0018] In some embodiments, before S103, the step further includes:
[0019] When the result of S102 is yes, obtaining the number of the second query conditions that meet the first clearing mechanism;
[0020] It is determined whether the quantity is greater than the set conditional quantity. If so, S103 is executed.
[0021] In some embodiments, before S101, the step further includes:
[0022] creating at least one abnormal value for the cache pool according to a current query target corresponding to the cache pool and the first query condition, wherein the abnormal value is a feature value irrelevant to the first query condition;
[0023] Correspondingly, the first clearing mechanism also requires that the characteristic value corresponding to the second query condition matches the abnormal value.
[0024] In some embodiments, before S101, the method further includes:
[0025] S104 uses the second clearing mechanism to determine whether the current query state triggers the clearing mechanism; if so, execute S103, if not, execute S101;
[0026] Among them, the second clearing mechanism requires that the clearing mechanism is triggered when the user identity type of the current user does not match the user identity type of the previous user, wherein the user identity type is pre-associated with at least one query condition type, and when there is no identical query condition type between the two user identity types, the two are considered to be mismatched.
[0027] The present invention also provides a data cache system, comprising:
[0028] A cache module is configured to provide a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the magnitude of the first query frequency of the first query condition;
[0029] A query condition acquisition module is configured to acquire a second query condition and a third query condition input by a user within a first time, and a second query frequency and a third query frequency of the second query condition and the third query condition within the first time;
[0030] The first clearing mechanism determination module is configured to use the first clearing mechanism to determine whether the second query condition triggers the clearing mechanism, and if so, enter the clearing module, which is configured to clear at least a portion of the data in the cache pool; wherein the first clearing mechanism requires that the clearing mechanism be triggered when the second query condition meets the following two conditions:
[0031] (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is a first query condition whose query weight level is greater than a set level;
[0032] (2) The difference between the second query frequency and the third query frequency is greater than a second set value;
[0033] Wherein, at least a part of the data includes: the characteristic value corresponding to the specific query condition.
[0034] In some embodiments, it also includes:
[0035] The clearing rate judgment module is configured to judge whether the clearing rate of the characteristic value corresponding to the query condition input by the user is greater than the preset rate; if so, enter the cache module
[0036] The present invention also provides a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method described in any one of the embodiments is implemented.
[0037] The present invention also provides a computer program product, which is configured to store computer-readable instructions, and when the computer-readable instructions are executed, the computer executes the method as described in any one of the embodiments.
[0038] Beneficial technical effects:
[0039] In stark contrast to the traditional tail limited item update mechanism, the present invention proposes a specific clearing mechanism for clearing the head cache data (i.e., multiple feature values with the highest historical query level weight in the cache pool) or even the entire cache pool as a whole. Moreover, this specific clearing mechanism of clearing the head or the whole can reduce the consumption of computer performance during long-term operation on the basis of reasonable utilization of cache pool resources.
[0040] From another perspective, unlike the traditional update mechanism, the present invention not only solves the problem of rational use of cache resources, but also pays attention to the consumption of computer performance caused by the cache clearing process, thereby reducing the necessary clearing times through overall clearing (the applicant has found that in the traditional tail-limited item update mechanism, continuous dynamic updates will generate more clearing times than the overall clearing in this application). BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, each element or part is not necessarily drawn according to the actual scale. Obviously, the drawings described below are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without paying creative labor.
[0042] Figure 1 is a schematic diagram of a method flow in an exemplary embodiment of the present invention;
[0043] Figure 2 This is a schematic diagram of data relationships in a cache pool A at an initial time stage in a specific embodiment of the present invention;
[0044] Figure 3 This is a schematic diagram of data relationships of a buffer pool A in a first time phase in a specific embodiment of the present invention;
[0045] Figure 4 This is a schematic diagram of data relationships in a cache pool B in a second time period in a specific embodiment of the present invention;
[0046] Figure 5 This is a schematic diagram of data relationships in cache pool B during the third time period in a specific embodiment of the present invention;
[0047] Figure 6 It is a schematic diagram of the system module structure in an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] Herein, suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings by themselves. Therefore, "module", "component" or "unit" can be used mixedly.
[0050] In this document, the terms "upper", "lower", "inner", "outer", "front", "back", "one end", "the other end" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.
[0051] In this document, unless otherwise clearly specified and limited, the terms "installed", "provided with", "connected", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0052] Herein "and / or" includes any and all combinations of one or more of the associated listed items.
[0053] Herein, "plurality" means two or more than two, ie, it includes two, three, four, five, etc.
[0054] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0055] As used in this specification, the term "about" typically means + / - 5% of the stated value, more typically + / - 4% of the stated value, more typically + / - 3% of the stated value, more typically + / - 2% of the stated value, even more typically + / - 1% of the stated value, and even more typically + / - 0.5% of the stated value.
[0056] In this specification, some embodiments may be disclosed in a format of being in a range. It should be understood that this description of "being in a range" is only for convenience and brevity, and should not be interpreted as a rigid limitation on the disclosed range. Therefore, the description of the range should be considered to have specifically disclosed all possible sub-ranges and independent numerical values within this range. For example, the description of the range 1-6 should be considered to have specifically disclosed sub-ranges such as from 1 to 3, from 1 to 4, from 1 to 5, from 2 to 4, from 2 to 6, from 3 to 6, etc., as well as individual numbers within this range, such as 1, 2, 3, 4, 5 and 6. Regardless of the breadth of the range, the above rules apply.
[0057] "Entity": In this article, an entity refers to the graphic data on a CAD file that is displayed on the CAD drawing interface. An entity has attributes, which are data values that control specific visual characteristics of an entity or element (such as visibility, color, and line style). In different embodiments, an entity may also be referred to as a "pixel" or "element".
[0058] "Object": In this article, objects refer to information on CAD files that will not be displayed in the CAD drawing interface, such as layers, text styles, dimension styles, etc. In this article, "style" refers to a named collection of attributes used to classify and define specific geometric and text elements (such as line styles or text styles).
[0059] "Element": In this article, element refers to all possible information on a CAD file, including "entities" and "objects", and can also be blocks, groups, and unit definitions based on "entities" and / or "objects".
[0060] "File": In this document, a file refers to any type of file that can be run in a CAD system and is used to draw, edit, modify, store, and view CAD drawings. Common CAD file formats include, but are not limited to, DWG, DXF, DWT, DWF, DWL, DWS, DWX, MNU, MNC, MNL, MNS, CUI, CUIX, SHX, PAT, LIN, CTB, STB, PLT, PC3, etc. For example, in some embodiments, a file refers to a CAD drawing (also referred to as a drawing).
[0061] "Collaborators": In this article, collaborators refer to users who participate in a drawing project and work together. The collaborators may have the same expertise (for example, multiple engineers from the architectural profession drawing together) or different expertise (for example, architectural engineers, water supply and drainage engineers, electrical engineers, and HVAC engineers drawing together). The collaborators refer to each other's drawings.
[0062] "Head concentration effect": In this article, the head concentration effect refers to the phenomenon that within a certain period of time, for a certain query target, the query conditions used have a high degree of repetition. For example, taking CAD drawings as an example, when CAD drawings are stored, it is necessary to query the approximate color value of each entity based on the color index value. Among them, the amount of entity data in CAD drawings is usually very large, possibly millions to tens of millions of entities, so millions to tens of millions of queries will be performed during storage. However, most of the query conditions in these millions to tens of millions of queries are the same or similar, that is to say, in such a query scenario, the query conditions (or the corresponding query results) show obvious head concentration. Correspondingly, data with this head concentration effect (such as approximate color values) is also called head data.
[0063] In addition to the approximate color value, typical header data may also include solid straight lines, such as width data of doors and windows.
[0064] Embodiment 1
[0065] See also Figure 1 As shown, the present invention provides a data caching method, which includes the steps of:
[0066] S100 provides a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the magnitude of the first query frequency of the first query condition;
[0067] For example, in some embodiments, the query target may be an entity or an element in a drawing, or the query target may be a CAD drawing.
[0068] For example, in some embodiments, the query frequency is the hit rate of the query condition.
[0069] S101 obtains a second query condition and a third query condition input by a user within a first time, as well as a second query frequency and a third query frequency of the second query condition and the third query condition within the first time;
[0070] S102 uses a first clearing mechanism to determine whether the second query condition triggers a clearing mechanism. If so, S103 is executed to clear at least a portion of the data in the cache pool. The first clearing mechanism requires that the clearing mechanism be triggered when the second query condition meets the following two conditions:
[0071] (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is a first query condition whose query weight level is greater than a set level;
[0072] (2) The difference between the second query frequency and the third query frequency is greater than a second set value;
[0073] Wherein, at least a part of the data includes: the characteristic value corresponding to the specific query condition.
[0074] On the contrary, when the result of S102 is no, the current cache pool may continue to be used.
[0075] In order to more clearly state the technical solution adopted by the present invention, the following is explained by taking an application example - query of approximate color values as an example:
[0076] In this application example, the query target is multiple entities in the CAD drawing, the query condition is the color index, and the feature value is the approximate color value calculated based on the color index.
[0077] As mentioned above, when storing CAD drawings, the approximate color value of each entity needs to be queried based on the color index. Since the amount of entity data in the drawings is very large, usually there are millions to tens of millions of entities, so millions to tens of millions of queries will be performed when storing. If the approximate color value is calculated every time, the efficiency will be very low, and the frequent clearing of approximate color values will also occupy a lot of performance.
[0078] Usually, different drawings may use different color schemes when drawing. For example, Drawing A uses the first color scheme (its main approximate color values include: white, yellow, blue, red, green, etc.), and Drawing B uses the second color scheme (its main approximate color values include: cyan, orange, indigo, etc.). Figure 2-Figure 5 The data information in the cache pool at different stages is shown respectively. The horizontal axis in the figure is the approximate color value, and the vertical axis is the query frequency of the approximate color value.
[0079] In the actual application of the cache mechanism, when a user opens drawing A, a cache pool A will be created for drawing A after analyzing the user's query data. After a period of cache operation, cache pool A will cache approximate color values such as white, yellow, blue, red, and green, and the approximate color values are all associated with the corresponding first index value (equivalent to the first query condition). Figure 2 As shown, it shows the query frequency of different approximate color values when the user opens drawing A, wherein the query weight level of the approximate color value with higher query frequency is also higher;
[0080] It is understandable that, at this time, when the query weight level of the approximate color value is higher, it will preferably be cached in the cache pool for repeated calls by the user, thereby avoiding repeated clearing and causing high performance consumption for the computer system.
[0081] Then, when the user opens drawing B, the computer system will receive the query of the second index value (equivalent to the second query condition and the third query condition) corresponding to the second color system in the first time. Figure 3 As shown, after opening drawing B, the computer will receive the second index value I (i.e., the second query condition) input by the user corresponding to blue (equivalent to the characteristic value), and record the second query frequency corresponding to the second index value I, which is 1000, and the second index value II (i.e., the third query condition) corresponding to blue 100 (equivalent to the characteristic value), and record the third query frequency of the corresponding second index value II as 33.
[0082] See also Figure 3 , the current cache pool A includes at least the following cache data: white - 32000; yellow - 21000; blue - 18000; green - 13000; cyan - 1000; orange - 920; indigo - 780; blue 102-101; cyan 100-33 (the numbers represent the query hit rate); at this time, the first index value corresponding to the feature value with a query weight level greater than or equal to 5 is set as the specific query condition; for example, the index value corresponding to green is currently selected as the specific query condition;
[0083] Furthermore, the first clearing mechanism is used to determine whether the second index value I (ie, the second query condition) corresponding to the green triggers the clearing mechanism. Specifically:
[0084] (1) The difference between the first query frequency 13000 of the first index value and the second query frequency 1000 of the second index value I is greater than the first set value;
[0085] (2) The difference between the second query frequency 1000 of the second index value I and the third query frequency 33 of the second index value II is greater than the second set value;
[0086] Therefore, it is considered that the second index value I corresponding to cyan has triggered the clearing mechanism, and all color approximations of the specific query conditions are cleared as a whole. Correspondingly, after the clearing, a new cache pool B is obtained, and the cached data information is as follows Figure 4 shown.
[0087] In particular, in some embodiments, when the clearing mechanism is triggered, the data in the entire cache pool will be directly cleared, and new cache data will be built in the cache pool.
[0088] It is understandable that the specific setting value can be adaptively adjusted according to different query targets or query condition types of the user.
[0089] It is worth noting that, unlike the traditional method of updating the weight of data according to the cache level, or clearing the tail data, the present invention proposes a new specific clearing mechanism for data cache, focusing on clearing the high-weight (or even the entire) cache data as a whole. While rationally utilizing the cache resources of the cache pool, it reduces the consumption of computer performance by clearing. In other words, the overall clearing mechanism for high-weight cache data (or the head cache data clearing mechanism) proposed by the present invention can effectively reduce the number of necessary clearing times.
[0090] In some embodiments, before S100, the step further includes:
[0091] Determine whether the clearing rate of the feature value corresponding to the query condition input by the user is greater than a preset rate; if so, execute S100;
[0092] Otherwise, in some embodiments, the caching mechanism will not be enabled, ie, a cache pool may be provided.
[0093] In some embodiments, before S100, the step further includes:
[0094] Determine whether the data size of the feature value corresponding to the query condition input by the user is smaller than a preset size; if so, execute S100; otherwise, in some embodiments, the cache mechanism will not be enabled, that is, a cache pool may be provided.
[0095] Contrary to the traditional caching idea (i.e., clearing a limited number of low-weight data at the tail to reduce the calculation time of high-frequency data through caching), the present invention also comprehensively considers key characteristics such as the clearing rate of cached data and data size, so as to clear the high-weight data in the cache pool as a whole from the perspective of the consumption of computing performance by data clearing.
[0096] Furthermore, for data with obvious head concentration efficiency, the clearing mechanism setting of the present invention can significantly reduce the consumption of computer performance by data clearing.
[0097] In some embodiments, before S103, the step further includes:
[0098] When the result of S102 is yes, obtaining the number of the second query conditions that meet the first clearing mechanism;
[0099] It is determined whether the number is greater than the set conditional number, and if so, S103 is executed. Otherwise, in some embodiments, the data clearing step is suspended.
[0100] Furthermore, in order to improve the reliability of the clearing mechanism, the number of second query conditions that satisfy the first clearing mechanism will also be comprehensively considered. That is, the clearing mechanism will only be activated when a typical new pattern appears in the latest batch of query conditions (for example, the color pattern of the first color system changes to the color pattern of the second color system).
[0101] In some embodiments, before S101, the step further includes:
[0102] creating at least one abnormal value for the cache pool according to a current query target corresponding to the cache pool and the first query condition, wherein the abnormal value is a feature value irrelevant to the first query condition;
[0103] Correspondingly, the first clearing mechanism also requires that the characteristic value corresponding to the second query condition matches the abnormal value.
[0104] For example, the abnormal value can be a fixed value customized by the user, or an error value that should not appear, and it is guaranteed that the value will not be queried under normal circumstances. Only when a certain event is triggered (for example, when the first clearing mechanism is triggered, or when at least one of the user identity type and the query target changes), the computer will actively query the abnormal value. When the abnormal value is queried, it is considered that the current cache pool no longer meets the current query content, has expired, and needs to be fully updated.
[0105] For example, taking the color index application as an example, you can set an abnormal color value for the cache pool, such as setting the abnormal value to transparent color or other extreme colors. At this time, after querying the color data of drawing A, cache pool A has been occupied by the characteristic value of drawing A. At this time, before querying the color of drawing B, query the set abnormal color once. When querying the color of drawing B, if the color is found to be an abnormal color, then the entire cache pool is cleared, and the next query starts to rebuild cache pool B. In this way, when querying the color of drawing B, the cache pool can be updated quickly, improving the color query performance of drawing B.
[0106] Furthermore, since the query conditions targeted by the present invention have the characteristic of being head-concentrated, even if the cache pool is cleared as a whole (eg, historical query color value records are not retained), the impact on subsequent query efficiency is relatively small.
[0107] In some embodiments, before S101, the method further includes:
[0108] S104 uses the second clearing mechanism to determine whether the current query state triggers the clearing mechanism; if so, execute S103, if not, execute S101;
[0109] Among them, the second clearing mechanism requires that the clearing mechanism is triggered when the user identity type of the current user does not match the user identity type of the previous user, wherein the user identity type is pre-associated with at least one query condition type, and when there is no identical query condition type between the two user identity types, the two are considered to be mismatched.
[0110] For example, the user identity type can be different collaborators, such as construction engineers, water supply and drainage engineers, electrical engineers, and HVAC engineers. At this time, for different collaborators, their preferences for query conditions will also be different. In this embodiment, at least one query condition type (such as color type, or attribute type, etc.) can be preset for different collaborators. At this time, when the computer system detects that the user identity type has a large change, it will directly clear the last cache pool record retained in the drawing and directly create a new cache pool for the user.
[0111] In some embodiments, the feature value may also be a description of the entity, such as a straight line, fill, and other information.
[0112] The following also takes the color index value query as an example to illustrate the cache mechanism in the cache pool of the present invention:
[0113] After the user selects a query target (such as a drawing), a cache pool of appropriate size can be predefined. Before performing data query calculations, first check whether the query result (equivalent to the characteristic value) has been cached in the cache pool according to the query conditions:
[0114] If the query condition is found, in addition to returning the query result, the query count weight of the query result will be increased and its priority will be adjusted. The adjustment strategy depends on two weights: the first is the query count, the more the query count, the higher the priority; the second is the query timing, the more recent the query, the higher the priority.
[0115] If the query condition is not found, the query calculation is performed first to obtain the result data, and then an attempt is made to put the result into the cache. The strategy for putting the result into the cache is as follows.
[0116] If the cache pool is not full, the query result is added to the cache pool at the lowest priority position, and then the priority is adjusted according to the weight of the query timing (equivalent to adjusting the query weight level).
[0117] If the cache pool is full, reduce the query count weight of all data in the cache pool. After adjustment, determine whether there is data with low query count weight and query timing weight. If so, replace it with the query result of this time.
[0118] Moreover, compared with the original calculation method (i.e., calculating the approximate color values one by one each time a query is made), the new calculation method (i.e., reusing data through a cache pool) significantly reduces the calculation time.
[0119] See also Figure 2 As shown, a large number of color values have obvious head concentration effects, and the following Table 1 is the simulation test results:
[0120] Table 1-Comparison of calculation time
[0121] Query data (number of copies) Original calculation method time consumption (s) New calculation method time (s) 1000000 0.69 0.04 2000000 1.46 0.07 10000000 6.86 0.35
[0122] However, when the user switches to another CAD drawing, see Figure 2-Figure 5 As shown, the rules of the query conditions are significantly different from the pre-stored data in the cache pool. At this time, the existing data cannot meet the latest query requirements, and the above-mentioned clearing mechanism will be used to clear the cache pool as a whole.
[0123] Embodiment 2
[0124] See also Figure 6 As shown, the present invention also provides a data cache system correspondingly, including:
[0125] The cache module 100 is configured to provide a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the magnitude of the first query frequency of the first query condition;
[0126] The query condition acquisition module 101 is configured to acquire a second query condition and a third query condition input by a user within a first time, and a second query frequency and a third query frequency of the second query condition and the third query condition within the first time;
[0127] The first clearing mechanism determination module 102 is configured to use the first clearing mechanism to determine whether the second query condition triggers the clearing mechanism. If so, the clearing module 103 is entered, and the clearing module is configured to clear at least a portion of the data in the cache pool; wherein the first clearing mechanism requires that the clearing mechanism is triggered when the second query condition meets the following two conditions:
[0128] (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is a first query condition whose query weight level is greater than a set level;
[0129] (2) The difference between the second query frequency and the third query frequency is greater than a second set value;
[0130] Wherein, at least a part of the data includes: the characteristic value corresponding to the specific query condition.
[0131] In some embodiments, it also includes:
[0132] The clearing rate judgment module is configured to judge whether the clearing rate of the characteristic value corresponding to the query condition input by the user is greater than the preset rate; if so, enter the cache module to judge whether the data size of the characteristic value corresponding to the query condition input by the user is less than the preset size; if so, enter the cache module 100.
[0133] In some embodiments, it also includes: a quantity determination module, which is configured to obtain the number of the second query conditions that meet the first clearing mechanism before entering the clearing module 103 when the result of the first clearing mechanism determination module 102 is yes; determine whether the number is greater than the set condition number, and if so, enter the clearing module 103.
[0134] In some embodiments, it also includes:
[0135] The exception verification module is configured to create at least one exception value for the cache pool according to the current query target corresponding to the cache pool and the first query condition before entering the query condition acquisition module 101, wherein the exception value is a feature value irrelevant to the first query condition; correspondingly, the first clearing mechanism also requires that the feature value corresponding to the second query condition matches the exception value.
[0136] In some embodiments, a second clearing mechanism determination module is further included, which is configured to use a second clearing mechanism to determine whether the current query state triggers a clearing mechanism before entering the query condition acquisition module 101; if so, enter the clearing module 103; if not, execute the query condition acquisition module 101;
[0137] Among them, the second clearing mechanism requires that the clearing mechanism is triggered when the user identity type of the current user does not match the user identity type of the previous user, wherein the user identity type is pre-associated with at least one query condition type, and when there is no identical query condition type between the two user identity types, the two are considered to be mismatched.
[0138] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0139] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, 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, a magnetic disk, or an optical disk), and includes a number of instructions for a computer terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0140] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A data caching method, characterized in that: Includes steps: S100 provides a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the magnitude of the first query frequency of the first query condition; S101 obtains a second query condition and a third query condition input by a user within a first time, as well as a second query frequency and a third query frequency of the second query condition and the third query condition within the first time; S102 uses a first clearing mechanism to determine whether the second query condition triggers a clearing mechanism. If so, S103 is executed to clear at least a portion of the data in the cache pool. The first clearing mechanism requires that the clearing mechanism be triggered when the second query condition meets the following two conditions: (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is the first query condition whose query weight level is greater than a set level; (2) The difference between the second query frequency and the third query frequency is greater than a second set value; Wherein, the at least part of the data includes: the feature value corresponding to the specific query condition; Before S101, the following steps are also included: creating at least one abnormal value for the cache pool according to a current query target corresponding to the cache pool and the first query condition, wherein the abnormal value is a feature value irrelevant to the first query condition; Correspondingly, the first clearing mechanism also requires that the characteristic value corresponding to the second query condition matches the abnormal value.
2. The data caching method according to claim 1, characterized in that: Before S100, the following steps are also included: Determine whether the clearing rate of the feature value corresponding to the query condition input by the user is greater than a preset rate; if so, execute S100.
3. The data caching method according to claim 1, characterized in that: Before S100, the following steps are also included: Determine whether the data size of the feature value corresponding to the query condition input by the user is smaller than a preset size; if so, execute S100.
4. The data caching method according to claim 1, characterized in that: Before S103, the step further includes: When the result of S102 is yes, obtaining the number of the second query conditions that meet the first clearing mechanism; It is determined whether the quantity is greater than the set conditional quantity. If so, S103 is executed.
5. The data caching method according to claim 1, characterized in that: Prior to S101, it also included: S104 uses the second clearing mechanism to determine whether the current query state triggers the clearing mechanism; if so, execute S103, if not, execute S101; Among them, the second clearing mechanism requires that the clearing mechanism is triggered when the user identity type of the current user does not match the user identity type of the previous user, wherein the user identity type is pre-associated with at least one query condition type, and when there is no identical query condition type between the two user identity types, the two are considered to be mismatched.
6. A data cache system, characterized in that: include: A cache module is configured to provide a cache pool for a first query condition of at least one query target, wherein the cache pool pre-stores at least one feature value corresponding to the first query condition; wherein the first query condition is further associated with a query weight level, and the query weight level is used to reflect the size of the first query frequency of the first query condition; A query condition acquisition module is configured to acquire a second query condition and a third query condition input by a user within a first time, and a second query frequency and a third query frequency of the second query condition and the third query condition within the first time; The first clearing mechanism determination module is configured to use the first clearing mechanism to determine whether the second query condition triggers the clearing mechanism, and if so, enter the clearing module, which is configured to clear at least a portion of the data in the cache pool; wherein the first clearing mechanism requires that the clearing mechanism be triggered when the second query condition meets the following two conditions: (1) The difference between the first query frequency and the second query frequency of a specific query condition is greater than a first set value, and the specific query condition is the first query condition whose query weight level is greater than a set level; (2) The difference between the second query frequency and the third query frequency is greater than a second set value; Wherein, the at least part of the data includes: the feature value corresponding to the specific query condition; The exception verification module is configured to create at least one exception value for the cache pool according to the current query target corresponding to the cache pool and the first query condition before entering the query condition acquisition module, wherein the exception value is a feature value irrelevant to the first query condition; correspondingly, the first clearing mechanism also requires that the feature value corresponding to the second query condition matches the exception value.
7. The data cache system according to claim 6, characterized in that: Also includes: A clearing rate determination module is configured to determine whether a clearing rate of a characteristic value corresponding to the query condition input by the user is greater than a preset rate; If yes, enter the cache module.
8. A computer-readable storage medium, characterized in that: Computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.
9. A computer program product, characterized in that The method is configured to store computer-readable instructions, which, when executed, cause a computer to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for data caching
CN103246612A