A data caching method and apparatus
By acquiring the characteristic parameters of the data to configure the replacement priority of data in the cache space, the problem of optimizing the data lifecycle when the cache space is insufficient is solved, and the performance and utilization of the cache are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SMARTER SILICON (SHANGHAI) TECH CO LTD
- Filing Date
- 2023-10-31
- Publication Date
- 2026-07-03
AI Technical Summary
How to improve the performance of caching, especially optimizing the lifecycle of data in the cache when cache space is insufficient.
By acquiring the characteristic parameters of the data, configuring the replacement priority parameters of each data in the cache space, determining the priority of data replacement when the cache space is insufficient based on the data type and priority parameters, and optimizing the lifecycle of data in the cache space.
It improves cache performance, optimizes cache space utilization, and meets the processor's actual data usage needs.
Smart Images

Figure CN117251485B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data caching method and apparatus. Background Technology
[0002] With the development of computer technology, more and more data processing needs to be implemented based on caching. However, how to improve the performance of caching has become a problem. Summary of the Invention
[0003] This application provides the following technical solution:
[0004] This application provides a data caching method, including:
[0005] In response to the processor's first cached data request, the feature parameters of the first data corresponding to the first cached data request are obtained from the first cached data request;
[0006] If, based on the characteristic parameters of the first data, it is determined that the first data needs to be cached, the first data is read from the memory and cached into the cache space;
[0007] Based on the feature parameters of the first data, a replacement priority parameter is configured for each data in the cache space. The replacement priority parameter is used to characterize the priority of the data being replaced in the cache space when the cache space is insufficient.
[0008] The characteristic parameters of the first data include:
[0009] The first data is either a data type or a data priority parameter.
[0010] Based on the feature parameters of the first data, configure the replacement priority parameters corresponding to each data in the cache space, including:
[0011] Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0012] The method further includes:
[0013] Determine the usage factor corresponding to each data type in the cache space, wherein the usage factor characterizes the degree of data usage demand of the processor for the data type.
[0014] Based on the usage factor corresponding to each data type in the cache space, update the replacement priority parameter corresponding to each data type in the cache space;
[0015] Alternatively, based on the usage factor corresponding to each data type in the cache space, update the data priority parameter corresponding to each data type in the cache space to obtain a new data priority parameter corresponding to each data type in the cache space, so that the alternative priority parameter corresponding to the data type can be configured subsequently based on the new data priority parameter.
[0016] Based on the usage factor corresponding to each data type in the cache space, update the replacement priority parameter corresponding to each data type in the cache space, including:
[0017] Based on the usage factor corresponding to each data type in the cache space, the candidate replacement priority parameter corresponding to each data type in the cache space is determined, wherein the higher the usage factor, the lower the candidate replacement priority parameter.
[0018] Replace or modify the alternative priority parameter based on the candidate alternative priority parameter;
[0019] Alternatively, if based on the usage factor corresponding to the data type in the cache space, it is determined that the data corresponding to the data type no longer needs to be cached in the cache space, the substitution priority parameter corresponding to the data type in the cache space is canceled, and if the data type meets the set conditions, the data corresponding to the data type will no longer be cached in the cache space.
[0020] Subsequently, based on the new data priority parameter, the corresponding alternative priority parameter for the data type is configured, including:
[0021] If the data priority parameter of the first data is inconsistent with the new data priority parameter corresponding to the data type of the first data, the historical replacement priority parameter corresponding to each data type in the cache space is updated based on the new data priority parameter. The historical replacement priority parameter corresponding to each data type in the cache space is the one previously configured based on the data type and data priority parameter of the first data.
[0022] Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space, including:
[0023] The initial replacement priority parameters for each data type in the cache space are determined based on the target caching strategy.
[0024] If the initial substitution priority parameters of the data types in the cache space are consistent with the high-low relationship between the data type and the data type of the first data, and the data priority parameters are consistent, the initial substitution priority parameters of the data types in the cache space are adjusted to obtain the substitution priority parameters of the data types in the cache space; wherein, the substitution priority parameter of the data type of the first data is lower than the initial substitution priority parameter of the data type of the first data.
[0025] Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space, including:
[0026] Based on the data type and data priority parameters of the first data, update the data priority parameters of each data type in the cache space to obtain the updated data priority parameters of each data type in the cache space;
[0027] Based on the updated data priority parameters of each data type in the cache space, the replacement priority parameters corresponding to each data type in the cache space are determined, wherein the higher the data priority parameter, the lower the replacement priority parameter.
[0028] The data caching method further includes:
[0029] In response to a second cached data request from the processor, second data is retrieved from the memory, and if the cache space is insufficient, the data types that can be replaced in the cache space are determined.
[0030] Select the data type with the highest replacement priority parameter from the list of replaceable data types;
[0031] Alternatively, the second data can be cached using the cache area corresponding to the data type with the highest substitution priority parameter, or the data with the highest substitution priority parameter can be selected from the data of the data type with the highest substitution priority parameter, and the second data can be cached using the cache area corresponding to the data with the highest substitution priority parameter.
[0032] Another aspect of this application provides a data caching device, comprising:
[0033] The acquisition module is used to, in response to a first cached data request from the processor, acquire the feature parameters of the first data corresponding to the first cached data request from the first cached data request;
[0034] The caching module is used to read the first data from the memory and cache it into the cache space if it is determined that the first data needs to be cached based on the feature parameters of the first data;
[0035] The configuration module is used to configure the replacement priority parameters corresponding to each data in the cache space based on the feature parameters of the first data. The replacement priority parameters are used to characterize the priority of the data being replaced in the cache space when the cache space is insufficient. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart illustrating a data caching method provided in Embodiment 1 of this application;
[0038] Figure 2 This is a flowchart illustrating a data caching method provided in Embodiment 2 of this application;
[0039] Figure 3 This is a flowchart illustrating a data caching method provided in Embodiment 3 of this application;
[0040] Figure 4 This is a flowchart illustrating a data caching method provided in Embodiment 4 of this application;
[0041] Figure 5 This is a flowchart illustrating a data caching method provided in Embodiment 6 of this application;
[0042] Figure 6 This is a flowchart illustrating a data caching method provided in Embodiment 7 of this application;
[0043] Figure 7 This is a schematic diagram illustrating an implementation method for determining the initial replacement priority parameter based on a target caching strategy provided in this application;
[0044] Figure 8 This is a flowchart illustrating a data caching method provided in Embodiment 10 of this application;
[0045] Figure 9 This is a flowchart illustrating a data caching method provided in Embodiment 11 of this application;
[0046] Figure 10 This is a schematic diagram of the structure of a data caching device provided in this application. Detailed Implementation
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0049] Reference Figure 1 This is a flowchart illustrating a data caching method provided in Embodiment 1 of this application, as shown below. Figure 1 As shown, the method may include, but is not limited to, the following steps:
[0050] Step S101: In response to the processor's first cache data request, obtain the feature parameters of the first data corresponding to the first cache data request from the first cache data request.
[0051] In this embodiment, if the processor requests to cache the first data, it can determine the characteristic parameters of the first data and send a first cache data request containing the characteristic parameters of the first data to the system cache.
[0052] The characteristic parameters of the first data can be used to assist the system cache in caching.
[0053] The processor can be of any type and is not limited thereto in this application. For example, the processor may include, but is not limited to, a graphics processing unit (GPU).
[0054] The first cache data request can be, but is not limited to, a write data request or a read data request. For example, if the first cache data request is a write data request and is used to request that the first data be cached, that is, the processor requests to write the first data to the cache space. Accordingly, the system cache can respond to the first cache data request by reading the first data from memory and caching it into the cache space.
[0055] The first data can be of any type, and there are no restrictions on this in this application.
[0056] Step S102: If it is determined that the first data needs to be cached based on the characteristic parameters of the first data, the first data is read from the memory and cached into the cache space.
[0057] Step S103: Based on the feature parameters of the first data, configure the replacement priority parameters corresponding to each data in the cache space. The replacement priority parameters are used to characterize the priority of data being replaced in the cache space when the cache space is insufficient.
[0058] In this embodiment, each piece of data in the cache space may include first data and other data besides the first data.
[0059] The replacement priority parameters for each piece of data in the cache space are different.
[0060] Based on the feature parameters of the first data and the corresponding replacement priority parameters of each data in the cache space, if new data needs to be cached and the cache space is insufficient, the system cache can determine the data in the cache space that can be replaced by the new data based on the configured replacement priority parameters of each data in the cache space. The higher the replacement priority parameter, the more preferentially the corresponding data in the cache space will be replaced.
[0061] In this embodiment, in response to the processor's first cached data request, if it is determined that the first data needs to be cached based on the cache parameters of the first cached data request, the first data is read from the memory and cached into the cache space. The feature parameters of the first data are obtained from the cached data request. Based on the feature parameters of the first data, the replacement priority parameters corresponding to each data in the cache space are configured. In the case of insufficient cache space, caching can be performed based on the configured replacement priority parameters corresponding to each data, thereby optimizing the lifecycle of each data in the cache and improving the performance of cache usage.
[0062] As another optional embodiment of this application, refer to Figure 2 This is a flowchart illustrating a data caching method provided in Embodiment 2 of this application. This embodiment mainly refines step S101 in Embodiment 1 above, such as... Figure 2 As shown, step S101 may include, but is not limited to, the following steps:
[0063] Step S1011: Obtain at least one of the data type and data priority parameters of the first data corresponding to the first cached data request from the first cached data request.
[0064] A specific implementation method in which at least one of the data type and data priority parameters of the first data is a characteristic parameter of the first data.
[0065] Data types can be used to reflect the data usage scenario corresponding to the first data. For example, if the data type of the first data is vertex data, it can reflect an image processing scenario where the data is used to determine the shape and position of an object; if the data type of the first data is texture data, it can reflect an image processing scenario where the data is used to achieve texture effects in an image.
[0066] The higher the data priority parameter, the higher the target usage frequency of the corresponding data. The target usage frequency may differ from the actual usage frequency; it can be the expected usage frequency of the data during data processing or a usage frequency determined based on the historical usage frequency of the data during data processing.
[0067] The less likely a data point is to be replaced in the cache, the better. Data priority parameters can be, but are not limited to, used to characterize the frequency of data usage.
[0068] For example, the corresponding feature parameters may include, but are not limited to, the data type of the first data. In step S102 of embodiment 1, the system cache determines whether the first data needs to be cached, which may include, but is not limited to, the system cache determining whether the data type of the first data meets the caching conditions (e.g., the data of this data type is not frequently modified).
[0069] Corresponding to step S1011, step S103 in the above embodiment 1 may include, but is not limited to:
[0070] Step S1031: Based on at least one of the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data in the cache space.
[0071] Step S1031 may include, but is not limited to:
[0072] Step S10311: Based on the data type of the first data, configure the replacement priority parameters corresponding to each data type in the cache space.
[0073] In step S10311, based on the data type of the first data, each data type in the cache space can be updated to obtain the updated data types in the cache space, and the replacement priority parameters corresponding to the updated data types in the cache space can be determined. The replacement priority parameters corresponding to each data type can be different from each other.
[0074] Step S1031 may also include, but is not limited to:
[0075] Step S10312: Based on the data priority parameters of the first data, configure the alternative priority parameters corresponding to each data in the cache space.
[0076] In step S10312, the substitution priority parameters corresponding to each data can be different from each other, wherein the higher the data priority parameter, the lower the substitution priority parameter.
[0077] Step S1031 may also include, but is not limited to:
[0078] Step S10313: Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0079] In step S10313, the substitution priority parameters corresponding to each data type are different from each other.
[0080] In this embodiment, in response to a first cached data request from the processor, if it is determined that the first data needs to be cached based on the cache parameters of the first cached data request, the first data is read from the memory and cached into the cache space. At least one of the data type and data priority parameters of the first data is obtained from the cached data request. Based on at least one of the data type and data priority parameters of the first data, alternative priority parameters corresponding to each data in the cache space are configured. In the case of insufficient cache space, caching can be performed based on the configured alternative priority parameters corresponding to each data, thereby optimizing the lifecycle of each data in the cache and improving the performance of cache usage.
[0081] As another optional embodiment of this application, refer to Figure 3 This is a flowchart illustrating a data caching method provided in Embodiment 3 of this application. Figure 3 As shown, the method may include, but is not limited to, the following steps:
[0082] Step S201: In response to the processor's first cache data request, obtain the data type and data priority parameters of the first data corresponding to the first cache data request from the first cache data request.
[0083] Step S202: If it is determined that the first data needs to be cached based on the data type and data priority parameters of the first data, the first data is read from the memory and cached into the cache space.
[0084] For example, if the data priority parameter corresponding to the data type of the first data is higher than the data priority parameter threshold, it can be determined that the first data needs to be cached.
[0085] Step S203: Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0086] The substitution priority parameter is used to characterize the priority of data being substituted in the cache when the cache space is insufficient.
[0087] Steps S202-S203 can be found in the description of steps S1021 and S10313 in Example 2, and will not be repeated here.
[0088] Step S204: Determine the usage factor of each data type in the cache space, and use the factor to characterize the processor's demand for data of each data type.
[0089] Step S204 may include, but is not limited to:
[0090] S2041. Determine the cache hit rate for each data type in the cache space.
[0091] The cache hit rate of a data type in the cache space can be understood as: the number of times data of that data type is hit in the cache space, which is the proportion of the number of times data of that data type is accessed in the cache space. The number of times accessed includes the number of hits and the number of misses.
[0092] Among them, a higher cache hit rate corresponds to a higher level of usage demand.
[0093] A cache hit for a data type can be understood as: data of a data type can be directly found in the cache.
[0094] A cache miss for a data type can be understood as: the data type cannot be directly found in the cache.
[0095] Step S204 may also include, but is not limited to:
[0096] S2042. Determine the corresponding read time interval for each data type in the cache space.
[0097] In this embodiment, the reading time interval can be determined by, but is not limited to, the time between the most recent reading of data of a data type from the cache space before the current time and the last reading of data of the data type from the cache space before the most recent time.
[0098] Among them, the smaller the read interval, the higher the demand for the product.
[0099] Step S205: Based on the usage factor of each data type in the cache space, update the replacement priority parameter corresponding to each data type in the cache space.
[0100] Corresponding to step S2041, step S205 may include, but is not limited to:
[0101] S2051. If the data priority parameter of a data type in the cache space is lower than the data priority parameter of the data type to be updated, and the cache hit rate of the corresponding data type in the cache space is higher than the cache hit rate of the data type to be updated in the cache space, reduce the replacement priority parameter of the data type to be updated.
[0102] It is understandable that data types with low cache hit rates have a shorter lifespan in the cache space. In step S2051, for data of the type to be updated that has a high data priority parameter and a low cache hit rate, the lifespan in the cache space can be increased by reducing the substitution priority parameter corresponding to the data type to be updated, thereby increasing the cache hit rate of the cache space.
[0103] Corresponding to step S2041, step S205 may also include, but is not limited to:
[0104] S2052. If there is a data priority parameter corresponding to a data type in the cache space that is higher than the data priority parameter corresponding to the data type to be updated, and the cache hit rate corresponding to that data type in the cache space is higher than the cache hit rate corresponding to the data type to be updated in the cache space, keep the replacement priority parameter corresponding to the data type to be updated unchanged or increase the replacement priority parameter corresponding to the data type to be updated.
[0105] It is understandable that processors do not use data types with low data priority parameters very frequently. Data of data types with low data priority parameters are usually in a state of being missed. When data replacement is required, data of this data type can still be replaced first. Therefore, if the cache hit rate of the data type to be updated is lower than the cache hit rate of other data types, the replacement priority parameter of the data type to be updated can be kept unchanged or increased.
[0106] Corresponding to step S2042, step S205 may include, but is not limited to:
[0107] S2053. If the data priority parameter of a data type in the cache space is lower than the data priority parameter of the data type to be updated, and the corresponding read interval in the cache space is lower than the cache hit rate of the data type to be updated in the cache space, increase the replacement priority parameter of the data type to be updated.
[0108] For data types with short read intervals in the cache, the processor uses the data of this type more frequently. Therefore, the processor can increase the corresponding replacement priority parameter and extend its lifespan in the cache to meet the processor's actual data usage needs.
[0109] During actual data processing, processors expect data of higher demand to be retrieved from the cache promptly to minimize access latency. However, when cache space is insufficient, relying solely on the substitution priority parameters for each data type may not meet the processor's actual data processing needs. For example, data type A may have a higher substitution priority than data type B, but its usage factor may also be higher. Without updating the substitution priority parameters, data type A will be substituted before data type B when cache space is insufficient, preventing the processor from retrieving data type A from the cache in a timely manner. Therefore, updating the substitution priority parameters for each data type in the cache based on its usage factor can provide a new set of parameters that meet the processor's actual data usage requirements.
[0110] As another optional embodiment of this application, refer to Figure 4 This is a flowchart illustrating a data caching method provided in Embodiment 4 of this application. This embodiment mainly refines step S205 in Embodiment 3 above, such as... Figure 4 As shown, step S205 may include, but is not limited to, the following steps:
[0111] Step S2054: Based on the usage factor of each data type in the cache space, determine the candidate replacement priority parameter corresponding to each data type in the cache space. The higher the usage factor, the lower the candidate replacement priority parameter.
[0112] In this embodiment, the following can be done, but is not limited to: sorting or comparing the usage factors of each data type in the cache space to determine the high-low relationship of the usage factors of each data type in the cache space, and determining the candidate replacement priority parameters of each data type in the cache space based on the high-low relationship.
[0113] Step S2055: Replace or modify the alternative priority parameter based on the candidate alternative priority parameter.
[0114] If the priority of data represented by the candidate substitution priority parameter corresponding to the data type is lower than the priority of data represented by the substitution priority parameter corresponding to the data type in the cache space, the substitution priority parameter can be replaced or modified based on the candidate substitution priority parameter to obtain the updated substitution priority parameter, so that the priority of data represented by the updated substitution priority parameter in the cache space is consistent with the priority of data represented by the candidate substitution priority parameter in the cache space.
[0115] In this embodiment, based on the usage factor corresponding to each data type in the cache space, candidate replacement priority parameters corresponding to each data type in the cache space are determined. The replacement priority parameters are replaced or modified based on the candidate replacement priority parameters so that the updated replacement priority parameters corresponding to each data type can meet the processor's actual data usage needs.
[0116] As another optional embodiment of this application, here is a flowchart illustrating a data caching method provided in Embodiment 5 of this application. This embodiment is mainly a refinement of step S205 in Embodiment 3 above. Step S205 may include, but is not limited to, the following steps:
[0117] Step S2056: If, based on the usage factor corresponding to the data type in the cache space, it is determined that the data corresponding to the data type no longer needs to be cached in the cache space, the substitution priority parameter corresponding to the data type in the cache space is canceled, and the data corresponding to the data type is no longer cached in the cache space if the data type meets the set conditions.
[0118] It should be noted that if the data priority parameter corresponding to a certain data type is not high, it indicates that the processor does not use it frequently, and / or if the usage factor corresponding to a certain data type represents the degree of usage demand, then if the data type meets the set conditions (e.g., the data of this data type is frequently modified), the data of this data type does not need to be cached in the cache space, and can be read directly from memory each time.
[0119] In the implementation method where the cache hit rate is the corresponding factor, if the cache hit rate of the data type in the cache space is not zero, it indicates that the data of that data type has been cached in the cache space. Based on this, the data of that data type can still be cached in the cache space in the future.
[0120] Additionally, it should be noted that if the cache hit rate of a data type in the cache space is zero, it indicates that the data of that data type may not have been cached in the cache space. Based on this, if the data type meets certain conditions (e.g., the data of that data type is frequently modified), it is not necessary to configure an alternative priority parameter for that data type. Subsequently, the data of that data type does not need to be cached in the cache space, and it can be read directly from memory each time.
[0121] In this embodiment, if it is determined that the data corresponding to the data type no longer needs to be cached in the cache space based on the usage factor corresponding to the data type in the cache space, the substitution priority parameter corresponding to the data type in the cache space is canceled. Under the condition that the data type meets the set conditions, the data corresponding to the data type will no longer be cached in the cache space, which can save cache space.
[0122] Of course, it should be noted that if it is determined based on the feature parameters of the first data that the first data does not need to be cached, then the first data will not be cached in the cache space.
[0123] For example, if it is determined that the data priority parameter corresponding to the data type of the first data is not high, it indicates that the processor does not use it frequently. Therefore, the first data is not cached in the cache space, and it can be read directly from memory each time.
[0124] As another optional embodiment of this application, refer to Figure 5 This is a flowchart illustrating a data caching method provided in Embodiment 6 of this application. Figure 5 As shown, the method may include, but is not limited to, the following steps:
[0125] Step S301: In response to the processor's first cache data request, obtain the data type and data priority parameters of the first data corresponding to the first cache data request from the first cache data request.
[0126] Step S302: If it is determined that the first data needs to be cached based on the data type and data priority parameters of the first data, the first data is read from the memory and cached into the cache space.
[0127] Step S303: Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0128] The substitution priority parameter is used to characterize the priority of data being substituted in the cache when the cache space is insufficient.
[0129] Step S304: Determine the usage factor of each data type in the cache space, and use the factor to characterize the processor's demand for data of each data type.
[0130] For a detailed description of steps S301-S304, please refer to the relevant description of steps S201-S204 in Example 3, which will not be repeated here.
[0131] Step S305: Based on the usage factor of each data type in the cache space, update the data priority parameters of each data type in the cache space to obtain new data priority parameters of each data type in the cache space, so that the alternative priority parameters of the data types can be configured based on the new data priority parameters in the future.
[0132] The data priority parameters corresponding to each data type in the cache space may not meet the actual usage requirements. Therefore, based on the usage factor of each data type in the cache space, the data priority parameters corresponding to each data type can be updated to obtain new data priority parameters for each data type, so that the new data priority parameters corresponding to each data type can meet the processor's actual data usage requirements.
[0133] Based on the premise that the new data priority parameters corresponding to each data type can meet the processor's actual data usage needs, alternative priority parameters corresponding to the data types can be configured based on the new data priority parameters to ensure that the alternative priority parameters corresponding to the data types can also meet the processor's actual data usage needs.
[0134] As another optional embodiment of this application, refer to Figure 6 This is a flowchart illustrating a data caching method provided in Embodiment 7 of this application. Figure 6 As shown, the method may include, but is not limited to, the following steps:
[0135] Step S401: In response to the processor's first cache data request, obtain the data type and data priority parameters of the first data corresponding to the first cache data request from the first cache data request.
[0136] Step S402: If it is determined that the first data needs to be cached based on the data type and data priority parameters of the first data, the first data is read from the memory and cached into the cache space.
[0137] Step S403: Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0138] The substitution priority parameter is used to characterize the priority of data being substituted in the cache when the cache space is insufficient.
[0139] Step S404: Determine the usage factor of each data type in the cache space, and use the factor to characterize the processor's demand for data of each data type.
[0140] Step S405: Based on the usage factor of each data type in the cache space, update the data priority parameters of each data type in the cache space to obtain the new data priority parameters of each data type in the cache space.
[0141] For a detailed description of steps S401-S405, please refer to the relevant description of steps S301-S305 in Example 6, which will not be repeated here.
[0142] Step S406: If the data priority parameter of the first data and the new data priority parameter corresponding to the data type of the first data are inconsistent, update the historical replacement priority parameters corresponding to each data type in the cache space based on the new data priority parameter corresponding to the data type of the first data. The historical replacement priority parameters corresponding to each data type in the cache space are those previously configured based on the data type and data priority parameter of the first data.
[0143] Based on the new data priority parameter corresponding to the data type of the first data, update the historical replacement priority parameters corresponding to each data type in the cache space, which may include, but are not limited to:
[0144] S4061. Based on the relationship between the new data priority parameter corresponding to the data type of the first data and the new data priority parameters of other data types in the cache space, adjust the historical replacement priority parameter corresponding to the first data type in the cache space.
[0145] In step S4061, the other data types are all data types in the cache space other than the data type of the first data.
[0146] Step S406 is a specific implementation of step S305 in Example 6, which involves configuring the alternative priority parameter corresponding to the data type based on the new data priority parameter.
[0147] Of course, the specific implementation of configuring the alternative priority parameters corresponding to the data type based on the new data priority parameters is not limited to step S406. The subsequent configuration of the alternative priority parameters corresponding to the data type based on the new data priority parameters may also include, but is not limited to:
[0148] Based on the new data priority parameters corresponding to each data type in the cache space, determine the alternative priority parameters corresponding to each data type in the cache space.
[0149] Specifically, the relationship between the new data priority parameters corresponding to each data type in the cache space can be determined by comparing or sorting them. Based on this relationship, the replacement priority parameter corresponding to each data type in the cache space can be determined, where a newer data priority parameter corresponds to a lower replacement priority parameter.
[0150] The data priority parameters corresponding to each data type in the cache space may not meet the actual usage requirements. This means that caching data using alternative priority parameters configured based on the data priority parameters of each data type in the cache space may not meet the processor's actual data processing needs. Therefore, the data priority parameters corresponding to each data type in the cache space can be updated based on the usage factor of each data type in the cache space to obtain new data priority parameters for each data type. This ensures that the new data priority parameters for each data type can meet the processor's actual data usage requirements. Furthermore, if the data priority parameters of the first data type are inconsistent with the new data priority parameters corresponding to the first data type, the historical alternative priority parameters corresponding to each data type in the cache space are updated based on the new data priority parameters to obtain new alternative priority parameters for each data type. This ensures that the new alternative priority parameters for each data type can meet the processor's actual data usage requirements.
[0151] As another optional embodiment of this application, a data caching method is provided in Embodiment 8 of this application. This embodiment is mainly a refinement of step S10313 in Embodiment 2 above. Step S10313 may include, but is not limited to, the following steps:
[0152] Step S103131: Determine the initial replacement priority parameters corresponding to each data type in the cache space based on the target caching strategy.
[0153] The data type of the first data is contained within the various data types in the cache space.
[0154] In this embodiment, if the data type and data priority parameters of the first data are not obtained from the first cached data request, and the cache space is insufficient, the system cache can directly replace the data by using the initial replacement priority parameters corresponding to each data type in the cache space determined based on the target caching strategy.
[0155] The system cache can set and use target caching strategies as needed. In this application, there are no restrictions on the type of target caching strategy.
[0156] Step S103132: If the relationship between the initial substitution priority parameters of the data types and the data types of the first data in the cache space is consistent with the relationship between the data priority parameters, adjust the initial substitution priority parameters of the data types in the cache space to obtain the substitution priority parameters of the data types in the cache space.
[0157] In the cache space, the relationship between the initial replacement priority parameters of the data types and the first data type is consistent with the relationship between the data priority parameters. This can be understood as follows:
[0158] In the cache space, among the data types, there is a data type whose initial replacement priority parameter is lower than that of the data type of the first data, and the data priority parameter is lower than that of the data type of the first data.
[0159] Alternatively, in the cache space, there is a data type whose initial replacement priority parameter is higher than that of the data type of the first data, and the data priority parameter is higher than that of the data type of the first data.
[0160] Adjusting the initial substitution priority parameters for each data type in the cache space yields substitution priority parameters for each data type in the cache space, which may include, but are not limited to:
[0161] S11. Swap the initial substitution priority parameter corresponding to the data type of the first data with the initial substitution priority parameter corresponding to the data type of the first data. The hierarchical relationship between the data type corresponding to the data type of the first data and the initial substitution priority parameter corresponding to the data type of the first data is consistent with the hierarchical relationship between data priority parameters.
[0162] Adjusting the initial replacement priority parameters for each data type in the cache space yields the replacement priority parameters for each data type in the cache space, which may include, but are not limited to:
[0163] S12. Determine the high-low relationship between the data priority parameters of each data type in the cache space, and determine the candidate replacement priority parameters corresponding to each data type based on the high-low relationship. Among them, the higher the data priority parameter, the lower the corresponding candidate replacement priority parameter.
[0164] S13. Replace the initial substitution priority parameter corresponding to each data type with the candidate substitution priority parameter corresponding to each data type.
[0165] After adjustment, the substitution priority parameter corresponding to the data type of the first data is lower than the initial substitution priority parameter corresponding to the data type of the first data.
[0166] In this embodiment, the initial replacement priority parameters corresponding to each data type in the cache space are determined based on the target caching strategy. When the cache space is insufficient, data replacement based on the initial replacement priority parameters may prematurely replace frequently used data. Therefore, if the initial replacement priority parameters of the data types in the cache space are consistent with the high-low relationship between the data types and the data types of the first data, the initial replacement priority parameters of each data type in the cache space can be adjusted to obtain the replacement priority parameters of each data type in the cache space. Data replacement based on the replacement priority parameters can extend the lifespan of frequently used data in the cache space, improve the cache hit rate, thereby reducing the number of times frequently used data is read from the memory, increasing the cache bandwidth, and reducing the power consumption of the system cache.
[0167] For example, if the cache space consists of a 4×4 matrix of storage cells, and the target caching strategy is the least recently used replacement strategy, then each storage cell in the least recently used replacement strategy has its own entry. This entry records the usage of the storage cell. When no data is cached in the cache space, the initial state of the entry is as follows: Figure 7 As shown in section (a), the data of data type A is cached in four storage units (1,1)-(1,4) in the cache space. The line0 entry corresponds to data type A, as shown below. Figure 7 As shown in section (b), the row corresponding to entry line0 is set to 1, and its corresponding column is set to 0; this corresponds to caching data of data type B into four storage units (2,1)-(2,4) in the cache space. Entry line1 corresponds to data type B, as shown... Figure 7 As shown in section (c), the row corresponding to the line 1 entry is set to 1, and the corresponding column is set to 0; this corresponds to caching data of data type C into four storage units (3,1)-(3,4) in the cache space. The line 2 entry corresponds to data type C, as shown... Figure 7 As shown in section (d), the row corresponding to the line 2 entry is set to 1, and the corresponding column is set to 0; this corresponds to caching the first data of data type D into four storage units (4,1)-(4,4) in the cache space. The line 3 entry corresponds to data type D, as shown... Figure 7 As shown in section (e), all rows corresponding to the line3 entry are set to 1, and all columns corresponding to it are set to 0.
[0168] The entry corresponding to a line of all zeros is the least recently used, that is, line0, line1, line2, and line3 are all the least recently used. When there are multiple least recently used, the initial replacement priority parameter can be determined according to the order of generation of the least recently used. For example, the high-low relationship between the initial replacement priority parameters of data type A corresponding to line0, data type B corresponding to line1, data type C corresponding to line2, and data type D corresponding to line3 can be expressed as line0>line1>ine2>line3. If data replacement is performed according to the initial replacement priority parameter, the data of data type A will be replaced first. However, the high-low relationship between the data priority parameters of data types A, B, C, and D is data priority data type A>data priority data type C>data priority data type B>data priority data type D, which causes the data type with the highest data priority parameter to be replaced first. Therefore, for the high-low relationship between the data priority parameters of data types A, B, C, and D, the initial replacement priority parameter can be adjusted. The high-low relationship between the adjusted replacement priority parameters can be expressed as: line0<line2<ine1<line3. According to line0<line2<ine1<line3, the data of data type D, that is, the data with the lowest data priority parameter, can be replaced first.
[0169] As another optional embodiment of the present application, a data caching method provided for Embodiment 9 of the present application. This embodiment is mainly a refinement scheme of step S10313 in the above Embodiment 2. Step S10313 may include but is not limited to the following steps:
[0170] Step S103133: Update the data priority parameters of each data type in the cache space based on the data type and data priority parameter of the first data, and obtain the updated data priority parameters of each data type in the cache space.
[0171] For example, if each data type in the cache space includes: data type A, data type B, and data type C, the data priority parameter of data type A is a, the data priority parameter of data type B is b, the data priority parameter of data type C is c, the data type of the first data is data type D, and the data priority parameter of the first data is d, the updated data priority parameters of each data type in the cache space include: the data priority parameter a of data type A, the data priority parameter b of data type B, the data priority parameter c of data type C, and the data priority parameter d of data type D.
[0172] Step S103134: Based on the updated data priority parameters of each data type in the cache space, determine the replacement priority parameters corresponding to each data type in the cache space. Among them, the higher the data priority parameter, the lower the replacement priority parameter.
[0173] In this embodiment, the relative importance of the updated data priority parameters of each data type in the cache space can be determined by comparing or sorting them, but is not limited to this method. Based on this relative importance, the alternative priority parameters for each data type in the cache space can be determined. For example, if the updated data priority parameters of each data type in the cache space include: data priority parameter a for data type A, data priority parameter b for data type B, data priority parameter c for data type C, and data priority parameter d for data type D, by comparing or sorting data priority parameters a, b, c, and d, it can be determined that data priority parameter a > data priority parameter b > data priority parameter c > data priority parameter d. Based on this, the alternative priority parameters for data types A, B, C, and D can be determined, satisfying the following condition: alternative priority parameter for data type A < alternative priority parameter for data type B < alternative priority parameter for data type C < alternative priority parameter for data type D.
[0174] In this embodiment, the data priority parameters of each data type in the cache space are updated based on the data type and data priority parameters of the first data to obtain the updated data priority parameters of each data type in the cache space. Based on the updated data priority parameters of each data type in the cache space, the alternative priority parameters corresponding to each data type in the cache space are determined. In the case of insufficient cache space, caching can be performed based on the configured alternative priority parameters corresponding to each data type, thereby optimizing the lifecycle of each data type in the cache and improving the performance of cache usage.
[0175] As another optional embodiment of this application, refer to Figure 8 This is a flowchart illustrating a data caching method provided in Embodiment 10 of this application. Figure 8 As shown, the method may include, but is not limited to, the following steps:
[0176] Step S501: In response to the processor's first cache data request, obtain the feature parameters of the first data corresponding to the first cache data request from the first cache data request.
[0177] Step S502: If it is determined that the first data needs to be cached based on the characteristic parameters of the first data, the first data is read from the memory and cached into the cache space.
[0178] Step S503: Based on the feature parameters of the first data, configure the replacement priority parameters corresponding to each data in the cache space. The replacement priority parameters are used to characterize the priority of data being replaced in the cache space when the cache space is insufficient.
[0179] For a detailed description of steps S501-S503, please refer to the relevant description of steps S101-S103 in Example 1, which will not be repeated here.
[0180] Step S504: In response to the processor's second cache data request, retrieve the second data from memory, and if the cache space is insufficient, determine the data type that can be replaced in the cache space.
[0181] In this embodiment, the data types that can be replaced can be selected from the various data types in the cache space based on the target caching strategy, but are not limited to this. For example, if the target caching strategy is a least recently used replacement strategy, the least recently used data type is selected from the various data types in the cache space based on the least recently used replacement strategy, and this least recently used data type is used as the data type that can be replaced.
[0182] Step S505: Select the data type with the highest priority parameter from the replaceable data types.
[0183] Step S506: Cache the second data using the cache area corresponding to the data type with the highest replacement priority parameter.
[0184] In this embodiment, by responding to the processor's second cache data request, second data is obtained from the memory. In the case of insufficient cache space, the data types that can be replaced in the cache space are determined, and the data type with the highest replacement priority parameter is selected from the replaceable data types. The second data is cached in the cache area corresponding to the data type with the highest replacement priority parameter. This can extend the lifespan of data types with low replacement priority parameters (corresponding to high data priority parameters) in the cache space, so as to meet the processor's usage needs for frequently used data as much as possible.
[0185] As another optional embodiment of this application, refer to Figure 9 This is a flowchart illustrating a data caching method provided in Embodiment 11 of this application. Figure 9 As shown, the method may include, but is not limited to, the following steps:
[0186] Step S601: In response to the processor's first cache data request, obtain the feature parameters of the first data corresponding to the first cache data request from the first cache data request.
[0187] Step S602: If it is determined that the first data needs to be cached based on the characteristic parameters of the first data, the first data is read from the memory and cached into the cache space.
[0188] Step S603: Based on the feature parameters of the first data, configure the replacement priority parameters corresponding to each data in the cache space. The replacement priority parameters are used to characterize the priority of data being replaced in the cache space when the cache space is insufficient.
[0189] Step S604: In response to the processor's second cache data request, retrieve the second data from memory, and if the cache space is insufficient, determine the data type that can be replaced in the cache space.
[0190] Step S605: Select the data type with the highest priority parameter from the replaceable data types.
[0191] For a detailed description of steps S601-S605, please refer to the relevant description of steps S501-S505 in Example 10, which will not be repeated here.
[0192] Step S606: Select the data with the highest replacement priority parameter from the data of the data with the highest replacement priority parameter, and use the cache area corresponding to the data with the highest replacement priority parameter to cache the second data.
[0193] In this embodiment, substitution priority parameters for each piece of data of the same data type can be determined, and the method of determination is not limited in this application. For example, the substitution priority parameters for each piece of data of the same data type can be determined according to the order in which the data is cached, with higher substitution priority parameters corresponding to earlier cached items.
[0194] In this embodiment, by responding to the processor's second cache data request, second data is retrieved from memory. When the cache space is insufficient, the data types that can be replaced in the cache space are determined. The data type with the highest replacement priority parameter is selected from the replaceable data types, which can extend the lifetime of the data types with low replacement priority parameters (corresponding to high data priority parameters) in the cache space. On this basis, the data with the highest replacement priority parameter is selected from the data of the data with the highest replacement priority parameter, and the second data is cached using the cache area corresponding to the data with the highest replacement priority parameter. This can extend the lifetime of some data of the data with the highest replacement priority parameter in the cache space and further improve the cache hit rate.
[0195] The following section describes a data caching device provided in this application. The data caching device described below can be referred to in correspondence with the data caching method described above.
[0196] Please see Figure 10 The data caching device includes: an acquisition module 100, a caching module 200, and a configuration module 300.
[0197] The acquisition module 100 is used to respond to the processor's first cache data request and obtain the feature parameters of the first data corresponding to the first cache data request from the first cache data request.
[0198] The caching module 200 is used to read the first data from the memory and cache it into the cache space if it is determined that the first data needs to be cached based on the feature parameters of the first data.
[0199] The configuration module 300 is used to configure the replacement priority parameters corresponding to each data in the cache space based on the feature parameters of the first data. The replacement priority parameters are used to characterize the priority of data being replaced in the cache space when the cache space is insufficient.
[0200] The characteristic parameters of the first data may include:
[0201] The first data type and data priority parameter must be at least one of the following:
[0202] Configuration module 300 can be used specifically for:
[0203] Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
[0204] In this embodiment, the data caching device may further include: a determination module, used to determine the usage factor corresponding to each data type in the cache space, and use the factor to characterize the processor's demand for data of the data type;
[0205] The first update module is used to update the replacement priority parameters corresponding to each data type in the cache space based on the usage factor of each data type in the cache space.
[0206] The data caching device may also include:
[0207] The second update module is used to update the data priority parameters corresponding to each data type in the cache space based on the usage factor corresponding to each data type in the cache space, so as to obtain the new data priority parameters corresponding to each data type in the cache space, so that the alternative priority parameters corresponding to the data types can be configured based on the new data priority parameters in the future.
[0208] The first update module can be used specifically for:
[0209] Based on the usage factor of each data type in the cache space, the candidate replacement priority parameter corresponding to each data type in the cache space is determined. The higher the usage factor, the lower the candidate replacement priority parameter.
[0210] Replace or modify the alternative priority parameter based on the candidate alternative priority parameter;
[0211] Alternatively, if based on the usage factor corresponding to the data type in the cache space, it is determined that the data corresponding to the data type no longer needs to be cached in the cache space, the substitution priority parameter corresponding to the data type in the cache space is canceled, and the data corresponding to the data type will no longer be cached in the cache space if the data type meets the set conditions.
[0212] Corresponding to the second update module, configuration module 300 can also be used for:
[0213] If the data priority parameter of the first data is inconsistent with the new data priority parameter corresponding to the data type of the first data, the historical replacement priority parameter corresponding to each data type in the cache space is updated based on the new data priority parameter. The historical replacement priority parameter corresponding to each data type in the cache space is the one previously configured based on the data type and data priority parameter of the first data.
[0214] The configuration module 300 configures the alternative priority parameters corresponding to each data type in the cache space based on the data type and data priority parameters of the first data. Specifically, this process may include:
[0215] Determine the initial replacement priority parameters for each data type in the cache space based on the target caching strategy;
[0216] If the initial substitution priority parameters of the data types in the cache space are consistent with the initial substitution priority parameters of the first data type, adjust the initial substitution priority parameters of the data types in the cache space to obtain the substitution priority parameters of the data types in the cache space; wherein, the substitution priority parameter of the first data type is lower than the initial substitution priority parameter of the first data type.
[0217] The configuration module 300 configures the alternative priority parameters corresponding to each data type in the cache space based on the data type and data priority parameters of the first data. Specifically, this process may include:
[0218] Based on the data type and data priority parameters of the first data, update the data priority parameters of each data type in the cache space to obtain the updated data priority parameters of each data type in the cache space;
[0219] Based on the updated data priority parameters of each data type in the cache space, the replacement priority parameters corresponding to each data type in the cache space are determined. Among them, the higher the data priority parameter, the lower the corresponding replacement priority parameter.
[0220] In this embodiment, the cache module 200 can also be used for:
[0221] In response to a second cache data request from the processor, second data is retrieved from memory, and if cache space is insufficient, the data type that can be replaced in the cache space is determined.
[0222] Choose the data type with the highest priority parameter from the available alternative data types;
[0223] The second data can be cached using the cache area corresponding to the data type with the highest substitution priority parameter, or the data with the highest substitution priority parameter can be selected from the data of the data type with the highest substitution priority parameter, and the second data can be cached using the cache area corresponding to the data with the highest substitution priority parameter.
[0224] It should be noted that each embodiment focuses on describing the differences from other embodiments, and the same or similar parts between the embodiments can be referred to accordingly. For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments.
[0225] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0226] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, in implementing this application, the functions of each module can be implemented in one or more software and / or hardware.
[0227] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. 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 product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0228] The data caching method and apparatus provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data caching method, comprising: In response to the processor's first cached data request, the feature parameters of the first data corresponding to the first cached data request are obtained from the first cached data request; If, based on the characteristic parameters of the first data, it is determined that the first data needs to be cached, the first data is read from the memory and cached into the cache space; Based on the feature parameters of the first data, a replacement priority parameter is configured for each data in the cache space. The replacement priority parameter is used to characterize the priority of the data being replaced in the cache space when the cache space is insufficient. Each piece of data in the cache space includes first data and other data besides the first data. When new data needs to be cached, if the cache space is insufficient, the data in the cache space that can be replaced by the new data is determined based on the replacement priority parameters corresponding to each piece of data stored in the cache space.
2. The data caching method according to claim 1, wherein the characteristic parameters of the first data include: The first data is either a data type or a data priority parameter.
3. The data caching method according to claim 2, wherein, based on the feature parameters of the first data, a substitution priority parameter corresponding to each data in the cache space is configured, including: Based on the data type and data priority parameters of the first data, configure the alternative priority parameters corresponding to each data type in the cache space.
4. The data caching method according to claim 3, further comprising: Determine the usage factor corresponding to each data type in the cache space, wherein the usage factor characterizes the degree of data usage demand of the processor for the data type. Based on the usage factor corresponding to each data type in the cache space, update the replacement priority parameter corresponding to each data type in the cache space; Alternatively, based on the usage factor corresponding to each data type in the cache space, update the data priority parameter corresponding to each data type in the cache space to obtain a new data priority parameter corresponding to each data type in the cache space, so that the alternative priority parameter corresponding to the data type can be configured subsequently based on the new data priority parameter.
5. The data caching method according to claim 4, wherein updating the replacement priority parameter corresponding to each data type in the cache space based on the usage factor corresponding to each data type in the cache space includes: Based on the usage factor corresponding to each data type in the cache space, the candidate replacement priority parameter corresponding to each data type in the cache space is determined, wherein the higher the usage factor, the lower the candidate replacement priority parameter. Replace or modify the alternative priority parameter based on the candidate alternative priority parameter; Alternatively, if based on the usage factor corresponding to the data type in the cache space, it is determined that the data corresponding to the data type no longer needs to be cached in the cache space, the substitution priority parameter corresponding to the data type in the cache space is canceled, and if the data type meets the set conditions, the data corresponding to the data type will no longer be cached in the cache space.
6. The data caching method according to claim 4, wherein subsequently, based on the new data priority parameter, an alternative priority parameter corresponding to the data type is configured, including: If the data priority parameter of the first data is inconsistent with the new data priority parameter corresponding to the data type of the first data, the historical replacement priority parameter corresponding to each data type in the cache space is updated based on the new data priority parameter. The historical replacement priority parameter corresponding to each data type in the cache space is the one previously configured based on the data type and data priority parameter of the first data.
7. The data caching method according to claim 3, wherein, based on the data type and data priority parameter of the first data, alternative priority parameters corresponding to each data type in the cache space are configured, including: The initial replacement priority parameters for each data type in the cache space are determined based on the target caching strategy. If the initial substitution priority parameters of the data types in the cache space are consistent with the high-low relationship between the data type and the data type of the first data, and the data priority parameters are consistent, the initial substitution priority parameters of the data types in the cache space are adjusted to obtain the substitution priority parameters of the data types in the cache space; wherein, the substitution priority parameter of the data type of the first data is lower than the initial substitution priority parameter of the data type of the first data.
8. The data caching method according to claim 3, wherein, based on the data type and data priority parameter of the first data, alternative priority parameters corresponding to each data type in the cache space are configured, including: Based on the data type and data priority parameters of the first data, update the data priority parameters of each data type in the cache space to obtain the updated data priority parameters of each data type in the cache space; Based on the updated data priority parameters of each data type in the cache space, the replacement priority parameters corresponding to each data type in the cache space are determined, wherein the higher the data priority parameter, the lower the replacement priority parameter.
9. The data caching method according to claim 1, further comprising: In response to a second cached data request from the processor, second data is retrieved from the memory, and if the cache space is insufficient, the data types that can be replaced in the cache space are determined. Select the data type with the highest replacement priority parameter from the list of replaceable data types; The second data is cached using the cache area corresponding to the data type with the highest substitution priority parameter, or the data with the highest substitution priority parameter is selected from the data of the data type with the highest substitution priority parameter, and the second data is cached using the cache area corresponding to the data with the highest substitution priority parameter.
10. A data caching device, comprising: The acquisition module is used to, in response to a first cached data request from the processor, acquire the feature parameters of the first data corresponding to the first cached data request from the first cached data request; The caching module is used to read the first data from the memory and cache it into the cache space if it is determined that the first data needs to be cached based on the feature parameters of the first data; The configuration module is used to configure the replacement priority parameters corresponding to each data in the cache space based on the feature parameters of the first data. The replacement priority parameters are used to characterize the priority of the data being replaced in the cache space when the cache space is insufficient. Each piece of data in the cache space includes first data and other data besides the first data. When new data needs to be cached, if the cache space is insufficient, the data in the cache space that can be replaced by the new data is determined based on the replacement priority parameters corresponding to each piece of data stored in the cache space.