Data caching method and device, equipment and storage medium
By setting multiple cache sub-regions in the cache area according to different cache topics and setting storage policies for them, the problem that cache policies are no longer applicable in the existing technology is solved, and the hit rate of the cache area and the performance of the cache device are improved.
Patent Information
- Application Number
- CN202411965356.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-06-03
AI Technical Summary
In the prior art, pre-set cache strategy may no longer be applicable to data to be cached due to factors such as data diversification, scenario changes and system function expansion, resulting in a decrease in the hit rate of the cache area and a decrease in the performance of the cache device.
By setting multiple cache sub-regions in the cache area in advance according to different cache topics, and setting corresponding storage policies for each cache sub-regions, when there is data to be cached, the data topic is obtained, the target cache sub-regions are selected using the corresponding relationship between the topic and the cache topic, and the storage policy of the sub-regions is used to store the data to be cached.
The hit rate of the cache area and the performance of the cache device are improved, because the data to be cached is cached in the cache sub-region corresponding to its data topic, making it more likely to be reused later.
Smart Images

Figure CN120085801A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data storage, and more particularly, to a data caching method, apparatus, device, and storage medium. Background Art
[0002] With the gradual increase in the access volume between the user side and the client side in various aviation fuel systems, each system application needs to support a larger number of concurrencies. Therefore, the performance of caching devices has received increasing attention. To adapt to the gradually increasing concurrency and the gradually improving user requirements, it is necessary to improve the speed and efficiency of the system application in responding to user requests. Therefore, while being able to cache data information, it is also necessary to improve the hit rate of the cache area of the caching device. The hit rate means that when the target data stored in advance needs to be retrieved again, the possibility of the target data existing in the cache area is greater, so that frequent retrieval of the target data from the data persistence layer can be avoided.
[0003] In the prior art, a storage strategy adapted to the storage area is set in advance according to the usage scenario. When there is data to be cached, the storage strategy is used for caching. However, due to factors such as the diversification of data types, the change of scenarios during the operation process, and the expansion of system application functions, the pre-set caching strategy is very likely to be no longer applicable to the subsequent data to be cached. Therefore, the hit rate of the cache area will be reduced, and the performance of the caching device will be reduced. Therefore, how to improve the hit rate of the cache area and the performance of the caching device is a technical problem that those skilled in the art need to solve currently. Summary of the Invention
[0004] In view of this, the purpose of the present application is to provide a data caching method, apparatus, device, and storage medium, which can solve the problem that the current software cannot digitally supervise the aircraft refueling vehicle by controlling the position data, alarm data, and vehicle unique identification code of the aircraft refueling vehicle, achieve position tracking, alarm, and trajectory query of the aircraft refueling vehicle, enable the airport management personnel to digitally supervise the control of the aircraft refueling vehicle, and improve the safety of the aircraft refueling vehicle during refueling work at the airport.
[0005] The purpose of the present invention is to provide a data caching method that can improve the hit rate of the cache area and the performance of the caching device; another purpose of the present invention is to provide a data caching apparatus, device, and computer-readable storage medium, all of which have the above beneficial effects.
[0006] To solve the above technical problems, the present invention provides a data caching method, including:
[0007] Multiple cache sub-areas are set in advance in the cache area according to different cache topics, and corresponding storage strategies are set for each of the cache sub-areas;
[0008] When there is data to be cached, obtain the data topic of the data to be cached;
[0009] Select a target cache sub-region by using the correspondence between the data topic and the cache topic;
[0010] Store the data to be cached by using the storage policy corresponding to the target cache sub-region.
[0011] Preferably, when there is no target cache sub-region corresponding to the data topic in the cache sub-region, the method further includes:
[0012] Add and set a target cache sub-region corresponding to the data topic of the data to be cached in the cache area and set the corresponding storage policy, and enter the step of storing the data to be cached by using the storage policy corresponding to the target cache sub-region.
[0013] Preferably, the step of obtaining the data to be cached specifically includes:
[0014] Obtain a user request;
[0015] Judge whether the data information corresponding to the user request exists in the cache sub-region;
[0016] If not, obtain the data information corresponding to the user request from the data persistence layer to obtain the data to be cached.
[0017] Preferably, the cache topic is specifically a topic set according to the task type.
[0018] Preferably, the step of pre-setting multiple cache sub-regions in the cache area according to different cache topics specifically includes:
[0019] Pre-set multiple different cache topics;
[0020] Classify different cache topics;
[0021] Set multiple cache sub-regions in the cache area, and set the cache topics belonging to the same category in the same cache sub-region.
[0022] Preferably, it further includes: counting the access times of each cache sub-region within a preset time;
[0023] When there is a target cache sub-partition with the access times less than the preset number threshold, clear the cache topic of the target cache sub-partition and the cache content in the target cache sub-partition.
[0024] To solve the above technical problems, the present invention further provides a data caching device, including: a setting module, configured to pre-set a plurality of cache sub-areas in a buffer according to different cache topics, and respectively set corresponding storage policies for each of the cache sub-areas;
[0025] an obtaining module, configured to obtain the data topic of the data to be cached when there is data to be cached;
[0026] a selection module, configured to select a target cache sub-area by using the correspondence between the data topic and the cache topic;
[0027] a storage module, configured to store the data to be cached by using the storage policy corresponding to the target cache sub-area.
[0028] To solve the above technical problems, the present invention further provides a data caching device, including: a memory, configured to store a computer program;
[0029] a processor, configured to implement the steps of any of the above data caching methods when executing the computer program.
[0030] To solve the above technical problems, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above data caching methods.
[0031] A data caching method provided by the present invention includes pre-setting a plurality of cache sub-areas in a buffer according to different cache topics, and respectively setting corresponding storage policies for each cache sub-area; when there is data to be cached, obtaining the data topic of the data to be cached; then selecting a target cache sub-area by using the correspondence between the data topic and the cache topic; and thus
[0032] storing the data to be cached by using the storage policy corresponding to the target cache sub-area. Since the data to be cached is cached in the cache sub-area corresponding to the data topic of the data to be cached, therefore, the data information cached in each cache sub-area is more likely to be the target data that needs to be used again later, that is, the cache area is more likely to store the target data, so the hit rate of the cache area is improved, and the performance of the cache device is enhanced.
[0033] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] To more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0035] Figure 1 Flowchart of a data caching method provided by an embodiment of the present invention;
[0036] Figure 2 Flowchart of another data caching method provided by an embodiment of the present invention;
[0037] Figure 3 Structural diagram of a data caching device provided by an embodiment of the present invention;
[0038] Figure 4 Structural diagram of a data caching device provided by an embodiment of the present invention. Detailed implementation manners
[0039] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some, rather than all, of the embodiments of the present application. Usually, the components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application to be protected, but only represents the selected embodiments of the present application. Based on the embodiments of the present application, every other embodiment obtained by those of ordinary skill in the art without creative efforts belongs to the scope of protection of the present application.
[0040] Figure 1 Flowchart of a data caching method provided by an embodiment of the present invention. As Figure 1 shown, a data caching method includes:
[0041] S10: Predetermine multiple cache sub-regions in the buffer according to different cache topics, and set corresponding storage policies for each cache sub-region respectively.
[0042] Specifically, predetermine multiple different cache topics, including the number of cache topics and specific type information of cache topics, etc., and then set multiple cache sub-regions in the buffer according to the number of cache topics. The cache sub-regions need to cover all
[0043] For some caching topics, the total capacity of the cache sub - regions needs to be less than or equal to the total capacity of the cache region. Additionally, the storage space sizes of the cache sub - regions can be the same, or can be set according to the corresponding caching topics. The process of allocating the storage space sizes can be allocated according to the caching topics or according to a ratio. This embodiment does not limit this.
[0044] After setting up multiple cache sub - regions according to different caching topics, corresponding storage policies are set for each cache sub - region respectively. It can be understood that common storage policies include the First - In - First - Out (FIFO) policy, that is, clearing the data information that was cached earliest; the Least - Frequently - Used (LFU) policy, which clears the data information with fewer usage times according to the usage times of the data information; and the Least - Recently - Used (LRU) policy, which clears the data information with the farthest usage timestamp according to the timestamp of the last use of the data information. It should be noted that in this embodiment, generally, one storage policy is set corresponding to one cache sub - region to avoid duplicate storage or even storage chaos caused by multiple storage policies during the data caching process.
[0045] S20: When there is data to be cached, obtain the data topic of the data to be cached.
[0046] When it is detected that there is currently data to be cached, that is, when it is detected that there is data information that needs to be cached,
[0047] Obtain the data topic of the data to be cached. It can be understood that each data information has its corresponding topic. Therefore, when it is determined that there is data to be cached, obtain the data topic of the data to be cached.
[0048] S30: Select the target cache sub - region using the correspondence between the data topic and the cache topic.
[0049] It can be understood that after obtaining the data topic of the data to be cached, according to the correspondence between the data topic and the cache topic, select the target cache sub - region corresponding to the data topic. The target cache sub - region is the cache sub - region used to store the data to be cached. Generally, one data to be cached corresponds to one target cache sub - region. It should be noted that the correspondence between the data topic and the cache topic can be the same relationship, that is, select the cache topic that is the same as the data topic, and use the cache sub - region corresponding to this cache topic as the target cache sub - region.
[0050] S40: Store the data to be cached using the storage policy corresponding to the target cache sub - region.
[0051] In a physical system, since storage policies corresponding to each cache sub-region have been set previously, after obtaining the target cache sub-region by using the correspondence between the data topic and the cache topic, the storage policy of the target cache sub-region is used to perform a caching operation on the information to be cached, so as to cache the data to be cached in the target cache sub-region.
[0052] A data caching method provided by an embodiment of the present invention includes: pre-setting a plurality of cache sub-regions in a buffer according to different cache topics, and respectively setting corresponding storage policies for each cache sub-region; when there is data to be cached, obtaining the data topic of the data to be cached; and then selecting a target cache sub-region by using the correspondence between the data topic and the cache topic.
[0053] Thereby, the data to be cached is stored by using the storage policy corresponding to the target cache sub-region. Since the data to be cached is cached in the cache sub-region corresponding to the data topic of the data to be cached, the possibility that the data information cached in each cache sub-region is the target data that needs to be used again later is greater, that is, the possibility that the target data is stored in the buffer is greater. Therefore, the hit rate of the buffer is improved, and the performance of the caching device is enhanced.
[0054] Figure 2 FIG. is a flowchart of another data caching method provided by an embodiment of the present invention. On the basis of the above embodiment, this embodiment further explains and optimizes the technical solution. Specifically, the step of obtaining the data to be cached specifically includes:
[0055] S21: Obtain a user request;
[0056] S22: Determine whether the data information corresponding to the user request exists in the cache sub-region;
[0057] S23: If not, obtain the data information corresponding to the user request from the data persistence layer to obtain the data to be cached.
[0058] In this embodiment, further considering the source of the data information cached in the buffer. Specifically, when a user request is obtained, it is determined whether the data information corresponding to the user request exists in the cache sub-region. If it exists, it means that the data information can be directly obtained from the buffer, so there is no need to perform a caching operation; otherwise, it is necessary to obtain the data information corresponding to the user request from the data persistence layer according to the user request to obtain the data to be cached, and then store it in the corresponding cache sub-region by using the correspondence between the data topic of the obtained data to be cached and the cache topic. It should be noted that the data persistence layer is a device for storing data, such as a disk or a database, etc.
[0059] It can be seen that the data caching method provided by this embodiment can cache the data to be cached obtained through multiple channels, improving the practicability.
[0060] Based on the above embodiments, the technical solution is further described and optimized in this embodiment. Specifically, when there is no target cache sub-region corresponding to the data topic in the cache sub-region, the method further includes:
[0061] Add a target cache sub-region corresponding to the data topic of the data to be cached in the cache area and set the corresponding storage policy, and enter the step of storing the data to be cached using the storage policy corresponding to the target cache sub-region.
[0062] Specifically, considering that there may be a situation where there is no target cache sub-region corresponding to the data topic of the data to be cached obtained, in order to facilitate the subsequent use of the data to be cached, in this embodiment, a target cache sub-region corresponding to the data topic of the data to be cached is further added in the cache area, and a corresponding cache policy is set for this cache sub-region, and then the data to be cached is cached in this target cache sub-region using the cache policy.
[0063] The data caching method provided in this embodiment, compared with the method of discarding the data to be cached or storing it in the data persistence layer when there is no cache topic corresponding to the data topic of the data to be cached in the cache sub-region, this method adds a target cache sub-region for the data to be cached and caches the data to be cached in this target cache sub-region using the corresponding storage policy, thereby improving the scalability of the cache area and making it more convenient to obtain the data to be cached subsequently.
[0064] Based on the above embodiments, the technical solution is further described and optimized in this embodiment. Specifically, the method further includes:
[0065] Count the number of accesses to each cache sub-region within a preset time;
[0066] When there is a target cache sub-partition with the number of accesses less than the preset number threshold, clear the cache topic of the target cache sub-partition and the cache content in the target cache sub-partition.
[0067] Specifically, in this embodiment, a counter is set for each cache sub-region in advance. When there is an operation to access the data information in the cache sub-region, the count value of the counter corresponding to the cache sub-region is incremented by 1, and then the access times of each cache sub-region within a preset time are counted. When the preset time is reached, the access times of each cache sub-region are compared with a preset number threshold. When there is a target cache sub-region with access times less than the preset number threshold, it indicates that the data information in this cache sub-region is accessed less frequently in the later stage. Therefore, the cache topic and the cache content in the target cache sub-region are cleared. It should be noted that in this embodiment, the preset number threshold can be set to 0, or can be set to other values according to actual needs and actual operation experience.
[0068] It can be seen that the data caching method provided in this embodiment can further improve the hit rate of the cache area.
[0069] Based on the above embodiment, this embodiment further explains and optimizes the technical solution. Specifically, setting multiple cache sub-regions in the cache area according to different cache topics in advance includes:
[0070] Set multiple different cache topics in advance;
[0071] Classify different cache topics;
[0072] Set multiple cache sub-regions in the cache area, and set the cache topics belonging to the same class in the same cache sub-region.
[0073] Specifically, set multiple different cache topics in advance, and then classify different cache topics. Specifically, two or more cache topics can be classified into one class, and then the cache topics belonging to the same class are set in the same cache sub-region, that is, one cache sub-region can subscribe to multiple cache topics belonging to the same class. By setting multiple cache topics in the same cache sub-region, that is, setting multiple cache topics of the same class for the same cache sub-region, while ensuring that the data to be cached corresponding to multiple types of data topics can be cached, the number of cache sub-regions is reduced, making the cache area more concise.
[0074] As a preferred implementation, the cache topic is specifically a topic set according to the task type.
[0075] In specific implementation, cache topics can be set according to task types. For example, cache topics can be set according to long tasks and short tasks. More specifically, cache topics can be set according to the task types where the data to be cached needs to be cached in a logical pool or a logical volume. In other embodiments, cache topics can also be set in other ways, such as according to data types, data sizes, or data formats. This embodiment does not make any limitations in this regard. Since the storage policies corresponding to different task types vary greatly, by setting cache topics according to task types in this embodiment, the hit rate of the cache area can be improved.
[0076] The above has described in detail the embodiments of a data caching method provided by the present invention. The present invention also provides a data caching device, a device, and a computer-readable storage medium corresponding to this method. Since the embodiments of the device, the device, and the computer-readable storage medium correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the device, the device, and the computer-readable storage medium part, and will not be elaborated here for the time being.
[0077] Figure 3 The structure diagram of a data caching device provided by an embodiment of the present invention is as Figure 3 shown. A data caching device includes:
[0078] A setting module 31, configured to pre-set a plurality of cache sub-areas in the cache area according to different cache topics, and respectively set corresponding storage policies for each cache sub-area;
[0079] An obtaining module 32, configured to obtain the data topic of the data to be cached when there is data to be cached;
[0080] A selecting module 33, configured to select a target cache sub-area by using the correspondence between the data topic and the cache topic;
[0081] A storing module 34, configured to store the data to be cached by using the storage policy corresponding to the target cache sub-area.
[0082] The data caching device provided by the embodiment of the present invention has the beneficial effects of the above data caching method.
[0083] Figure 4 The structure diagram of a data caching device provided by an embodiment of the present invention is as Figure 4 shown. A data caching device includes:
[0084] A memory 41, configured to store a computer program;
[0085] A processor 42, configured to implement the steps of the above data caching method when executing the computer program.
[0086] The data caching device provided by the embodiments of the present invention has the beneficial effects of the above data caching method.
[0087] To solve the above technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above data caching method are implemented.
[0088] The computer-readable storage medium provided by the embodiments of the present invention has the beneficial effects of the above data caching method.
[0089] The above has introduced in detail the data caching method, device, equipment and computer-readable storage medium provided by the present invention. Specific embodiments are applied herein to elaborate on the principles and implementation manners of the present invention. The above descriptions of the embodiments are only used to help understand the method and its core idea of the present invention. It should be pointed out that for those of ordinary skill in the art
[0090] in the technical field, without departing from the principle of the present invention, several improvements and modifications can still be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
[0091] The embodiments in the specification are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method part.
[0092] Finally, it should be noted that the above embodiments are only specific implementation manners of the present application, used to illustrate the technical solutions of the present application, rather than limiting them. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present application can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A data caching method, characterized in that: include: Pre-set multiple cache sub-areas in the cache area according to different cache themes, and set a Set the corresponding storage policy; When there is data to be cached, obtaining the data subject of the data to be cached; Selecting a target cache sub-area using the corresponding relationship between the data subject and the cache subject; The data to be cached is stored using the storage strategy corresponding to the target cache sub-area.
2. The method according to claim 1, characterized in that When the cache sub-area does not contain the data subject When the corresponding target cache sub-area is located, the method further comprises: Add a target cache sub-area corresponding to the data subject of the data to be cached in the cache area and set The corresponding storage strategy is used, and the step of storing the data to be cached by using the storage strategy corresponding to the target cache sub-area is entered.
3. The method according to claim 1, characterized in that The step of obtaining the data to be cached specifically includes: Get user request; Determining whether the data information corresponding to the user request exists in the cache sub-area; If not, the data information corresponding to the user request is obtained from the data persistence layer to obtain the data to be cached. according to.
4. The method according to claim 1, characterized in that The cache topic is specifically a topic set according to the task type.
5. The method according to claim 4, characterized in that The step of pre-setting a plurality of cache sub-areas in the cache area according to different cache themes specifically includes: Pre-set multiple different cache themes; Classifying different cache topics; A plurality of cache sub-areas are set in the cache area, and the cache subjects belonging to the same category are set in the same cache sub-area.
6. The method according to any one of claims 1 to 5, characterized in that: Further including: Count the number of visits to each cache sub-area within a preset time; When there is a target cache subpartition whose access times are less than a preset times threshold, the cache subject of the target cache subpartition and the cache content in the target cache subpartition are cleared.
7. A data cache device, characterized in that: include: A setting module, used to pre-set multiple cache sub-areas in the cache area according to different cache themes, and set corresponding storage strategies for each of the cache sub-areas; An acquisition module, used for acquiring a data subject of the data to be cached when there is data to be cached; A selection module, configured to select a target cache sub-area by using the corresponding relationship between the data subject and the cache subject; A storage module is used to store the data to be cached using the storage strategy corresponding to the target cache sub-area.
8. A data cache device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data caching method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data caching method according to any one of claims 1 to 6 are implemented.