Data caching strategy determination method and device, storage medium, electronic equipment and product
By analyzing the relationship between user requests and the time set of cached data in the system, and dynamically optimizing the data caching strategy, the problem of low database query efficiency in traditional risk performance assessment systems is solved. This enables efficient access to and processing of risk performance assessment data across different time dimensions, thereby improving system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional risk performance assessment systems suffer from low database query efficiency when processing large-scale historical data, resulting in limited system response speed and computing power. Existing technologies have failed to effectively optimize data caching strategies to improve the efficiency of accessing different time dimensions.
By analyzing the set relationship between the time range of user requests and the time range of data already cached by the system, the data caching strategy is dynamically determined, including relationships such as difference, intersection, and superset, and the data caching strategy is optimized to reduce database access.
It improves the efficiency of accessing risk performance assessment data, reduces the number of database accesses, enhances system response speed and resource utilization, and ensures the accuracy of data processing and system stability.
Smart Images

Figure CN121807911A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial risk management technology, and more specifically, to a method, apparatus, storage medium, electronic device, and product for determining a data caching strategy. Background Technology
[0002] In modern financial risk management, risk performance assessment has become an indispensable part of measuring portfolio performance, predicting market trends, and formulating investment strategies. This process heavily relies on in-depth analysis of historical data, particularly a range of complex financial indicators such as portfolio returns, volatility, tracking error, and information ratios. With the rapid development of financial markets and the advent of the big data era, financial institutions process and analyze massive amounts of historical data daily. Traditional risk performance assessment systems use databases as the primary data storage and management system, where data read and write operations become bottlenecks. When processing large-scale historical data, the efficiency of database queries directly impacts the overall system response speed and computing power. Especially when calculating multiple indicators for the same portfolio across different time windows, frequent and repeated database accesses consume significant time and computing resources.
[0003] Therefore, in related technologies, no effective solution has yet been proposed for how to optimize data caching strategies to efficiently process and quickly access risk performance assessment data across different time dimensions. Summary of the Invention
[0004] This application provides a method, apparatus, storage medium, electronic device, and product for determining a data caching strategy, to at least address the problem in the related art of how to optimize a data caching strategy to efficiently process and quickly access risk performance assessment data across different time dimensions.
[0005] According to one embodiment of this application, a method for determining a data caching strategy is provided, comprising: obtaining a first time range corresponding to first data used for risk performance assessment, and a second time range corresponding to second data already cached in the risk performance system; determining a time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection; and determining a caching strategy for the first data based on the time set relationship.
[0006] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: calculating the difference between the first time range and the second time range when the time set relationship indicates that the first time range is a superset of the second time range, and obtaining a difference calculation result, wherein the difference calculation result includes: a first difference from the start time of the first time range to the start time of the second time range and / or a second difference from the end time of the second time range to the end time of the first time range; determining a third time range based on the difference calculation result, and obtaining the third data corresponding to the third time range from a preset database; and caching the merged fourth data after merging the third data and the time range identifier corresponding to the cached fourth data to the first time range.
[0007] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: calculating the intersection time range of the first time range and the second time range when the time set relationship indicates that there is an intersection between the first time range and the second time range, wherein the intersection time range includes: a first intersection time range corresponding to the time start point of the first time range to the time end point of the second time range, or a second intersection time range corresponding to the time start point of the second time range to the time end point of the first time range; determining a non-intersection time range of the first time range relative to the second time range based on the intersection time range, and obtaining the fifth data corresponding to the non-intersection time range from a preset database; caching the fifth data and the second data after merging them, and updating the time range identifier corresponding to the cached sixth data to the union of the first time range and the second time range.
[0008] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: when the time set relationship indicates that the first time range and the second time range do not intersect, retrieving the first data corresponding to the first time range from a preset database and updating the time range identifiers corresponding to the cached first data and the second data to the first time range and the second time range; when the time set relationship indicates that the first time range is a subset of the second time range, retrieving the first data corresponding to the first time range from the second data.
[0009] In an exemplary embodiment, determining the time set relationship between a first time range and a second time range includes: determining a first moment corresponding to the start of time in the first time range, a second moment corresponding to the end of time in the first time range, a third moment corresponding to the start of time in the second time range, and a fourth moment corresponding to the end of time in the second time range; if the second moment is less than the third moment or the fourth moment is less than the first moment, determining that the time set relationship is that the first time range and the second time range have no intersection; if the first moment is less than or equal to the third moment and the second moment is less than or equal to the fourth moment, determining that the time set relationship is that the first time range is a subset of the second time range; if the first moment is greater than or equal to the third moment and the second moment is greater than or equal to the fourth moment, determining that the time set relationship is that the first time range is a superset of the second time range; and if the first moment is less than the third moment and the second moment is greater than the third moment, determining that the time set relationship is that the first time range and the second time range have an intersection.
[0010] In an exemplary embodiment, before determining the time set relationship between the first time range and the second time range, the method further includes: checking whether the time formats of the first time range and the second time range are consistent; if the time formats are inconsistent, processing the time formats, wherein the processing includes: converting the timestamps of the first time range and the second time range into a unified time format; adjusting the time zones of the first time range and the second time range; aligning the precision of the first time range and the second time range; and determining the time set relationship between the first time range and the second time range if the time formats are consistent.
[0011] According to another aspect of the embodiments of this application, a data caching strategy determination apparatus is also provided, comprising: an acquisition module, configured to acquire a first time range corresponding to first data used for risk performance assessment, and a second time range corresponding to second data already cached in the risk performance system; a first determination module, configured to determine a time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection; and a second determination module, configured to determine a caching strategy for the first data based on the time set relationship.
[0012] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described method for determining the data caching strategy at runtime.
[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for determining the data caching strategy through the computer program.
[0014] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program and a method for determining the above-mentioned data caching strategy when the computer program is executed by a processor.
[0015] In this embodiment, a first time range corresponding to first data used for risk performance assessment and a second time range corresponding to second data already cached in the risk performance system are obtained. A time set relationship between the first and second time ranges is determined, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first and second time ranges intersect, or the first and second time ranges do not intersect. A caching strategy for the first data is determined based on the time set relationship. This technical solution solves the problem of how to optimize data caching strategies to efficiently process and quickly access risk performance assessment data across different time dimensions. Furthermore, by analyzing the set relationship between the time range corresponding to the first data requested by the user and the time range of the second data already cached in the system, the optimal caching strategy for the first data is dynamically determined, thereby efficiently meeting the data requirements in risk performance assessment, reducing database access, and improving system response speed and resource utilization. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the hardware environment for a method of determining a data caching strategy according to an embodiment of this application;
[0019] Figure 2 This is a flowchart of a method for determining a data caching strategy according to an embodiment of this application;
[0020] Figure 3 This is a schematic diagram of a caching process based on risk performance assessment data according to an embodiment of this application;
[0021] Figure 4 This is a schematic diagram of a processing flow under different relationships between the data request time range and the cached data time range according to an embodiment of this application;
[0022] Figure 5 This is a structural block diagram of a data caching strategy determination device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, apparatus, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, apparatus, or devices.
[0025] According to one aspect of the embodiments of this application, a method for determining a data caching strategy is provided. This method for determining a data caching strategy is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned method for determining a data caching strategy can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. Figure 1 This is a schematic diagram of the hardware environment for a method of determining a data caching strategy according to an embodiment of this application, as shown below. Figure 1As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0026] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0027] This embodiment provides a method for determining a data caching strategy, applied to the aforementioned terminal device. Figure 2 This is a flowchart of a method for determining a data caching strategy according to an embodiment of this application. The process includes the following steps:
[0028] Step S202: Obtain the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system;
[0029] Step S204: Determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, or the first time range and the second time range do not have an intersection.
[0030] Step S206: Determine the caching strategy for the first data based on the time set relationship.
[0031] Through the above steps, a first time range corresponding to the first data used for risk performance assessment and a second time range corresponding to the second data already cached in the risk performance system are obtained; the time set relationship between the first time range and the second time range is determined, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, or the first time range and the second time range do not have an intersection; and a caching strategy for the first data is determined based on the time set relationship. This technical solution solves the problem of how to optimize data caching strategies to efficiently process and quickly access risk performance assessment data with different time dimensions. Furthermore, by analyzing the set relationship between the time range corresponding to the first data requested by the user and the time range of the second data already cached in the system, the optimal caching strategy for the first data is dynamically determined, thereby efficiently meeting the data requirements in risk performance assessment, reducing database access, and improving system response speed and resource utilization.
[0032] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: calculating the difference between the first time range and the second time range when the time set relationship indicates that the first time range is a superset of the second time range, and obtaining a difference calculation result, wherein the difference calculation result includes: a first difference from the start time of the first time range to the start time of the second time range and / or a second difference from the end time of the second time range to the end time of the first time range; determining a third time range based on the difference calculation result, and obtaining the third data corresponding to the third time range from a preset database; and caching the merged fourth data after merging the third data and the time range identifier corresponding to the cached fourth data to the first time range.
[0033] Optionally, suppose the risk performance system initially caches valuation data for a portfolio from January 1, 2022 to December 31, 2022 (second time range). Then, it receives a new request to calculate the portfolio's volatility and Sharpe ratio from October 1, 2021 to March 1, 2023 (first time range). Clearly, the new request's time range covers the original cached data's time range. First, the difference between the two time ranges is calculated, resulting in two sets of differences: a first set of differences for October 1, 2021 to January 1, 2022, and a second set of differences for December 31, 2022 to March 1, 2023. Then, based on these two sets of differences, data for the missing time periods is retrieved from a pre-defined database to form third data (i.e., valuation data for October 1, 2021 to January 1, 2022 and December 31, 2022 to March 1, 2023). Next, the third data is merged with the cached second data to generate fourth data covering the period from October 1, 2021 to March 1, 2023. Finally, the newly generated fourth data is cached, and its time range is updated to October 1, 2021 to March 1, 2023. Through these implementation steps, new requests can be responded to quickly without reloading 2022 data from the database. Furthermore, the updated cached data can be immediately used by subsequent requests, such as other risk indicators calculated from August 1, 2022 to January 1, 2023. These requests can directly utilize data from October 2021 to January 2022 and December 2022 to March 2023 without additional database queries, improving data access efficiency, reducing system latency, and alleviating database pressure.
[0034] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: calculating the intersection time range of the first time range and the second time range when the time set relationship indicates that there is an intersection between the first time range and the second time range, wherein the intersection time range includes: a first intersection time range corresponding to the time start point of the first time range to the time end point of the second time range, or a second intersection time range corresponding to the time start point of the second time range to the time end point of the first time range; determining a non-intersection time range of the first time range relative to the second time range based on the intersection time range, and obtaining the fifth data corresponding to the non-intersection time range from a preset database; caching the fifth data and the second data after merging them, and updating the time range identifier corresponding to the cached sixth data to the union of the first time range and the second time range.
[0035] Optionally, assume the risk performance system has cached detailed valuation data for a portfolio from January 1, 2023 to June 30, 2023 (second time frame). A new request is then received asking for analysis of the return and maximum drawdown from December 1, 2022 to June 15, 2023 (first time frame). First, the intersection of the two time frames is calculated and determined as January 1, 2023 to June 15, 2023 (first intersection time frame). Next, the non-intersecting time frames are identified as December 1, 2022 to January 1, 2023 (first non-intersecting time frame) and June 15, 2023 to June 30, 2023 (second non-intersecting time frame). Next, data from two non-overlapping time ranges are selectively retrieved from the database: data from December 1, 2022 to January 1, 2023, and data from June 15, 2023 to June 30, 2023, forming the fifth set of data. This fifth set of data is then merged with the previously cached second set of data to obtain the sixth set of data, covering the time range from December 1, 2022 to June 30, 2023. The sixth set of data is then cached, and its time range identifier is updated to this new union time range. This implementation reduces reliance on the database, thus alleviating the database load.
[0036] In an exemplary embodiment, determining a caching strategy for the first data based on a time set relationship includes: when the time set relationship indicates that the first time range and the second time range do not intersect, retrieving the first data corresponding to the first time range from a preset database and updating the time range identifiers corresponding to the cached first data and the second data to the first time range and the second time range; when the time set relationship indicates that the first time range is a subset of the second time range, retrieving the first data corresponding to the first time range from the second data.
[0037] Optionally, assume the risk performance system has cached valuation data for a portfolio from January 1, 2023 to June 30, 2023 (second time range). Subsequently, a new request is received asking for volatility and maximum drawdown data for the portfolio from July 1, 2022 to December 31, 2022 (first time range). Since these two time ranges do not overlap, data from July 1, 2022 to December 31, 2022 (first data) is directly retrieved from the preset database. The newly retrieved first data is cached, and the cached time range identifiers are updated to include both the existing data range from January to June 2023 and the newly added data range from July to December 2022.
[0038] Optionally, in another scenario, suppose the risk performance system has cached comprehensive data for a portfolio from January 1, 2023 to December 31, 2023 (second time range). Subsequently, a request is received for return and information ratio data from April 1, 2023 to October 31, 2023 (first time range). It is recognized that the first time range is a subset of the second time range, meaning all required valuation data is already cached. Therefore, data for this period is directly retrieved from the cache for calculations without accessing the database again. Since the first data can be directly obtained from the second data, there is no need to supplement data from the database, and therefore no need to update the cached time range identifier. This maintains the stability of the cache structure and the integrity of existing data.
[0039] The above embodiments not only optimize the efficiency of high-frequency, multi-dimensional data access but also ensure the accuracy of data processing and the stability of system operation. Whether processing completely independent time-period data or quickly responding to needs within a subset of time ranges, this caching strategy demonstrates its flexibility and efficiency.
[0040] In an exemplary embodiment, determining the time set relationship between a first time range and a second time range includes: determining a first moment corresponding to the start of time in the first time range, a second moment corresponding to the end of time in the first time range, a third moment corresponding to the start of time in the second time range, and a fourth moment corresponding to the end of time in the second time range; if the second moment is less than the third moment or the fourth moment is less than the first moment, determining that the time set relationship is that the first time range and the second time range have no intersection; if the first moment is less than or equal to the third moment and the second moment is less than or equal to the fourth moment, determining that the time set relationship is that the first time range is a subset of the second time range; if the first moment is greater than or equal to the third moment and the second moment is greater than or equal to the fourth moment, determining that the time set relationship is that the first time range is a superset of the second time range; and if the first moment is less than the third moment and the second moment is greater than the third moment, determining that the time set relationship is that the first time range and the second time range have an intersection.
[0041] Optionally, assume the risk performance system has cached detailed performance data for a stock portfolio from January 1, 2023 to June 30, 2023 (time point three to time point four). Now, a request is received asking for the portfolio's return and maximum drawdown data from July 1, 2022 to December 31, 2022 (time point one to time point two). First, comparing the time points, it is found that time point two (December 31, 2022) is earlier than time point three (January 1, 2023), indicating that the two time ranges do not overlap.
[0042] Understandably, if we have stock portfolio data from January 1, 2022 to December 31, 2022 (time point three to time point four), and suddenly receive a request for volatility and Sharpe ratio data for that portfolio from April 1, 2022 to October 1, 2022 (time point one to time point two), by comparing the time points, we can determine that time point one (April 1, 2022) is later than or equal to time point three (January 1, 2022), and time point two (October 1, 2022) is earlier than or equal to time point four (December 31, 2022), thus establishing that time point one is a subset of time point two.
[0043] In other words, if the system already has stock portfolio data from January 1, 2022 to June 30, 2023 (time 3 to time 4), and a request now asks for specific financial indicators from March 1, 2022 to September 1, 2023 (time 1 to time 2), then if time 1 (March 1, 2022) is later than or equal to time 3 (January 1, 2022), and time 2 (September 1, 2023) is later than time 4 (June 30, 2023), then the first time range is determined to be a superset of the second time range.
[0044] The above embodiments, through detailed time-point comparisons and intelligent data acquisition strategies, can significantly improve the efficiency and accuracy of data processing, while reducing computing costs and improving the overall performance of the system.
[0045] In an exemplary embodiment, before determining the time set relationship between the first time range and the second time range, the method further includes: checking whether the time formats of the first time range and the second time range are consistent; if the time formats are inconsistent, processing the time formats, wherein the processing includes: converting the timestamps of the first time range and the second time range into a unified time format; adjusting the time zones of the first time range and the second time range; aligning the precision of the first time range and the second time range; and determining the time set relationship between the first time range and the second time range if the time formats are consistent.
[0046] Optionally, suppose the risk performance system needs to process time-range data from two different data sources, each representing the return of a portfolio. Data source A's time range is from "2023-01-01T00:00:00Z" to "2023-06-30T23:59:59Z", while data source B's time range is recorded as "Jan 1, 2023 12:00 AM GMT+08:00" to "Jul 1, 2023 11:59 PM GMT+08:00". First, check the time formats of these two time ranges. It is found that data source A uses ISO 8601 format, while data source B uses natural language format. Therefore, the timestamps of data source B need to be converted to ISO 8601 format to achieve format consistency. Next, considering that data source B's time zone is offset by 8 hours from International Standard Time (UTC), the timestamp of data source B needs to be converted from GMT+08:00 to the zero time zone (i.e., UTC time) to eliminate the impact of time zone differences on the determination of time set relationships. Since the original data may have differences in precision—for example, data source A may record times in seconds, while data source B may record times in minutes—it is necessary to align the time precision of both to the same level to ensure the accuracy of subsequent calculations. Through a series of preprocessing and relationship determination steps, it is ensured that all time data reaches a consistent standard before processing, improving the accuracy and efficiency of data processing.
[0047] To better understand the process of determining the above data caching strategy, the following description, in conjunction with optional embodiments, further illustrates the process of determining the above data caching strategy, but is not intended to limit the technical solutions of the embodiments of this application.
[0048] In related technologies, for risk performance systems, additional storage hardware and software are required, increasing costs. Furthermore, the expiration time settings for hot data can only be adjusted based on experience, making it difficult to achieve a perfectly appropriate setting. Secondly, maintaining data consistency and up-to-date state in a distributed environment is complex, especially under unstable network conditions. Additional operational work is needed to manage the cluster and ensure synchronization and health of each node. Distributed caching also suffers from data migration issues; the data redistribution process when nodes join or leave can lead to temporary service interruptions or performance degradation. Moreover, while Flask's built-in caching mechanism can ensure fast access and operation of hot data by setting expiration times, these settings also rely on experience and cannot be perfectly tailored.
[0049] To address the aforementioned issues, this application proposes an optional embodiment of a caching method based on risk performance assessment data. This method intelligently determines the relationship between the data request and the cached data by accurately locating and analyzing the time dimension of the request, such as whether a subset, superset, or intersection exists. This determines whether to directly use the cached data or only supplement the missing parts of the requested data. This strategy reduces the number of database accesses, improving data processing efficiency and system response speed.
[0050] Optional, Figure 3 This is a schematic diagram of a caching process based on risk performance assessment data according to an embodiment of this application, specifically including the following steps:
[0051] Step 1: Data Acquisition and Caching. When a request for risk performance data is received for the first time, the request typically specifies a time range, such as from T1-START to T1-END. For this time range, a precise query command is sent directly to the database to retrieve detailed portfolio valuation data, which is the basis for calculating risk performance indicators. The retrieved data is then stored in the cache for subsequent requests with the same or related time ranges, reducing database load and response time.
[0052] Step Two: Determining the Smart Caching Strategy. For a new data request, first parse its time range (marked as T2-START to T2-END) and compare it with the time range of already cached data. For example... Figure 4 As shown, Figure 4 This is a schematic diagram illustrating a processing flow under different relationships between data request time range and cached data time range according to an embodiment of this application, specifically including the following:
[0053] (1) If the time range of T2 is completely within the time range of T1, that is, the time range of T2 is a subset of the time range of T1, the required combined data will be directly extracted from the cache for calculation without accessing the database again.
[0054] (2) If the time range of T2 covers the time range of T1 (i.e., the time range of T2 is a superset of the time range of T1), but T2 has a part that exceeds T1, only this part of the new data will be obtained and merged with the existing cached data. Then the time range identifier in the cache will be updated to cover a wider range of time periods.
[0055] (3) If the time range of T1 and the time range of T2 overlap, the data outside the overlap is also obtained and integrated into the cache. At the same time, the time range of the cache is corrected to ensure that it covers the complete data set.
[0056] (4) If the time range of T1 and the time range of T2 do not intersect, then the data within the time range of T2 will be obtained separately, stored in the cache, and the time range identifier in the cache will be updated.
[0057] Step 3: Data Integration and Update. When data in the cache needs to be updated, the system can efficiently merge the new data with the existing cached data, while simultaneously adjusting the time range identifier to ensure that the cached data covers the latest time interval and that the data maintains consistency and integrity.
[0058] Step 4: Data Cache Cleanup. After each request is processed, the system follows explicit rules to clean up the cache, releasing data that is no longer needed. This prevents excessive consumption of memory resources, maintains system stability and security, and avoids potential memory leaks.
[0059] In summary, this application introduces an intelligent caching mechanism to dynamically adjust data storage and usage based on different time-dimensional requirements. This strategy not only considers data validity but also significantly improves system response speed and resource utilization by avoiding unnecessary database requests. Facing various possible time-dimensional changes, this application reduces redundant data readings and enhances system flexibility and efficiency by identifying data reuse opportunities (e.g., subset relationships), determining missing data parts (e.g., superset and intersection cases), and handling data requirements for completely independent time periods. When supplementary data is needed, an integration and update strategy merges newly acquired data with existing cached data while updating the time range identifier in the cache to reflect the latest data coverage interval. This method ensures data consistency and integrity while simplifying data management complexity. Furthermore, this application clearly defines the data cache lifecycle and specifies rules for clearing the cache at the end of each request. This mechanism helps prevent memory leaks and ensures the long-term stability and security of the system.
[0060] Through the above description of the embodiments, those skilled in the art can clearly understand that the method for determining the data caching strategy according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software device. This computer software device is stored in a storage medium (such as ROM / RAM, disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the method for determining the data caching strategy of the various embodiments of this application.
[0061] This embodiment also provides a data caching strategy determination device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0062] Figure 5 This is a structural block diagram of a data caching strategy determination device according to an embodiment of this application; as shown... Figure 5 As shown, it includes:
[0063] The acquisition module 52 is used to acquire the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system;
[0064] The first determining module 54 is used to determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection.
[0065] The second determining module 56 is used to determine the caching strategy of the first data based on the time set relationship.
[0066] Using the aforementioned apparatus, a first time range corresponding to first data used for risk performance assessment and a second time range corresponding to second data already cached in the risk performance system are obtained. A time set relationship between the first and second time ranges is determined, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range intersects with the second time range, or the first and second time ranges do not intersect. A caching strategy for the first data is determined based on the time set relationship. This technical solution addresses the problem of how to optimize data caching strategies to efficiently process and quickly access risk performance assessment data across different time dimensions. Furthermore, by analyzing the set relationship between the time range corresponding to the first data requested by the user and the time range of the second data already cached in the system, the optimal caching strategy for the first data is dynamically determined, thereby efficiently meeting the data requirements in risk performance assessment, reducing database access, and improving system response speed and resource utilization.
[0067] In an exemplary embodiment, the second determining module is further configured to calculate the difference between the first time range and the second time range when the time set relationship indicates that the first time range is a superset of the second time range, and obtain a difference calculation result, wherein the difference calculation result includes: a first difference from the start time of the first time range to the start time of the second time range and / or a second difference from the end time of the second time range to the end time of the first time range; determine a third time range based on the difference calculation result, and obtain the third data corresponding to the third time range from a preset database; and, if the third data and the second data are merged, cache the merged fourth data and update the time range identifier corresponding to the cached fourth data to the first time range.
[0068] In an exemplary embodiment, the second determining module is further configured to calculate the intersection time range of the first time range and the second time range when the time set relationship indicates that there is an intersection between the first time range and the second time range, wherein the intersection time range includes: a first intersection time range corresponding to the time start point of the first time range to the time end point of the second time range or a second intersection time range corresponding to the time start point of the second time range to the time end point of the first time range; determine the non-intersection time range of the first time range relative to the second time range based on the intersection time range, and obtain the fifth data corresponding to the non-intersection time range from a preset database; merge the fifth data and the second data and cache them, and update the time range identifier corresponding to the cached sixth data to the union of the first time range and the second time range.
[0069] In an exemplary embodiment, the second determining module is further configured to: obtain first data corresponding to the first time range from a preset database when the time set relationship indicates that the first time range and the second time range do not intersect, and update the time range identifiers corresponding to the cached first data and the second data to the first time range and the second time range; and obtain first data corresponding to the first time range from the second data when the time set relationship indicates that the first time range is a subset of the second time range.
[0070] In an exemplary embodiment, the first determining module is further configured to determine a first moment corresponding to the start of the first time range, a second moment corresponding to the end of the first time range, a third moment corresponding to the start of the second time range, and a fourth moment corresponding to the end of the second time range; if the second moment is less than the third moment or the fourth moment is less than the first moment, determine that the time set relationship is that the first time range and the second time range have no intersection; if the first moment is less than or equal to the third moment and the second moment is less than or equal to the fourth moment, determine that the time set relationship is that the first time range is a subset of the second time range; if the first moment is greater than or equal to the third moment and the second moment is greater than or equal to the fourth moment, determine that the time set relationship is that the first time range is a superset of the second time range; and if the first moment is less than the third moment and the second moment is greater than the third moment, determine that the time set relationship is that the first time range and the second time range have an intersection.
[0071] In one exemplary embodiment, the apparatus further includes: a checking module, configured to check whether the time formats of the first time range and the second time range are consistent before determining the time set relationship between the first time range and the second time range; if the time formats are inconsistent, to process the time formats, wherein the processing includes: converting the timestamps of the first time range and the second time range into a unified time format; adjusting the time zones of the first time range and the second time range; aligning the precision of the first time range and the second time range; and determining the time set relationship between the first time range and the second time range if the time formats are consistent.
[0072] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes the method for determining any of the above-described data caching strategies when it runs.
[0073] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0074] S1, obtain the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system;
[0075] S2, determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection;
[0076] S3, determine the caching strategy for the first data based on the time set relationship.
[0077] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0078] Embodiments of this application also provide a computer program product, including a computer program, wherein the computer program, when executed by a processor, performs the steps in any of the above method embodiments.
[0079] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0080] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0081] S1, obtain the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system;
[0082] S2, determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection;
[0083] S3, determine the caching strategy for the first data based on the time set relationship.
[0084] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical discs.
[0085] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0086] The collection, storage, use, processing, transmission, provision, and disclosure of financial data or user data involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0087] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0088] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0089] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for determining a data caching strategy, characterized in that, include: Obtain the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system; Determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection; The caching strategy for the first data is determined based on the time set relationship.
2. The method for determining the data caching strategy according to claim 1, characterized in that, Determining the caching strategy for the first data based on the aforementioned time set relationship includes: When the time set relationship indicates that the first time range is a superset of the second time range, the difference between the first time range and the second time range is calculated to obtain the difference calculation result, wherein the difference calculation result includes: the first difference from the time start point of the first time range to the time start point of the second time range and / or the second difference from the time end point of the second time range to the time end point of the first time range; The third time range is determined based on the difference calculation result, and the third data corresponding to the third time range is obtained from the preset database. After merging the third data and the second data, the merged fourth data is cached, and the time range identifier corresponding to the cached fourth data is updated to the first time range.
3. The method for determining the data caching strategy according to claim 1, characterized in that, Determining the caching strategy for the first data based on the aforementioned time set relationship includes: When the time set relationship indicates that the first time range and the second time range have an intersection, the intersection time range of the first time range and the second time range is calculated, wherein the intersection time range includes: the first intersection time range corresponding to the time start point of the first time range to the time end point of the second time range or the second intersection time range corresponding to the time start point of the second time range to the time end point of the first time range; Based on the intersection time range, determine the non-intersection time range of the first time range relative to the second time range, and obtain the fifth data corresponding to the non-intersection time range from the preset database; The fifth data is merged with the second data and then cached. The time range identifier corresponding to the cached sixth data is updated to the union of the first time range and the second time range.
4. The method for determining the data caching strategy according to claim 1, characterized in that, Determining the caching strategy for the first data based on the aforementioned time set relationship includes: When the time set relationship indicates that the first time range and the second time range do not intersect, the first data corresponding to the first time range is obtained from the preset database, and the time range identifiers corresponding to the cached first data and the second data are updated to the first time range and the second time range. When the time set relationship indicates that the first time range is a subset of the second time range, the first data corresponding to the first time range is obtained from the second data.
5. The method for determining the data caching strategy according to claim 1, characterized in that, Determining the time set relationship between the first time range and the second time range includes: Determine the first moment corresponding to the start of the first time range, the second moment corresponding to the end of the first time range, the third moment corresponding to the start of the second time range, and the fourth moment corresponding to the end of the second time range; If the second time is less than the third time or the fourth time is less than the first time, the time set relationship is determined to be that the first time range and the second time range do not intersect. If the first time is less than or equal to the third time, and the second time is less than or equal to the fourth time, the time set relationship is determined to be that the first time range is a subset of the second time range; If the first time is greater than or equal to the third time, and the second time is greater than or equal to the fourth time, the time set relationship is determined to be that the first time range is a superset of the second time range; If the first time is less than the third time and the second time is greater than the third time, the time set relationship is determined to be that the first time range and the second time range have an intersection.
6. The method for determining the data caching strategy according to claim 1, characterized in that, Before determining the time set relationship between the first time range and the second time range, the method further includes: Check whether the time formats of the first time range and the second time range are consistent; In the event of inconsistent time formats, the time formats are processed, wherein the processing includes: converting the timestamps of the first time range and the second time range into a unified time format; adjusting the time zones of the first time range and the second time range; and aligning the precision of the first time range and the second time range. Given that the time formats are consistent, the time set relationship between the first time range and the second time range is determined.
7. A device for determining a data caching strategy, characterized in that, include: The acquisition module is used to acquire the first time range corresponding to the first data used for risk performance assessment, and the second time range corresponding to the second data cached in the risk performance system. The first determining module is used to determine the time set relationship between the first time range and the second time range, wherein the time set relationship includes at least one of the following: the first time range is a subset of the second time range, the first time range is a superset of the second time range, the first time range and the second time range have an intersection, and the first time range and the second time range do not have an intersection. The second determining module is used to determine the caching strategy for the first data based on the time set relationship.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for determining the data caching strategy according to any one of claims 1 to 6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for determining the data caching strategy according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for determining the data caching strategy as described in any one of claims 1 to 6.