Data caching method and device, computer equipment and readable storage medium
By setting multiple data cache layers in the reporting system, selecting appropriate cache layers for storage according to data characteristics and usage requirements, the problem of lack of flexibility in data cache in the prior art is solved, and flexible storage and efficient access of data are achieved.
Patent Information
- Application Number
- CN202411741891.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-14
AI Technical Summary
The existing reporting system lacks flexible storage strategies in data caching and cannot meet the diverse needs of different users and business scenarios.
By setting multiple data cache layers (temporary cache layer, key field cache layer, database cache layer and global shared cache layer), the most suitable cache layer is flexibly selected for storage according to the characteristics and usage requirements of the data to be cached.
It realizes flexible storage of data, meets the diverse needs of different users and business scenarios, and improves data access speed and overall performance.
Smart Images

Figure CN119621781A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of report technology, and in particular to a data caching method, device, computer equipment and readable storage medium. Background Art
[0002] The reporting system is a comprehensive software system that integrates data collection, processing, analysis and display functions. It is mainly used to extract data from various data sources, process these data through preset or customized rules and algorithms, and generate various types of reports, such as statistical tables, charts, dashboards, etc., to meet the needs of enterprises or individuals for data analysis and decision support.
[0003] When the current reporting system caches data, it caches the query results within its own system or stores them in the target database.
[0004] However, different users or business scenarios may have completely different requirements for caching, and current reporting systems lack flexible storage strategies for data caching. Summary of the invention
[0005] Based on this, it is necessary to provide a data caching method, device, computer equipment and readable storage medium that can realize flexible data storage in response to the above technical problems.
[0006] In a first aspect, the present application provides a data caching method, the method comprising:
[0007] Get the data to be cached;
[0008] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0009] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0010] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0011] In one embodiment, determining the matching result between the data to be cached and the multiple data cache layers corresponding to the local report system includes:
[0012] Matching the data to be cached with the query statement in the local report system to obtain a matching result between the data to be cached and the temporary cache layer;
[0013] Matching the data to be cached with the key fields in the display interface provided by the local report system to obtain a matching result between the data to be cached and the key field cache layer;
[0014] Matching the data to be cached with each database in the local reporting system to obtain a matching result between the data to be cached and the database cache layer;
[0015] The data to be cached is matched with the shared data type in the local report system to obtain a matching result between the data to be cached and the global shared cache layer.
[0016] In one embodiment, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers according to each matching result includes:
[0017] If the matching result between the data to be cached and any data cache layer in the multiple data cache layers indicates a successful match, the data cache layer is used as the target cache layer corresponding to the data to be cached.
[0018] In one of the embodiments, storing the to-be-cached data in the target cache layer according to the cache policy corresponding to the target cache layer includes:
[0019] Determine the target cache duration and cache refresh frequency corresponding to the target cache layer according to the cache strategy corresponding to the target cache layer;
[0020] The to-be-cached data is stored in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer.
[0021] In one of the embodiments, the method further includes: determining a continued caching time for the data to be cached to continue to be stored in the target cache layer according to the access records and data weight of the data to be cached, and the access records and data weight of other cached data in the local report system; wherein the continued caching time is less than or equal to the target caching time;
[0022] Continuing to store the data to be cached in the target cache layer according to the continued cache duration and the cache refresh frequency corresponding to the target cache layer;
[0023] When the time period for storing the data to be cached in the target cache layer reaches the continued cache time period, the data to be cached is stored in the persistent storage space corresponding to the local reporting system.
[0024] In one embodiment, a plurality of data cache layers correspond to different priorities respectively; storing the data to be cached in the target cache layer according to the cache policy corresponding to the target cache layer includes:
[0025] Obtaining configuration parameters of the target cache layer;
[0026] If it is determined according to the configuration parameters that the target cache layer has a corresponding cache strategy, then storing the data to be cached in the target cache layer according to the cache strategy corresponding to the target cache layer;
[0027] If it is determined according to the configuration parameters that there is no corresponding cache strategy for the target cache layer, then according to the priorities corresponding to the data cache layers, the upper-level data cache layer corresponding to the target cache layer is selected from multiple data cache layers, and the cache strategy corresponding to the upper-level data cache layer is used as the cache strategy corresponding to the target cache layer, and according to the cache strategy corresponding to the target cache layer, the data to be cached is stored in the target cache layer.
[0028] In a second aspect, the present application further provides a data cache device, comprising:
[0029] An acquisition module is used to obtain data to be cached;
[0030] A matching module, used to determine the matching results between the data to be cached and multiple data cache layers corresponding to the local reporting system; wherein the multiple data cache layers at least include a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0031] A cache layer selection module, used to select a target cache layer corresponding to the data to be cached from multiple data cache layers according to each matching result;
[0032] The data cache module is used to store the data to be cached in the target cache layer according to the cache policy corresponding to the target cache layer.
[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0034] Get the data to be cached;
[0035] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0036] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0037] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0039] Get the data to be cached;
[0040] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0041] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0042] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0043] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0044] Get the data to be cached;
[0045] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0046] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0047] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0048] The above-mentioned data caching method, device, computer equipment and readable storage medium, the present application sets multiple data cache layers (temporary cache layer, key field cache layer, database cache layer and global shared cache layer). The solution can flexibly select the most appropriate cache layer for storage according to the characteristics and usage requirements of the data to be cached. This multi-level design meets the diverse cache needs of different users and business scenarios. The multi-level cache design makes it easy to expand new cache layers or adjust the strategies of existing cache layers as needed in the future to adapt to business development and changes. Through refined cache strategy management, the life cycle of data can be more effectively controlled, including data creation, updating, expiration and deletion, thereby improving data consistency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 An application environment diagram of a data caching method in an embodiment;
[0051] Figure 2 A schematic diagram of a flow chart of a data caching method in an embodiment;
[0052] Figure 3 A flowchart of steps for determining a matching result between the data to be cached and multiple data cache layers corresponding to a local report in one embodiment;
[0053] Figure 4 A schematic diagram of a flow chart of a step of storing the data to be cached in the target cache layer in an embodiment;
[0054] Figure 5 A flowchart of the steps of storing the data to be cached in the persistent storage space corresponding to the local report in one embodiment;
[0055] Figure 6 A schematic diagram of a flow chart of a step of storing the data to be cached in the target cache layer in an embodiment;
[0056] Figure 7 is a structural block diagram of a data cache device in one embodiment;
[0057] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0059] In an exemplary embodiment, Figure 1 As shown, the present application provides an intelligent reporting system, which includes a foreground function subsystem, a cache subsystem and a background management subsystem;
[0060] Among them, the front-end functional subsystem includes custom query module, interactive dashboard, data modeling module, SQL editor module, data modeling module, question building module and operation definition module.
[0061] The cache subsystem includes a cache API module, a forwarding and refresher module, and a timing scheduler module.
[0062] Among them, the background management subsystem includes data access submodule, permission management submodule, performance management submodule, task and scheduling submodule, audit tracking submodule and log monitoring submodule.
[0063] In an exemplary embodiment, Figure 2 As shown, a data caching method is provided, which is applied to Figure 1 In the cache API module, the method includes:
[0064] S201, obtaining data to be cached.
[0065] When a user initiates a query or requests data through the front-end function, the data to be cached is first obtained. The data can come from a database, an external data source, or other sub-.
[0066] S202: Determine a matching result between the data to be cached and a plurality of data cache layers corresponding to the local report.
[0067] Among them, the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer.
[0068] Specifically, analyze the characteristics of the data to be cached, such as data size, access frequency, importance, etc. Based on these characteristics, determine in which data cache layer the data to be cached should be stored. The data cache layer includes:
[0069] (1) Temporary cache layer: used to store short-term, frequently accessed data.
[0070] It is understandable that the temporary cache layer is also called the "question cache layer". The question cache layer is used to cache query results for specific questions. For example, when a user creates a SQL query in an intelligent report or builds a question using the question editor, the results of these queries are cached to speed up subsequent query requests for the same question. Each question will calculate the retention time of the question cache, which can be configured in the settings. The cache can be cleared or set to expire on demand to ensure the real-time nature of the query data.
[0071] (2) Key field cache layer: used to store key fields in the data to speed up query.
[0072] The key field cache layer is also called the "dashboard cache". The dashboard cache is used to save the overall query results of the widgets of each question in the dashboard. By caching the query results of all question components, smart reports can speed up the loading speed of the dashboard, especially when the data volume is large or the query is complex. The dashboard cache is usually independent of the question cache, so the refresh frequency of the dashboard can be controlled separately to avoid frequent triggering of large numbers of queries.
[0073] (3) Database cache layer: used to store larger amounts of data and usually interacts directly with the database.
[0074] The database cache layer refers to the cache configuration at the database level. Any query executed on this database that does not specify its own cache strategy will use the database-level cache strategy. Its type can be one of the following: specified duration strategy, schedule strategy, adaptive strategy, no cache strategy, and default strategy.
[0075] (4) Global shared cache layer: used to store data shared across multiple users or modules.
[0076] The global shared cache layer is the default cache with the widest scope and the lowest priority. The type of global cache must be one of the specified duration strategy, schedule strategy, adaptive strategy, and no cache strategy.
[0077] Specifically, the process of determining the matching result between the data to be cached and the multiple data cache layers corresponding to the local report is as follows:
[0078] (I) The matching process of data feature dimensions is as follows: Analyze the size of the data to be cached to determine which cache layer it is suitable for storage. For example, smaller data may be more suitable for storage in a temporary cache layer or a key field cache layer, while larger data may need to be stored in a database cache layer or a global shared cache layer. Evaluate the access frequency of the data to be cached. Highly frequently accessed data is suitable for storage in a temporary cache layer or a key field cache layer to speed up access; while low-frequency accessed data can be stored in a database cache layer or a global shared cache layer. Determine the importance of the data to be cached. Key data or sensitive data may need to be stored in a more secure and reliable cache layer, such as a database cache layer or a global shared cache layer. Analyze the timeliness of the data to be cached. Data with higher real-time requirements may be more suitable for storage in a temporary cache layer for quick updates; while data with lower timeliness requirements may be stored in a database cache layer or a global shared cache layer.
[0079] (II) The matching process of the cache strategy dimension is as follows: Consider the capacity limitations of each cache layer. Ensure that the selected cache layer has sufficient capacity to store the data to be cached. Evaluate the cache strategies of each cache layer, such as cache refresh strategy, cache invalidation strategy, etc. Select a cache strategy that matches the characteristics of the data to be cached to optimize cache performance. Consider the consistency requirements between the cached data and the original data source. For data that requires high consistency, more complex cache consistency strategies may need to be adopted, such as distributed transactions or subscription database binlog.
[0080] Specifically, for each data cache layer, a preliminary match is performed based on the data characteristic dimensions (data size, access frequency, data importance, and data timeliness) to screen out suitable cache layers. The cache strategy dimension is evaluated for the cache layers that are initially screened, taking into account factors such as cache capacity, cache strategy, and cache consistency, to obtain a comprehensive matching result of the data characteristic dimension and the cache strategy dimension.
[0081] S203: Select a target cache layer corresponding to the to-be-cached data from multiple data cache layers according to each matching result.
[0082] Optionally, based on the matching results of the data feature dimension and the cache strategy dimension, an optimal cache layer is selected as the target cache layer for the data to be cached.
[0083] S204: Store the data to be cached in the target cache layer according to the cache policy corresponding to the target cache layer.
[0084] Among them, the cache policy corresponding to the target cache layer may include: (1) a cache refresh policy, which is used to determine when and how to update the data in the cache; (2) a cache invalidation policy, which is used to determine when and how to invalidate the cached data; (3) a cache consistency policy, which is used to ensure the consistency between the cached data and the original data source; (4) a cache capacity management policy, which is used to manage the storage capacity of the cache layer and prevent cache overflow; (5) a cache access policy, which is used to determine how to access the data in the cache; and (6) a cache security policy, which is used to ensure the security of the cached data.
[0085] Optionally, when storing the data to be cached in the target cache layer, establish a connection with the target cache layer to ensure that data interaction can be performed normally. Store the data to be cached in the target cache layer. This process may involve steps such as writing data to the cache, setting cache keys, and configuring cache policies. Ensure that the storage specifications and restrictions of the target cache layer are followed during the data storage process. According to the cache policy obtained previously, configure the corresponding cache policy for the data to be cached in the target cache layer. This can include setting the expiration time of the cache, configuring the cache refresh mechanism, and setting the cache consistency policy. After the storage is completed, verify whether the data is correctly stored in the target cache layer. Verification can be performed by querying the cache, comparing data, etc.
[0086] In the above data caching method, this application sets multiple data cache layers (temporary cache layer, key field cache layer, database cache layer and global shared cache layer). The solution can flexibly select the most appropriate cache layer for storage according to the characteristics and usage requirements of the data to be cached. This multi-level design meets the diverse cache needs of different users and business scenarios. The multi-level cache design makes it easy to expand new cache layers or adjust the strategies of existing cache layers as needed in the future to adapt to business development and changes. Through refined cache strategy management, the life cycle of data can be more effectively controlled, including data creation, updating, expiration and deletion, thereby improving data consistency and accuracy.
[0087] In an exemplary embodiment, Figure 3 As shown, the determining of the matching result between the data to be cached and the multiple data cache layers corresponding to the local report includes:
[0088] S301, matching the data to be cached with the query statement in the local report to obtain a matching result between the data to be cached and the temporary cache layer.
[0089] Specifically, the data to be cached is matched with the data tables and fields involved in the query statement. If the data to be cached is the data frequently accessed by the query statement, or is highly relevant to the query statement, it is considered that the data to be cached has a high degree of match with the temporary cache layer. Based on the degree of match, it is determined whether the data to be cached is suitable for storage in the temporary cache layer in order to quickly respond to future query requests.
[0090] S302: Match the data to be cached with the key fields in the display interface provided by the local report to obtain a matching result between the data to be cached and the key field cache layer.
[0091] Specifically, analyze the display interface of the local report and identify the key fields on the interface, which are usually the core data that users are concerned about or the data that is frequently displayed. Extract information related to the key fields from the data to be cached. Match the extracted key information with the key fields in the display interface. If the data to be cached contains a large amount of information directly related to the key fields, it is considered that the data to be cached has a high degree of match with the key field cache layer. Based on the degree of match, decide whether the data to be cached is suitable for storage in the key field cache layer so that it can be quickly displayed to the user.
[0092] S303: Match the data to be cached with each database in the local report to obtain a matching result between the data to be cached and the database cache layer.
[0093] Specifically, understand the structure, table relationships, and data distribution of each database in the local report. Map the data to be cached to the corresponding table or field in the database. Evaluate the data volume of the data to be cached and its access mode in the database (such as query frequency, update frequency, etc.). If the data volume of the data to be cached is large, the access frequency is high, and it is suitable for storage and query in the database, it is considered that the data to be cached has a high degree of match with the database cache layer. Decide whether to store the data to be cached in the database cache layer to take advantage of the query optimization and storage management capabilities of the database.
[0094] S304: Match the data to be cached with the shared data type in the local report to obtain a matching result between the data to be cached and the global shared cache layer.
[0095] Specifically, analyze which data types in local reports are shared across multiple users or components. Check whether the data to be cached is shared, that is, whether it is accessed by multiple users or components at the same time. Evaluate the consistency and security requirements of the data to be cached when it is shared. If the data to be cached is highly consistent and secure, and is suitable for global sharing, it is considered that the data to be cached has a high degree of match with the global shared cache layer. Based on the evaluation results of sharing, consistency, and security, decide whether the data to be cached is suitable for storage in the global shared cache layer.
[0096] Furthermore, according to each matching result, a target cache layer corresponding to the data to be cached is selected from multiple data cache layers, including: if the matching result between the data to be cached and any data cache layer in the multiple data cache layers indicates a successful match, then the data cache layer is used as the target cache layer corresponding to the data to be cached.
[0097] Furthermore, in actual applications, it may be necessary to set the matching priority according to business requirements and the characteristics of the cache layer. For example, some key data may need to be stored in the key field cache layer or the global shared cache layer first. If the data to be cached successfully matches multiple data cache layers, and the business logic requires that only one of them can be selected as the target cache layer, then conflict handling rules need to be formulated. For example, the final selection of the cache layer can be determined based on factors such as the matching degree, the usage of the cache layer, and the importance of the business.
[0098] In this embodiment, through the above technical solution, the matching degree between the data to be cached and the multiple data cache layers corresponding to the local report can be comprehensively evaluated, and the most suitable cache layer can be selected for storage according to the evaluation result. This can not only improve the data access speed, but also optimize resource utilization and improve overall performance.
[0099] In an exemplary embodiment, Figure 4 As shown, storing the to-be-cached data in the target cache layer according to the cache policy corresponding to the target cache layer includes:
[0100] S401, determining a target cache duration and a cache refresh frequency corresponding to the target cache layer according to a cache policy corresponding to the target cache layer.
[0101] Optionally, obtain the cache policy corresponding to the target cache layer from the configuration or cache policy management module. These policies usually include the storage duration, refresh frequency, consistency requirements, etc. of the cache. Parse the obtained cache policy to extract specific parameters related to the target cache layer, such as the target cache duration (i.e., the maximum time that data is stored in the cache) and the cache refresh frequency (i.e., the frequency of updating cache data). According to the provisions in the cache policy, determine the maximum time that data should be stored in the target cache layer, i.e., the target cache duration. This time can be fixed (such as 1 hour, 1 day, etc.) or dynamic (such as dynamically adjusted according to the frequency of use or importance of the data). Similarly, determine the refresh frequency of the cached data according to the cache policy. This frequency determines how often the cached data is updated, which can be a periodic refresh (such as a refresh every hour), a real-time refresh (such as an immediate refresh when the data changes), or a refresh triggered by a specific event.
[0102] S402: Store the to-be-cached data in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer.
[0103] Optionally, the data to be cached is packaged and processed according to the storage format and requirements of the target cache layer, and is prepared to be stored in the cache. When storing the cached data, an expiration time is set for the cached data according to the target cache duration determined in S401.
[0104] When data is stored in the cache for more than this time, the cache will automatically delete it or mark it as invalid. According to the cache refresh frequency determined in S401, configure the cache data refresh mechanism. This can be achieved through scheduled tasks, event monitoring, or data change notifications. Ensure that the cache can be updated in time when the data changes or reaches the refresh time.
[0105] Finally, the processed data to be cached is stored in the target cache layer. During the storage process, it is necessary to ensure the integrity and consistency of the data, and perform optimization operations such as data partitioning and indexing according to the requirements of the cache.
[0106] Further, such as Figure 5 As shown, after storing the data to be cached in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer, the method further includes:
[0107] S501, determining a continued caching time for the data to be cached to continue to be stored in the target cache layer according to the access records and data weights of the data to be cached and the access records and data weights of other cached data in the local report.
[0108] The continued caching time duration is less than or equal to the target caching time duration.
[0109] Optionally, access records of the data to be cached and other cached data are collected from the log or cache access monitoring module. These records should include information such as the access time, access frequency, and access user of the data. Weights are assigned to the data to be cached and other cached data based on business rules and data importance. The weights can reflect the importance, frequency of use, or business value of the data.
[0110] Furthermore, the collected access records are analyzed to identify the access patterns of the data, such as the peak access time and the changing trend of the access frequency. Combined with the data weight and access pattern, the value of continuing to store the cached data in the cache is evaluated. The access frequency, importance and relative relationship of the data with other data are considered. Based on the above evaluation, the continued cache duration of the cached data in the target cache layer is determined. This duration should be less than or equal to the initially set target cache duration, and should be dynamically adjusted according to the actual access situation and weight of the data.
[0111] S502: Continue to store the data to be cached in the target cache layer according to the continued cache duration and the cache refresh frequency corresponding to the target cache layer.
[0112] It is understandable that, according to the continued caching duration determined in S501, the caching strategy of the data to be cached in the target cache layer is updated, including updating the expiration time and the refresh mechanism. According to the updated caching strategy, the data to be cached is continued to be stored in the target cache layer. It is ensured that the data remains valid within the continued caching duration and is updated in a timely manner according to the cache refresh frequency.
[0113] S503: When the storage time of the data to be cached in the target cache layer reaches the continued cache time, the data to be cached is stored in the persistent storage space corresponding to the local report.
[0114] Specifically, according to the continued caching duration determined in S501, the caching strategy of the data to be cached in the target cache layer is updated, including updating the expiration time and the refresh mechanism. According to the updated caching strategy, the data to be cached is continued to be stored in the target cache layer. Ensure that the data remains valid within the continued caching duration and is updated in a timely manner according to the cache refresh frequency.
[0115] In an exemplary embodiment, multiple data cache layers correspond to different priorities respectively.
[0116] Correspondingly, such as Figure 6 As shown, storing the to-be-cached data in the target cache layer according to the cache policy corresponding to the target cache layer includes:
[0117] S601: Obtain configuration parameters of the target cache layer.
[0118] Optionally, access the storage location where the configuration parameters of each data cache layer are stored, which can be a configuration file, a database table, a distributed configuration center, etc. Extract the configuration parameters related to the target cache layer from the configuration storage. These parameters include the name, type, capacity, cache policy reference, etc. of the cache layer.
[0119] S602: If it is determined according to the configuration parameters that the target cache layer has a corresponding cache policy, the data to be cached is stored in the target cache layer according to the cache policy corresponding to the target cache layer.
[0120] Optionally, based on the configuration parameters obtained in S601, check whether the target cache layer has a clearly specified cache strategy. If a corresponding cache strategy exists, configure the behavior of the target cache layer according to the specific content of the strategy (such as cache duration, refresh frequency, consistency strategy, etc.). Use the configured cache strategy to store the data to be cached in the target cache layer.
[0121] S603: If it is determined according to the configuration parameters that there is no corresponding cache strategy for the target cache layer, then according to the priorities corresponding to the data cache layers, select the upper-level data cache layer corresponding to the target cache layer from multiple data cache layers, use the cache strategy corresponding to the upper-level data cache layer as the cache strategy corresponding to the target cache layer, and store the data to be cached in the target cache layer according to the cache strategy corresponding to the target cache layer.
[0122] Optionally, if the cache policy of the target cache layer is not found in the configuration parameters determined in S601, enter this step. It is necessary to know the priority relationship between the various data cache layers, which is usually also defined in the configuration. According to the priority information, find the parent data cache layer of the target cache layer. This usually means that in the cache hierarchy, the parent cache layer has a higher priority or is closer to the data source. Use the cache policy of the parent data cache layer as the cache policy of the target cache layer. This includes copying the cache duration, refresh frequency and other settings of the parent level. Use the inherited cache policy to configure the target cache layer and store the data to be cached. Record the relationship of this policy inheritance in the log or configuration management for subsequent maintenance and auditing.
[0123] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0124] Based on the same inventive concept, the embodiment of the present application also provides a data caching device for implementing the data caching method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data caching device embodiments provided below can refer to the limitations on the data caching method above, and will not be repeated here.
[0125] In an exemplary embodiment, Figure 7 As shown, a data cache device is provided, comprising: an acquisition module 11, a matching module 12, a cache layer selection module 13 and a data cache module 14; wherein:
[0126] An acquisition module 11 is used to acquire data to be cached;
[0127] A matching module 12 is used to determine the matching result between the data to be cached and multiple data cache layers corresponding to the local reporting system; wherein the multiple data cache layers at least include a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0128] A cache layer selection module 13, configured to select a target cache layer corresponding to the data to be cached from multiple data cache layers according to each matching result;
[0129] The data cache module 14 is used to store the to-be-cached data in the target cache layer according to the cache policy corresponding to the target cache layer.
[0130] In one embodiment, the matching module 12 is further used to: match the data to be cached with the query statement in the local report system to obtain a matching result between the data to be cached and the temporary cache layer;
[0131] Matching the data to be cached with the key fields in the display interface provided by the local report system to obtain a matching result between the data to be cached and the key field cache layer;
[0132] Matching the data to be cached with each database in the local reporting system to obtain a matching result between the data to be cached and the database cache layer;
[0133] The data to be cached is matched with the shared data type in the local report system to obtain a matching result between the data to be cached and the global shared cache layer.
[0134] In one of the embodiments, the cache layer selection module 13 is further used to: if the matching result between the data to be cached and any data cache layer in the multiple data cache layers indicates a successful match, then use the data cache layer as the target cache layer corresponding to the data to be cached.
[0135] In one of the embodiments, the data cache module 14 is used to: determine the target cache duration and cache refresh frequency corresponding to the target cache layer according to the cache policy corresponding to the target cache layer;
[0136] The to-be-cached data is stored in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer.
[0137] In one of the embodiments, the device further includes an updating module, which is used to: determine the continued caching time for the data to be cached to continue to be stored in the target cache layer according to the access records and data weights of the data to be cached, and the access records and data weights of other cached data in the local reporting system; wherein the continued caching time is less than or equal to the target caching time;
[0138] Continuing to store the data to be cached in the target cache layer according to the continued cache duration and the cache refresh frequency corresponding to the target cache layer;
[0139] When the time period for storing the data to be cached in the target cache layer reaches the continued cache time period, the data to be cached is stored in the persistent storage space corresponding to the local reporting system.
[0140] In one embodiment, multiple data cache layers correspond to different priorities respectively; the data cache module 14 is further used to: obtain configuration parameters of the target cache layer;
[0141] If it is determined according to the configuration parameters that the target cache layer has a corresponding cache strategy, then storing the data to be cached in the target cache layer according to the cache strategy corresponding to the target cache layer;
[0142] If it is determined according to the configuration parameters that there is no corresponding cache strategy for the target cache layer, then according to the priorities corresponding to the data cache layers, the upper-level data cache layer corresponding to the target cache layer is selected from multiple data cache layers, and the cache strategy corresponding to the upper-level data cache layer is used as the cache strategy corresponding to the target cache layer, and according to the cache strategy corresponding to the target cache layer, the data to be cached is stored in the target cache layer.
[0143] Each module in the above data cache device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0144] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 8 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a data caching method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0145] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0146] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0147] Get the data to be cached;
[0148] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0149] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0150] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0151] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0152] Get the data to be cached;
[0153] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0154] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0155] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0156] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0157] Get the data to be cached;
[0158] Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers include at least a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer;
[0159] According to each matching result, selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers;
[0160] According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
[0161] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0162] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are 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 application.
[0163] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data storage method, characterized in that: The method comprises: Get the data to be cached; Determine the matching result between the data to be cached and multiple data cache layers corresponding to the local report system; wherein the multiple data cache layers at least include a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer; According to each matching result, selecting a target cache layer corresponding to the data to be cached from multiple data cache layers; According to the cache policy corresponding to the target cache layer, the to-be-cached data is stored in the target cache layer.
2. The method according to claim 1, characterized in that The determining of the matching result between the data to be cached and the multiple data cache layers corresponding to the local report system includes: Matching the data to be cached with the query statement in the local report system to obtain a matching result between the data to be cached and the temporary cache layer; Matching the data to be cached with the key fields in the display interface provided by the local report system to obtain a matching result between the data to be cached and the key field cache layer; Matching the data to be cached with each database in the local reporting system to obtain a matching result between the data to be cached and the database cache layer; The data to be cached is matched with the shared data type in the local report system to obtain a matching result between the data to be cached and the global shared cache layer.
3. The method according to claim 1, characterized in that The step of selecting a target cache layer corresponding to the to-be-cached data from multiple data cache layers according to each matching result includes: If the matching result between the data to be cached and any data cache layer in the multiple data cache layers indicates a successful match, the data cache layer is used as the target cache layer corresponding to the data to be cached.
4. The method according to claim 1, characterized in that: The storing the to-be-cached data in the target cache layer according to the cache policy corresponding to the target cache layer includes: Determine the target cache duration and cache refresh frequency corresponding to the target cache layer according to the cache strategy corresponding to the target cache layer; The to-be-cached data is stored in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer.
5. The method according to claim 4, characterized in that After storing the to-be-cached data in the target cache layer according to the target cache duration and cache refresh frequency corresponding to the target cache layer, the method further includes: Determine the continued caching time for the data to be cached to continue to be stored in the target cache layer according to the access records and data weight of the data to be cached, and the access records and data weight of other cached data in the local report system; wherein the continued caching time is less than or equal to the target caching time; Continuing to store the data to be cached in the target cache layer according to the continued cache duration and the cache refresh frequency corresponding to the target cache layer; When the time period for storing the data to be cached in the target cache layer reaches the continued cache time period, the data to be cached is stored in the persistent storage space corresponding to the local reporting system.
6. The method according to claim 1, characterized in that The plurality of data cache layers correspond to different priorities respectively; storing the data to be cached in the target cache layer according to the cache strategy corresponding to the target cache layer comprises: Obtaining configuration parameters of the target cache layer; If it is determined according to the configuration parameters that the target cache layer has a corresponding cache strategy, then storing the to-be-cached data in the target cache layer according to the cache strategy corresponding to the target cache layer; If it is determined according to the configuration parameters that there is no corresponding cache strategy for the target cache layer, then according to the priorities corresponding to the data cache layers, the upper-level data cache layer corresponding to the target cache layer is selected from multiple data cache layers, and the cache strategy corresponding to the upper-level data cache layer is used as the cache strategy corresponding to the target cache layer, and according to the cache strategy corresponding to the target cache layer, the data to be cached is stored in the target cache layer.
7. A data cache device, characterized in that: The device comprises: An acquisition module is used to obtain data to be cached; A matching module, used to determine the matching results between the data to be cached and multiple data cache layers corresponding to the local reporting system; wherein the multiple data cache layers at least include a temporary cache layer, a key field cache layer, a database cache layer and a global shared cache layer; A cache layer selection module, used to select a target cache layer corresponding to the data to be cached from multiple data cache layers according to each matching result; The data cache module is used to store the data to be cached in the target cache layer according to the cache policy corresponding to the target cache layer.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.