A cache management method and system for data reading
By determining the call cardinality of memory data based on user historical data, current time and running software information, and determining the accompanying data based on the data to be read for cache optimization, the problem of inefficient cache management in the existing technology is solved, and more efficient is achieved data read and cache management.
Patent Information
- Application Number
- CN202310113392.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2043-02-15
AI Technical Summary
The prior art is difficult to determine the data copied into the cache area based on the actual needs of users, resulting in inefficient cache management.
The call cardinality of each data in memory is determined based on the user's historical data, current time and running software information, and the data is copied into the cache area based on the call cardinality, and the accompanying data is determined based on the data to be read for cache optimization.
It realizes the most needed data into the cache area according to the current needs of users, improving the efficiency of data reading and adaptability of cache management.
Smart Images

Figure CN115981895B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data cache, and in particular to a cache management method and system for data reading. Background Art
[0002] Cache refers to a storage device that can exchange data at high speed. It exchanges data with the CPU before the main memory. The CPU processes data very quickly. A CPU with a main frequency of 1GHz can read and process one billion instructions and data in one second, while the main memory is much slower. There is a huge difference in the reading speed of the main memory and the CPU. The cache is to solve the speed difference between the CPU speed and the main memory speed. The data in the main memory that is most frequently accessed by the CPU will be copied into the cache, so that when the CPU accesses this part of the data, it does not need to go to the main memory to get it. The CPU only needs to go to the cache to get it. However, the data required by the user at every moment will be different. In many cases, the data required is not the most frequently accessed data. At present, it is not possible to determine the data copied into the cache area according to the actual needs of the user. Therefore, it is necessary to provide a cache management method and system for data reading, aiming to solve the above problems. Summary of the invention
[0003] In view of the deficiencies in the prior art, an object of the present invention is to provide a cache management method and system for data reading to solve the problems existing in the above-mentioned background technology.
[0004] The present invention is implemented as follows: a cache management method for data reading, the method comprising the following steps:
[0005] Determine the call base of each piece of data in the memory based on the user's historical data, current time and running software information;
[0006] Copy part of the data in the memory into the first buffer area and the second buffer area according to the call cardinality;
[0007] receiving a data read instruction, wherein the data read instruction includes data to be read, searching the first buffer area, the second buffer area and the memory for the data to be read in sequence, and when the data to be read is found, the CPU processes the data to be read;
[0008] The accompanying data is determined according to the data to be read, part of the data in the second buffer area is cleared, part of the data in the first buffer area is released to the second buffer area, and the accompanying data is copied into the first buffer area.
[0009] As a further solution of the present invention: the step of determining the call cardinality of each piece of data in the memory according to the user's historical data, the current time and the running software information specifically includes:
[0010] Determine the data in the memory that matches the running software according to the running software information, and set a call base value for each matching data;
[0011] Determine the historical reading time information of each matching data according to the user's historical data, and determine the call coefficient according to the historical reading time information and the current time;
[0012] The calling base number of each piece of data is determined based on the calling base value and the calling coefficient.
[0013] As a further solution of the present invention: the step of determining the call coefficient according to the historical reading time information and the current time specifically includes:
[0014] Determine the difference between each historical reading time in the historical reading time information and the current time;
[0015] A call coefficient is determined for the data based on the difference range and the number of historical reading times that meet the difference range.
[0016] As a further solution of the present invention: the step of determining the accompanying data according to the data to be read specifically includes:
[0017] Determine, according to the data to be read and the user's historical data, data that is read simultaneously with the data to be read within a set time difference;
[0018] Each piece of data read at the same time is counted, and when the counted number is greater than the set number value, the corresponding data is determined to be accompanying data.
[0019] As a further solution of the present invention: the method further comprises:
[0020] Receive shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data;
[0021] Receive the shortcut command input by the user, and copy the corresponding read data into the first buffer area.
[0022] Another object of the present invention is to provide a cache management system for data reading, the system comprising:
[0023] A call cardinality determination module, used to determine the call cardinality of each piece of data in the memory according to user historical data, current time and running software information;
[0024] A data replication cache module, used to copy part of the data in the memory into the first cache area and the second cache area according to the call base;
[0025] A data reading processing module is used to receive a data reading instruction, wherein the data reading instruction includes data to be read, and sequentially search for the data to be read from the first buffer area, the second buffer area and the memory. When the data to be read is found, the CPU processes the data to be read;
[0026] The accompanying data cache module is used to determine the accompanying data according to the data to be read, clear part of the data in the second cache area, release part of the data in the first cache area to the second cache area, and copy the accompanying data into the first cache area.
[0027] As a further solution of the present invention: the calling cardinality determination module includes:
[0028] A calling base value determination unit is used to determine the data in the memory that matches the running software according to the running software information, and set a calling base value for each matching data;
[0029] A call coefficient determination unit, used to determine the historical reading time information of each matching data according to the user's historical data, and determine the call coefficient according to the historical reading time information and the current time;
[0030] The calling cardinality determination unit is used to determine the calling cardinality of each piece of data according to the calling base value and the calling coefficient.
[0031] As a further solution of the present invention: the calling coefficient determination unit includes:
[0032] A time difference determination subunit, used to determine the difference between each historical reading time in the historical reading time information and the current time;
[0033] The call coefficient determination subunit is used to determine the call coefficient for the data according to the difference range and the number of historical reading times that meet the difference range.
[0034] As a further solution of the present invention: the accompanying data cache module includes:
[0035] A simultaneous data reading unit, used to determine data to be read simultaneously with the data to be read within a set time difference according to the data to be read and the user's historical data;
[0036] The accompanying data determination unit is used to count each piece of data read simultaneously, and when the counted number is greater than a set number value, determine that the corresponding data is accompanying data.
[0037] As a further solution of the present invention: the system further includes a shortcut instruction cache module, which specifically includes:
[0038] A shortcut command information unit, used to receive shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data;
[0039] The data quick cache unit is used to receive the quick command input by the user and copy the corresponding read data into the first cache area.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] The present invention can determine the call cardinality of each piece of data in the memory according to the user's historical data, the current time and the running software information; and copy part of the data in the memory into the first cache area and the second cache area according to the call cardinality; and determine the accompanying data according to the data to be read, clear part of the data in the second cache area, release part of the data in the first cache area to the second cache area, and copy the accompanying data into the first cache area. The call cardinality can reflect the user's demand for each piece of data in the memory at the current time, thereby ensuring that the data that the user needs to read most is placed in the cache area. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 The present invention is a flowchart of a cache management method for data reading.
[0043] Figure 2 The present invention is a flow chart of determining the call cardinality of each piece of data in the memory according to user historical data, current time and running software information in a cache management method when reading data.
[0044] Figure 3 The present invention is a flow chart of determining a call coefficient according to historical reading time information and current time in a cache management method when reading data.
[0045] Figure 4 The present invention is a flow chart of determining accompanying data according to data to be read in a cache management method during data reading.
[0046] Figure 5 The present invention is a flow chart of receiving shortcut command information input by a user in a cache management method during data reading.
[0047] Figure 6 The figure is a schematic diagram of the structure of a cache management system for data reading.
[0048] Figure 7 The present invention is a structural diagram of calling a cardinality determination module in a cache management system during data reading.
[0049] Figure 8 The present invention is a structural schematic diagram of calling a coefficient determination unit in a cache management system during data reading.
[0050] Fig. 9 The present invention is a structural schematic diagram of an accompanying data cache module in a cache management system during data reading.
[0051] Fig.10 The present invention is a schematic diagram of the structure of a shortcut instruction cache module in a cache management system during data reading. Implementation
[0052] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0053] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.
[0054] like Figure 1 As shown, an embodiment of the present invention provides a cache management method for data reading, the method comprising the following steps:
[0055] S100, determining the call base of each piece of data in the memory according to the user's historical data, the current time and the running software information;
[0056] S200, copying part of the data in the memory into the first buffer area and the second buffer area according to the call base;
[0057] S300, receiving a data read instruction, the data read instruction including data to be read, searching the first cache area, the second cache area and the memory for the data to be read in sequence, and when the data to be read is found, the CPU processes the data to be read;
[0058] S400, determining accompanying data according to the data to be read, clearing part of the data in the second buffer area, releasing part of the data in the first buffer area to the second buffer area, and copying the accompanying data into the first buffer area.
[0059] It should be noted that the cache is used to solve the speed difference between the CPU speed and the memory speed. The data in the memory that is most frequently accessed by the CPU will be copied into the cache, so that when the CPU accesses this data, it does not need to go to the memory to get it. The CPU only needs to get it from the cache. However, the data required by the user at every moment will be different. In many cases, the data required is not the most frequently accessed data. Currently, it is not possible to determine the data to be copied into the cache area based on the actual needs of the user. The embodiments of the present invention aim to solve the above problems.
[0060] In an embodiment of the present invention, the call cardinality of each piece of data in the memory is determined based on the user's historical data, the current time, and the running software information. In this way, the call cardinality can reflect the user's demand for each piece of data in the memory at the current time. In this way, part of the data in the memory is copied into the first cache area and the second cache area according to the call cardinality, ensuring that the data that the user most needs to read is placed in the cache area, the reading speed of the first cache area is greater than the reading speed of the second cache area, and the second cache area will be occupied only after the first cache area is filled. When a data reading instruction input by the user is received, the data to be read will be searched for in the first cache area, the second cache area and the memory in turn. When the data to be read is found, the CPU processes the data to be read. It is easy to understand that the probability of finding the data to be read from the first cache area is the highest, the probability of finding the data to be read from the second cache area is lower, and the probability of finding the data to be read from the memory is the lowest. Furthermore, when the data to be read is processed by the CPU, the embodiment of the present invention will also determine the accompanying data based on the data to be read. The accompanying data is data that is often accessed by the user in the same period as the data to be read, and then clear part of the data in the second cache area. The occupancy of the part of the data is greater than or equal to the occupancy of the accompanying data. Part of the data in the first cache area is released to the second cache area, and the accompanying data is copied into the first cache area. In this way, it better meets user needs.
[0061] like Figure 2 As shown, as a preferred embodiment of the present invention, the step of determining the call cardinality of each piece of data in the memory according to the user's historical data, the current time and the running software information specifically includes:
[0062] S101, determining data in the memory that matches the running software according to the running software information, and setting a call base value for each matching data;
[0063] S102, determining historical reading time information of each matching data according to the user's historical data, and determining a call coefficient according to the historical reading time information and the current time;
[0064] S103, determining the call base of each piece of data according to the call base value and the call coefficient.
[0065] In an embodiment of the present invention, in order to determine the call cardinality, first, the data in the memory that matches the running software is determined based on the running software information, and a call base value is set for each matching data. It is easy to understand that the matching data can be opened by the running software, and the call base value is a fixed value set in advance; then the historical reading time information of each matching data is determined based on the user's historical data, and the call coefficient is determined based on the historical reading time information and the current time. It is easy to understand that the closer the historical reading time is to the current time, the higher the corresponding call coefficient. Finally, the call cardinality of each data is determined based on the call base value and the call coefficient. The call cardinality is equal to the call base value multiplied by the call coefficient. In addition, the data in the memory that does not match the running software has no call cardinality, or the call cardinality is zero.
[0066] like Figure 3 As shown, as a preferred embodiment of the present invention, the step of determining the call coefficient according to the historical reading time information and the current time specifically includes:
[0067] S1021, determining the difference between each historical reading time in the historical reading time information and the current time;
[0068] S1022, determining a call coefficient for the data according to the difference range and the number of historical reading times that meet the difference range.
[0069] In an embodiment of the present invention, in order to determine the call coefficient, it is first necessary to determine the difference between each historical reading time in the historical reading time information and the current time. It should be noted that when calculating the difference, it does not matter which day it is, and all the differences are calculated as the same day. For example, the historical reading times of a certain data are: 9:02, 9:06, 8:50, 9:26, 9:15 and 15:26, and the current time is 9:20, then the obtained differences are: 18 minutes, 14 minutes, 30 minutes, 6 minutes, 5 minutes and 6 hours and 6 minutes respectively. Finally, the call coefficient is determined for the data according to the difference range and the number of historical reading times that meet the difference range. The difference range is a preset fixed value. For example, if the difference range is 20 minutes, there are 4 matching times. The call coefficient is equal to the matching times / the basic number of times, and the basic number of times is a preset fixed value.
[0070] like Figure 4 As shown, as a preferred embodiment of the present invention, the step of determining the accompanying data according to the data to be read specifically includes:
[0071] S401, determining data to be read simultaneously with the data to be read within a set time difference according to the data to be read and the user's historical data;
[0072] S402, counting each piece of data read simultaneously, when the counted number is greater than a set number value, determining that the corresponding data is accompanying data.
[0073] In an embodiment of the present invention, in order to determine accompanying data, it is first necessary to determine the data that is read simultaneously with the data to be read within a set time difference based on the data to be read and the user's historical data. The user's historical data includes all historical read data and the corresponding historical reading time. The set time difference here takes the date into consideration. For example, if the time difference is set to 10 minutes, the data to be read is read at 9:20 on May 2, and the A data is read at 9:18 on May 3, then the A data read at 9:18 on May 3 does not meet the condition. Finally, each piece of data that is read simultaneously is counted. When the counted number is greater than the set number value, the corresponding data is determined to be accompanying data, indicating that the data often appears with the data to be read.
[0074] like Figure 5 As shown, as a preferred embodiment of the present invention, the method further includes:
[0075] S501, receiving shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data;
[0076] S502, receiving a shortcut command input by a user, and copying the corresponding read data into a first buffer area.
[0077] In an embodiment of the present invention, the user can also independently copy data into the first cache area. Specifically, the user needs to input shortcut command information in advance, and the shortcut command information includes several shortcut commands, each shortcut command corresponds to read data; then the user inputs one of the shortcut commands, and the embodiment of the present invention will copy the corresponding read data into the first cache area.
[0078] like Figure 6 As shown, an embodiment of the present invention further provides a cache management system for data reading, the system comprising:
[0079] A call cardinality determination module 100 is used to determine the call cardinality of each piece of data in the memory according to user historical data, current time and running software information;
[0080] The data replication cache module 200 is used to copy part of the data in the memory into the first cache area and the second cache area according to the call base;
[0081] The data reading processing module 300 is used to receive a data reading instruction, wherein the data reading instruction includes data to be read, and sequentially search for the data to be read from the first buffer area, the second buffer area and the memory. When the data to be read is found, the CPU processes the data to be read;
[0082] The accompanying data cache module 400 is used to determine the accompanying data according to the data to be read, clear part of the data in the second cache area, release part of the data in the first cache area to the second cache area, and copy the accompanying data into the first cache area.
[0083] In an embodiment of the present invention, the call cardinality of each piece of data in the memory is determined based on the user's historical data, the current time, and the running software information. In this way, the call cardinality can reflect the user's demand for each piece of data in the memory at the current time. In this way, part of the data in the memory is copied into the first cache area and the second cache area according to the call cardinality, ensuring that the data that the user most needs to read is placed in the cache area, the reading speed of the first cache area is greater than the reading speed of the second cache area, and the second cache area will be occupied only after the first cache area is filled. When a data reading instruction input by the user is received, the data to be read will be searched for in the first cache area, the second cache area and the memory in turn. When the data to be read is found, the CPU processes the data to be read. It is easy to understand that the probability of finding the data to be read from the first cache area is the highest, the probability of finding the data to be read from the second cache area is lower, and the probability of finding the data to be read from the memory is the lowest. Furthermore, when the data to be read is processed by the CPU, the embodiment of the present invention will also determine the accompanying data based on the data to be read. The accompanying data is data that is often accessed by the user in the same period as the data to be read, and then clear part of the data in the second cache area. The occupancy of the part of the data is greater than or equal to the occupancy of the accompanying data. Part of the data in the first cache area is released to the second cache area, and the accompanying data is copied into the first cache area. In this way, it better meets user needs.
[0084] like Figure 7 As shown, as a preferred embodiment of the present invention, the calling cardinality determination module 100 includes:
[0085] A calling base value determining unit 101 is used to determine data in the memory that matches the running software according to the running software information, and set a calling base value for each matching data;
[0086] A call coefficient determination unit 102, configured to determine the historical reading time information of each matching data according to the user's historical data, and determine the call coefficient according to the historical reading time information and the current time;
[0087] The calling cardinality determining unit 103 is used to determine the calling cardinality of each piece of data according to the calling base value and the calling coefficient.
[0088] like Figure 8 As shown, as a preferred embodiment of the present invention, the calling coefficient determination unit 102 includes:
[0089] The time difference determination subunit 1021 is used to determine the difference between each historical reading time in the historical reading time information and the current time;
[0090] The call coefficient determination subunit 1022 is used to determine the call coefficient for the data according to the difference range and the number of historical reading times that meet the difference range.
[0091] like Fig. 9 As shown, as a preferred embodiment of the present invention, the accompanying data cache module 400 includes:
[0092] A simultaneous data reading unit 401, used to determine data to be read simultaneously with the data to be read within a set time difference according to the data to be read and the user's historical data;
[0093] The accompanying data determination unit 402 is used to count each piece of data read simultaneously, and when the counted number is greater than a set number value, determine that the corresponding data is accompanying data.
[0094] like Fig.10 As shown, as a preferred embodiment of the present invention, the system further includes a shortcut instruction cache module 500, and the shortcut instruction cache module 500 specifically includes:
[0095] The shortcut command information unit 501 is used to receive shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data;
[0096] The data quick cache unit 502 is used to receive a quick command input by a user and copy the corresponding read data into the first cache area.
[0097] The above only describes in detail the preferred embodiments of the present invention, which is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0098] It should be understood that, although each step in the flow chart of each embodiment of the present invention is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0099] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0100] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the disclosure in the specification and examples. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A cache management method for data reading, characterized in that: The method comprises the following steps: Determine the call base of each piece of data in the memory based on the user's historical data, current time and running software information; Copy part of the data in the memory into the first buffer area and the second buffer area according to the call cardinality; receiving a data read instruction, wherein the data read instruction includes data to be read, searching the first buffer area, the second buffer area and the memory for the data to be read in sequence, and when the data to be read is found, the CPU processes the data to be read; Determine the accompanying data according to the data to be read, clear part of the data in the second buffer area, release part of the data in the first buffer area to the second buffer area, and copy the accompanying data into the first buffer area; The step of determining the call cardinality of each piece of data in the memory according to the user's historical data, the current time and the running software information specifically includes: Determine the data in the memory that matches the running software according to the running software information, and set a call base value for each matching data; Determine the historical reading time information of each matching data according to the user's historical data, and determine the call coefficient according to the historical reading time information and the current time; Determine the call base number of each piece of data according to the call base value and the call coefficient; The step of determining the call coefficient according to the historical reading time information and the current time specifically includes: Determine the difference between each historical reading time in the historical reading time information and the current time; Determine a call coefficient for the data based on a difference range and the number of historical reading times that meet the difference range; The step of determining the accompanying data according to the data to be read specifically includes: Determine, according to the data to be read and the user's historical data, data to be read simultaneously with the data to be read within a set time difference; Each piece of data read at the same time is counted, and when the counted number is greater than the set number value, the corresponding data is determined to be accompanying data.
2. The cache management method for data reading according to claim 1, characterized in that: The method further comprises: Receive shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data; Receive the shortcut command input by the user, and copy the corresponding read data into the first buffer area.
3. A cache management system for data reading, characterized in that: The system comprises: A call cardinality determination module, used to determine the call cardinality of each piece of data in the memory according to user historical data, current time and running software information; A data replication cache module, used to copy part of the data in the memory into the first cache area and the second cache area according to the call base; A data reading processing module is used to receive a data reading instruction, wherein the data reading instruction includes data to be read, and sequentially search for the data to be read from the first buffer area, the second buffer area and the memory. When the data to be read is found, the CPU processes the data to be read; An accompanying data cache module, used to determine accompanying data according to the data to be read, clear part of the data in the second cache area, release part of the data in the first cache area to the second cache area, and copy the accompanying data into the first cache area; The calling cardinality determination module comprises: A calling base value determination unit is used to determine the data in the memory that matches the running software according to the running software information, and set a calling base value for each matching data; A call coefficient determination unit, used to determine the historical reading time information of each matching data according to the user's historical data, and determine the call coefficient according to the historical reading time information and the current time; A call cardinality determination unit, used to determine the call cardinality of each piece of data according to a call base value and a call coefficient; The calling coefficient determination unit comprises: A time difference determination subunit, used to determine the difference between each historical reading time in the historical reading time information and the current time; A call coefficient determination subunit, used to determine a call coefficient for the data according to a difference range and the number of historical reading times that meet the difference range; The accompanying data cache module includes: A simultaneous data reading unit, used to determine data to be read simultaneously with the data to be read within a set time difference according to the data to be read and the user's historical data; The accompanying data determination unit is used to count each piece of data read simultaneously, and when the counted number is greater than a set number value, determine that the corresponding data is accompanying data.
4. The cache management system for data reading according to claim 3, characterized in that: The system further includes a shortcut instruction cache module, which specifically includes: A shortcut command information unit, used to receive shortcut command information input by a user, wherein the shortcut command information includes a plurality of shortcut commands, and each shortcut command corresponds to read data; The data quick cache unit is used to receive the quick command input by the user and copy the corresponding read data into the first cache area.
Citation Information
Patent Citations
Data caching method and device
CN104808952A
Data processing method, processing device, electronic equipment and storage medium
CN113688160A