Search

CN-115543202-B - Cache management method, reading method, system, electronic device and storage medium

CN115543202BCN 115543202 BCN115543202 BCN 115543202BCN-115543202-B

Abstract

The embodiment of the application provides a cache management method, a cache management system, an electronic device and a storage medium, and belongs to the technical field of data interaction. The cache management method comprises the steps of obtaining first target data, obtaining access data of the first target data, determining a first heat value of the first target data according to the access data, determining the first target data with the first heat value being larger than a preset threshold value as heat data, obtaining a heat message list, wherein the heat message list is used for indicating the heat data, obtaining second target data to be cached, and storing the second target data in a first-level cache if the second target data is in the heat message list. The embodiment of the application can improve the response speed of data reading.

Inventors

  • Zeng Peigui

Assignees

  • 中国平安人寿保险股份有限公司

Dates

Publication Date
20260512
Application Date
20221012

Claims (9)

  1. 1. A cache read method, wherein the cache read method is applied to a cache management system, the method comprising: Obtaining a cache data access request of a client; determining fourth target data to be read according to the cache data access request; Acquiring a preset heat message list, wherein the heat message list is used for indicating heat data cached in a first-level cache; If the fourth target data corresponds to the heat data in the heat message list, returning the fourth target data from the first-level cache according to the cache data access request; The cache management system includes: the first data acquisition module is used for acquiring first target data; The heat calculation module is used for acquiring access data of the first target data and determining a first heat value of the first target data according to the access data; the heat data determining module is used for determining the first target data with the first heat value larger than a preset threshold value as heat data; the heat information list acquisition module is used for acquiring a heat information list, wherein the heat information list is used for indicating the heat data; the second data acquisition module is used for acquiring second target data to be cached; and the heat data caching module is used for storing the second target data in a first-level cache if the second target data is in the heat message list.
  2. 2. The cache reading method according to claim 1, wherein the cache management system is configured to implement a cache management method, the cache management method comprising: acquiring first target data; acquiring access data of the first target data, and determining a first heat value of the first target data according to the access data; determining the first target data with the first heat value larger than a preset threshold value as heat data; acquiring a heat information list, wherein the heat information list is used for indicating the heat data; Acquiring second target data to be cached; And if the second target data is in the heat information list, storing the second target data in a first-level cache.
  3. 3. The cache reading method according to claim 2, wherein the determining the first target data having the first heat value greater than a preset threshold as heat data includes: acquiring a preset exclusion list, wherein the exclusion list is used for indicating third target data which is forbidden to be cached to the first-level cache; And when the first heat value is larger than a preset threshold value and the first target data does not correspond to any third target data in the exclusion list, determining that the first target data is heat data.
  4. 4. The cache read method of claim 2, wherein: the step of acquiring the first target data to the step of acquiring the hotness message list are performed periodically; The step of obtaining second target data to be cached and the step of storing the second target data in a first level cache if the second target data is in the hotness message list are performed in a first period, and the method further comprises: determining, in a second period subsequent to the first period, whether the second target data is still in the hotness message list; And if the second target data is not in the hot message list, releasing the second target data from the first-level cache and sending the second target data to a second-level cache.
  5. 5. The cache reading method according to claim 2, wherein the determining the first target data having the first heat value greater than a preset threshold as heat data includes: acquiring a first size of the first-level cache; Acquiring a second size of the first target data; And determining that the first target data is heat data according to the first heat value, the first size and the second size.
  6. 6. The cache read method of claim 5, wherein the determining that the first target data is hot data according to the first hot value, the first size, and the second size comprises: According to the first heat value, arranging the first target data in order from big to small to form a candidate data queue; Sequentially accumulating the second sizes of the first target data in the candidate data queue in a front-to-back order until the accumulated sum exceeds the first size; And removing the last accumulated first target data from the accumulated first target data, and taking the remaining first target data in the candidate data queue as heat data.
  7. 7. The cache read method according to claim 2, wherein the obtaining the access data of the first target data and determining the first heat value of the first target data according to the access data includes: Acquiring access data of the first target data, and obtaining the access times of the first target data in a preset time according to the access data; and determining a first heat value of the first target data according to the access times.
  8. 8. An electronic device comprising a memory storing a computer program and a processor implementing the cache reading method of any of claims 1 to 7 when the computer program is executed by the processor.
  9. 9. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the cache reading method of any one of claims 1 to 7.

Description

Cache management method, reading method, system, electronic device and storage medium Technical Field The present application relates to the field of data interaction, and in particular, to a cache management method, a cache management system, an electronic device, and a storage medium. Background The caches are divided into a local cache and a distributed cache, and the local cache and the distributed cache are generally used together, when the local cache is used as a first-level cache, the reading and writing speed is the fastest, but the relative capacity is limited, and when the distributed cache is used as a second-level cache, the reading and writing speed is relatively slower, but the capacity is large. In the related art, the first-level cache data and the second-level cache data are both predefined, when a large amount of data are accessed, when the data are not in the first-level cache, namely are not in the local cache, a large amount of cache data access requests access the second-level cache, and the response speed of data reading is reduced. Disclosure of Invention The embodiment of the application mainly aims to provide a cache management method, a cache management system, an electronic device and a storage medium, which can improve the response speed of data reading. In order to achieve the above objective, a first aspect of an embodiment of the present application provides a cache management method, which includes obtaining first target data, obtaining access data of the first target data, determining a first heat value of the first target data according to the access data, determining the first target data with the first heat value being greater than a preset threshold value as heat data, obtaining a heat message list, where the heat message list is used to indicate the heat data, obtaining second target data to be cached, and storing the second target data in a first level cache if the second target data is in the heat message list. In some embodiments, the determining the first target data with the first heat value greater than the preset threshold value as heat data includes obtaining a preset exclusion list, where the exclusion list is used to indicate third target data that is prohibited from being cached in the first level cache, and determining that the first target data is heat data when the first heat value is greater than the preset threshold value and the first target data does not correspond to any third target data in the exclusion list. In some embodiments, wherein the steps of obtaining the first target data to obtaining the hot message list are performed periodically, the steps of obtaining the second target data to be cached, and storing the second target data in a first level cache if the second target data is in the hot message list are performed in a first period, the method further comprises determining whether the second target data is still in the hot message list in the second period after the first period, and releasing the second target data from the first level cache and sending the second target data to a second level cache if the second target data is not already in the hot message list. In some embodiments, the determining the first target data with the first popularity value greater than the preset threshold as the popularity data includes obtaining a first size of the first level cache, obtaining a second size of the first target data, and determining the first target data as the popularity data according to the first popularity value, the first size and the second size. In some embodiments, the determining that the first target data is hot data according to the first hot value, the first size and the second size comprises arranging the first target data according to the first hot value from large to small to form a candidate data queue, accumulating the second size of the first target data in the candidate data queue in sequence from front to back until the accumulated sum exceeds the first size, removing the last accumulated first target data from the accumulated first target data, and taking the remaining first target data in the candidate data queue as hot data. In some embodiments, the acquiring the access data of the first target data and determining the first heat value of the first target data according to the access data includes acquiring the access data of the first target data, obtaining the access times of the first target data within a preset time according to the access data, and determining the first heat value of the first target data according to the access times. In order to achieve the above object, a second aspect of the embodiments of the present application provides a cache reading method, which includes obtaining a cache data access request of a client, determining fourth target data to be read according to the cache data access request, obtaining a preset heat message list, where the heat message list is used to indicate heat data c