Cache management method, reading method, system, electronic device and storage medium
By calculating the popularity value of the target data and storing the popularity data in the first-level cache, the contradiction between data access speed and capacity in the existing technology is resolved, and the data reading response speed and system stability are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA PING AN LIFE INSURANCE CO LTD
- Filing Date
- 2022-10-12
- Publication Date
- 2026-05-12
AI Technical Summary
In existing technologies, there is a contradiction between the data access speed and capacity of the first-level cache and the second-level cache. When data is not in the first-level cache, a large number of access requests will be redirected to the second-level cache, which will reduce the data read response speed, consume network bandwidth, and affect system stability.
By obtaining access data of the target data, the popularity value is calculated, the popular data is filtered out and stored in the first-level cache, and the popular data is indicated by the popular message list, reducing access to the second-level cache and improving the data reading response speed and system stability.
It improves data read response speed, reduces access to the second-level cache, avoids system congestion, and enhances system stability.
Smart Images

Figure CN115543202B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data interaction, and in particular to a cache management method, a reading method, a system, an electronic device, and a storage medium. Background Technology
[0002] Caching is divided into local caching and distributed caching. Generally, the two are used together. When using local caching as the first-level cache, the read and write speed is the fastest, but the capacity is relatively limited. When using distributed caching as the second-level cache, the read and write speed is relatively slower, but the capacity is large.
[0003] In related technologies, first-level and second-level cache data are predefined. When faced with a large number of data access requests, if the data is not in the first-level cache, that is, not in the local cache, a large number of cache data access requests will access the second-level cache, which reduces the response speed of data reading. Summary of the Invention
[0004] The main objective of this application is to provide a cache management method, a reading method, a system, an electronic device, and a storage medium that can improve the response speed of data reading.
[0005] To achieve the above objectives, a first aspect of this application proposes a cache management method, the method comprising: acquiring first target data; acquiring access data of the first target data, and determining a first popularity value of the first target data based on the access data; identifying the first target data whose first popularity value is greater than a preset threshold as popular data; acquiring a popular message list, the popular message list being used to indicate the popular data; acquiring second target data to be cached; and if the second target data is in the popular message list, storing the second target data in a first-level cache.
[0006] In some embodiments, determining the first target data whose first popularity value is greater than a preset threshold as popular data includes: obtaining a preset exclusion list, the exclusion list being used to indicate third target data that is prohibited from being cached in the first-level cache; when the first popularity value is greater than the preset threshold and the first target data does not correspond to any of the third target data in the exclusion list, determining the first target data as popular data.
[0007] In some embodiments, wherein: the step of obtaining the first target data to the step of obtaining the hot message list are executed periodically; the step of obtaining the second target data to be cached and the step of storing the second target data in the first-level cache if the second target data is in the hot message list are executed in the first period, the method further includes: in the second period after the first period, determining whether the second target data is still in the hot message list; if the second target data is no longer in the hot message list, releasing the second target data from the first-level cache and sending it to the second-level cache.
[0008] In some embodiments, determining the first target data whose first popularity value is greater than a preset threshold as popular data includes: obtaining the first size of the first-level cache; obtaining the second size of the first target data; and determining the first target data as popular data based on the first popularity value, the first size, and the second size.
[0009] In some embodiments, determining the first target data as popularity data based on the first popularity value, the first size, and the second size includes: arranging the first target data in descending order according to the first popularity value to form a candidate data queue; sequentially accumulating the second size of the first target data in the candidate data queue in a forward-to-back order until the sum exceeds the first size; removing the last accumulated first target data from the accumulated first target data, and using the remaining first target data in the candidate data queue as popularity data.
[0010] In some embodiments, obtaining access data of the first target data and determining a first popularity value of the first target data based on the access data includes: obtaining access data of the first target data, obtaining the number of times the first target data was accessed within a preset time period based on the access data, and determining a first popularity value of the first target data based on the number of accesses.
[0011] To achieve the above objectives, a second aspect of this application provides a cache reading method, the method comprising: obtaining a cache data access request from a client; determining a fourth target data to be read based on the cache data access request; obtaining a preset hot message list, the hot message list being used to indicate hot data cached in a first-level cache; and if the fourth target data corresponds to the hot data in the hot message list, returning the fourth target data from the first-level cache based on the cache data access request.
[0012] To achieve the above objectives, a third aspect of this application proposes a cache management system, the system comprising: a first data acquisition module for acquiring first target data; a popularity calculation module for acquiring access data of the first target data and determining a first popularity value of the first target data based on the access data; a popularity data determination module for determining the first target data whose first popularity value is greater than a preset threshold as popular data; a popularity message list acquisition module for acquiring a popularity message list, the popularity message list indicating the popular data; a second data acquisition module for acquiring second target data to be cached; and a popularity data caching module for storing the second target data in a first-level cache if the second target data is in the popularity message list.
[0013] To achieve the above objectives, a fourth aspect of the present application provides an electronic device, the electronic device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method described in the first aspect embodiment or the method described in the second aspect embodiment.
[0014] To achieve the above objectives, a fifth aspect of the present application provides a storage medium, which is a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect embodiment or the method described in the second aspect embodiment.
[0015] The cache management method, reading method, system, electronic device, and storage medium proposed in this application, when performing cache management, first calculate a first popularity value based on the access data of the first target data, and then filter the first target data to determine that the first target data with a first popularity value greater than a preset threshold is popular data. In this application, a popularity message list is preset, which can be used to indicate popular data. After receiving the second target data to be cached, if the second target data is in the popularity message list, that is, the popular data indicated in the popularity message list corresponds to the second target data, it means that the second target data is popular data. Therefore, the second target data is stored in the first-level cache. The data in the popularity message list corresponds to the data in the first-level cache. Subsequently, when performing cache reading, if the data to be read is popular data, it can be read from the first-level cache according to the indication of the popularity message list, thereby improving the response speed of data reading. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the structure of the cache management system provided in the embodiments of this application;
[0017] Figure 2This is a flowchart of the cache management method provided in the embodiments of this application;
[0018] Figure 3 yes Figure 2 The flowchart of step S103 in the process;
[0019] Figure 4 This is a flowchart of a cache management method provided in another embodiment of this application;
[0020] Figure 5 yes Figure 2 The flowchart of step S103 in the process;
[0021] Figure 6 yes Figure 5 The flowchart of step S403 in the process;
[0022] Figure 7 yes Figure 2 The flowchart of step S102 in the document;
[0023] Figure 8 This is a flowchart of the cache reading method provided in the embodiments of this application;
[0024] Figure 9 This is a schematic diagram of the functional modules of the cache management system provided in the embodiments of this application;
[0025] Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0027] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0029] First, let's analyze some of the terms used in this application:
[0030] Artificial intelligence (AI) is a new branch of computer science that studies, develops, and applies theories, methods, technologies, and systems to simulate, extend, and expand human intelligence. It aims to understand the essence of intelligence and produce intelligent machines that can react in a way similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thought. Furthermore, AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results.
[0031] Cache is divided into local cache and distributed cache. Generally, the two are used together. Local cache is used as the first-level cache, which has the fastest read and write speed, but the capacity is relatively limited. Examples include Java heap memory cache, Ehcache, and Guava Cache. Distributed cache is used as the second-level cache. Typical implementations include MemCached and Redis.
[0032] The first-level cache is a cache at the Structured Query Language Session (SqlSession) level. When operating the database, a SqlSession object needs to be constructed, and this object contains a data structure for storing cached data. The cached data areas between different SqlSessions are independent of each other. That is, it can only operate within the same SqlSession; caches in different SqlSessions cannot be read from each other. The second-level cache is a mapper-level cache. Multiple SqlSessions can share the second-level cache when operating on the same mapper's SQL statements; the second-level cache is cross-SqlSession.
[0033] In practice, first- and second-level cached data are predefined. When a client initiates a cached data access request, it first checks if the data exists in the first-level cache. If it does, the data is returned; otherwise, the second-level cache is accessed. Therefore, storing frequently accessed, frequently used data in the first-level cache, i.e., the local cache, can improve the response speed of data access.
[0034] However, the applicant discovered that access to data such as information, events, and products is unpredictable. When the actual hot data is not in the first-level cache, that is, not stored in the local cache, a large number of cache data access requests will access the second-level cache, which will occupy a large amount of internal network bandwidth, reduce the response speed of data access, and ultimately affect the stability of the system.
[0035] Based on this, embodiments of this application provide a cache management method, a reading method, a system, an electronic device, and a storage medium, which can improve the response speed of data reading.
[0036] The cache management method, reading method, system, electronic device and storage medium provided in the embodiments of this application are specifically described through the following embodiments. First, the cache management system in the embodiments of this application is described.
[0037] like Figure 1 The diagram shown illustrates the structural design of the cache management system provided in this embodiment, including a client (APP-SDK), a remote cache (RemoteCache), and a management center (ManageCenter). The client can be a user terminal, such as a personal computer, mobile phone, or tablet computer. The client includes an Application Programming Interface (API), a thread pool (threadPool), an exclusion list (excludeList), a hotkey list (hotKeyList), a first-level cache (such as localCache), configuration items, and a Remote Procedure Call (RPC). Specifically, the API can contain multiple interfaces, such as get(key), set(key), and del / expire(key), to retrieve cached data access requests and other data. The configuration items can configure the client's functional parameters. The client's RPC includes modules for data reporting, heartbeat, and hotkey monitoring.
[0038] The remote cache is equipped with multiple remote dictionary services (Redis) for data storage. The management center includes modules such as RPC, task scheduling, heat calculation, monitoring and analysis, parameter configuration, and hotkey pre-configuration.
[0039] The management center can be configured on the server, or in other words, the server can execute the functions of the management center. The RPC settings in the management center have modules for data reception, heartbeat, and push, which interact with the RPC in the client to realize data interaction. The task scheduling module can realize task scheduling configuration, the heat calculation module can calculate the heat value of the data to be cached, and the monitoring and analysis module can continuously monitor and analyze heat data. The parameter configuration module can configure the functional parameters of the management center, and the hotkey preset module can set the threshold for filtering heat data.
[0040] It is understood that the client and management center in this embodiment are set up together and can communicate with each other. The management center and the client can configure the cached data in the client through interaction.
[0041] The cache management system in this embodiment is a cache scheduling center. The client provides an upper-layer API interface to uniformly encapsulate the read and write methods of the cache, shielding the interface differences implemented by different cache technologies. This makes the system in this embodiment transparent to developers, allowing them to focus on the cache location without worrying about it, thus improving development efficiency.
[0042] The cache management system can synchronize the hot message list in real time and place the data in the first-level cache, which is also the local cache. At the same time, it maintains an exclusion list to match front-end access requests. If the data is in the hot message list, it is directly retrieved from the local cache and returned, thereby improving the response speed of data reading. In addition, since a large amount of hot data can be retrieved from the first-level cache according to the instructions of the hot message list, the access of a large number of data access requests to the second-level cache is reduced, thereby reducing the network bandwidth consumption and avoiding system congestion caused by a large number of data access requests accessing the second-level cache, thus improving system stability.
[0043] The cache management system can collect cache data access request information, push all cache data requests from clients to the message queue through log collection, API push, and other methods, perform statistical analysis on the cache data, start big data real-time computing tasks, consume access data in the message queue, obtain the number of accesses to cache data per unit time from the logs, and calculate the current popularity value of the cache data in real time.
[0044] The management center in the cache management system maintains real-time communication with clients through heartbeat data, initiates tasks, reads data popularity values calculated by big data tasks, updates the popularity message list, monitors the client's cache status in real time based on the actual configuration size of the client's local cache, intelligently pushes new high-popularity data, and evicts low-popularity data. It also supports manual configuration to realize the cache data pre-configuration function, further improving the robustness of the system.
[0045] The cache management method in this application can be illustrated through the following embodiments.
[0046] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0047] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0048] The cache management method provided in this application relates to the field of artificial intelligence technology. The cache management and reading methods provided in this application can be applied to terminals or servers, and can also be software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the cache management method, but is not limited to the above forms.
[0049] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0050] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. For example, when obtaining user-stored data and user cached data access requests, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of this application need to obtain sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to a confirmation page. Only after obtaining the user's separate permission or consent is the necessary user-related data for the normal operation of the embodiments of this application obtained.
[0051] Figure 2 This is an optional flowchart of the cache management method provided in the embodiments of this application. Figure 2 The method may include, but is not limited to, steps S101 to S106.
[0052] Step S101: Obtain the first target data;
[0053] For example, the cache management method in this application embodiment can be applied to the cache management system described above, for example, it can be applied to the management center described above.
[0054] In this embodiment of the application, first target data can be obtained. First target data is a medium of symbols that can be input into a computer and processed by a computer program. It is a general term for numbers, letters, symbols, and analog quantities that are used to input into an electronic computer for processing and have a certain meaning. First target data is the form and carrier of information, and can be data such as symbols, text, numbers, voice, images, and videos.
[0055] There are several ways to obtain the first target data. For example, the first target data can be user input data, which the user can input in the client and then send to the management center through the client; or, the first target data can be data generated by the cache management system during the execution of any program, which can be used to determine the content of the first-level cache.
[0056] Step S102: Obtain access data for the first target data, and determine the first popularity value of the first target data based on the access data;
[0057] For example, in the embodiments of this application, access data of the first target data can be obtained. Access data is a kind of data that indicates the access status of the first target data. Access data can be the data generated when the first target data provided by the client is accessed within a unit of time, and it is the access record of the user accessing the first target data.
[0058] Access data can take many forms. For example, access data can be the number of times the first target data is accessed; access frequency can be calculated based on the number of times the first target data is accessed per unit time, and the access frequency can be used as access data; or, access data can be the access time of the first target data, including specific time points within a day or week; or, access data can be the access duration of the first target data. This application embodiment does not impose specific limitations.
[0059] For example, a first popularity value can be determined based on the access data of the first target data. In this embodiment of the application, by determining the first popularity value of the first target data, the importance of the first target data can be indicated. The first target data with a high first popularity value indicates that it is important or that users frequently need to access it.
[0060] There are many ways to determine the first popularity value based on access data. For example, in this embodiment, access data can be used as the first popularity value. When the access data is the number of visits, the number of visits can be used as the first popularity value; when the access data is the access time, different numerical values can be determined according to the access time in different time periods, and then the obtained values can be used as the first popularity value; when the access data is the access duration, the access duration can be used as the first popularity value. Furthermore, there can be multiple access data sets in this embodiment. When there are multiple access data sets, a weighted calculation can be performed based on the weights of different access data sets to obtain the first popularity value. For example, when the access data includes the aforementioned number of visits, access time, and access duration, the values corresponding to the number of visits, access time, and access duration can be multiplied by their respective weights, and then weighted to obtain the first popularity value.
[0061] Step S103: The first target data whose first heat value is greater than the preset threshold is determined as heat data;
[0062] For example, the first target data is filtered through the embodiments of this application, and only those with a first popularity value greater than a preset threshold are determined to be popular data. For popular data, this application needs to improve the response capability of reading popular data, so determining popular data helps to improve the reading speed of popular data in the future. For the first target data with a first popularity value less than the preset threshold, this application judges it as data other than popular data. For this type of data, this application does not require it to have a high reading response speed, so subsequent steps do not need to process it specifically.
[0063] It should be noted that popularity data refers to data frequently accessed by users. The preset threshold is a pre-defined threshold for popularity, which can be a numerical value. For example, when the number of visits is used as the primary popularity value, the popularity threshold can be a preset number of visits to limit the popularity data; when the value obtained based on the visit time is used as the primary popularity value, the popularity threshold can be a preset value to limit the popularity data; when the visit duration is used as the primary popularity value, the popularity threshold can be a preset duration to limit the popularity data.
[0064] By setting a preset threshold, the required popularity data in this application embodiment can be filtered out, thereby improving the ability to judge popularity data. It is understood that the preset threshold can be set according to actual storage needs, and no specific restrictions are imposed in this application embodiment.
[0065] Step S104: Obtain the list of trending messages. The list of trending messages is used to indicate trending data.
[0066] For example, in this embodiment of the application, a hot message list is pre-set, which can be used to indicate hot data. The hot message list is an information queue that stores information. The hot message list can be pre-configured in the cache management system. For example, the hot message list can be pre-configured in the management center. The management center can also send the hot message list to the client so that the client can also perform cache management according to the preset hot message list.
[0067] There are many ways to indicate trending data in a trending message list. For example, a trending message list can store the identification information of the first target data that is determined to be trending data, and use the stored identification information to indicate the trending data. The identification information can be the data name or header information, etc. Alternatively, the first target data that is determined to be trending data can be directly stored in the trending message list, and the trending data can be indicated by storing the data file of the first target data.
[0068] Step S105: Obtain the second target data to be cached;
[0069] For example, after determining the popularity data and indicating the popularity data through the popularity message list, the data to be cached can be filtered in this application embodiment. The data to be cached in this application embodiment is called the second target data.
[0070] The second target data is the data that needs to be stored during the caching process. Similar to the first target data, the second target data is a medium of symbols that can be input into a computer and processed by a computer program. It is a general term for numbers, letters, symbols, and analog quantities that have certain meanings and are used to input into an electronic computer for processing. The second target data is also a form of information representation and carrier, which can be data such as symbols, text, numbers, voice, images, and videos.
[0071] There are many ways to obtain secondary target data. Secondary target data can be obtained by the client or the management center. For example, secondary target data can be user input data; the user can input the secondary target data in the client and then send it to the management center through the client. Alternatively, the user can directly input the secondary target data in the management center, and then the management center will send the secondary target data to the client. Furthermore, secondary target data can also be data that needs to be stored, generated by the cache management system during the execution of any program.
[0072] Step S106: If the second target data is in the hot message list, store the second target data in the first-level cache.
[0073] For example, in the caching process of the second target data in this embodiment, it is necessary to determine whether the second target data is popular data. Specifically, after receiving the second target data to be cached, if the second target data is in the popular message list, that is, if the popular data indicated in the popular message list corresponds to the second target data, it indicates that the second target data is popular data. Therefore, the second target data is stored in the first-level cache, so that the data in the popular message list corresponds to the data in the first-level cache. In this embodiment, the popular message list can be updated and maintained according to the first target data, and the second target data to be cached can be judged so that data that meets the requirements can be included in the first-level cache.
[0074] It should be noted that the first-level cache is the client's local cache, which is the cache most closely integrated with the client's processor.
[0075] When the second target data is obtained from the management center, there are several ways to store it in the first-level cache. For example, the management center can send the second target data to the client, so that the client can determine whether the second target data is in the hot message list, and if the result is yes, store the second target data in the client's first-level cache; the management center can also directly determine whether the second target data is in the hot message list, and if the result is yes, send an instruction message and the second target data to the client, so that the client stores the second target data in its first-level cache according to the instruction message.
[0076] When the second target data is obtained by the client, there are several ways to store it in the first-level cache. For example, if the client has a list of trending messages obtained from the management center, the client can directly determine whether the second target data is in the list, and if the result is yes, store the second target data in the client's first-level cache. Alternatively, if the client does not have a list of trending messages stored, the client can send the second target data, or its identifier, to the management center after obtaining it. The management center can then determine whether the second target data is in the list based on the received second target data or its identifier, and if the result is yes, send an instruction to the client, causing the client to store the second target data in its first-level cache according to the instruction.
[0077] For example, during the cache read phase, the client can read cached data based on the list of popular messages. For instance, when the client stores a list of popular messages, upon receiving a cached data access request, it first checks if there is corresponding data in the list. If so, it means the data to be read is popular data, which is the second target data pre-stored in the first-level cache, and the data is returned from the first-level cache. If not, it means the data to be read is not popular data, and the data needs to be returned from the second-level cache or other caches.
[0078] When the client does not store a list of trending messages, after receiving a cached data access request, the client can send the request to the management center to check if there is corresponding data in the management center's list of trending messages. If there is, it means that the data to be read is trending data, which is the second target data pre-stored in the first-level cache. The management center then sends an instruction to the client, and the client returns the data from the first-level cache. If there is no data, it means that the data to be read is not trending data. The management center then sends an instruction to the client, instructing the client to return the data from the second-level cache or other caches.
[0079] In this embodiment, a cache management method is implemented to configure popularity data. Popularity data is aggregated through a popularity message list, and the popularity data indicated in the popularity message list is synchronously stored in the first-level cache. After configuration, when the client faces a large amount of popularity data access, it can directly return data from the first-level cache, thereby improving the response speed of data reading. In addition, since a large amount of popularity data can be obtained from the first-level cache according to the indication of the popularity message list, the access of a large number of data access requests to the second-level cache is reduced, thereby reducing the occupation of network bandwidth, avoiding system blockage caused by a large number of data access requests accessing the second-level cache, and improving system stability.
[0080] Please see Figure 3 In some embodiments, step S103 may include steps S201 to S202:
[0081] Step S201: Obtain a preset exclusion list. The exclusion list is used to indicate third-target data that should not be cached in the first-level cache.
[0082] Step S202: When the first heat value is greater than the preset threshold and the first target data does not correspond to any third target data in the exclusion list, the first target data is determined to be heat data.
[0083] For example, in this embodiment of the application, an exclusion list is also maintained to exclude data that does not need to be stored in the hot message list. The exclusion list is an information queue that stores information. The exclusion list can be pre-configured in the cache management system. For example, the exclusion list can be pre-configured in the management center. The management center can also send the exclusion list to the client so that the client can also perform cache management according to the preset exclusion list.
[0084] In this embodiment, the data prohibited from being cached in the first-level cache is described as third-target data. The data type of the third-target data is the same as that of the first and second-target data; both are symbolic media that can be input into a computer and processed by a computer program. They are a general term for numbers, letters, symbols, and analog quantities that have a certain meaning and are used for input into a computer for processing. Third-target data is also a form of information representation and carrier, and can be data such as symbols, text, numbers, voice, images, and video. For example, the third-target data can be the key of some distributed locks, or data that requires special processing, which can be configured through operational procedures. This embodiment does not impose specific limitations on this.
[0085] There are many ways to obtain third-party target data. Third-party target data can be obtained by the client or the management center. For example, third-party target data can be user input data, which the user can enter in the client and then send to the management center; alternatively, the user can directly enter the third-party target data in the management center, which will then send it to the client. Furthermore, third-party target data can also be data generated by the cache management system during the execution of any program, indicating that it does not need to be stored.
[0086] For example, there are several ways in which the exclusion list indicates the third target data in the embodiments of this application. For instance, the exclusion list can store the identification information of the third target data, and the third target data can be indicated by storing the identification information, such as data name or header information; or, the third target data can be directly stored in the exclusion list, and the third target data can be indicated by storing the data file of the third target data.
[0087] It should be noted that, in the data storage stage of this application embodiment, when judging the first target data, it can be determined whether the first target data corresponds to any third target data in the exclusion list. When the two correspond, even if the first popularity value is high, the first target data will no longer be considered as popularity data, and the popularity value of the first target data will not be judged subsequently. However, when the first target data does not correspond to any third target data in the exclusion list, it means that the first target data does not need to be excluded. Therefore, it can be determined whether the first target data meets the criteria for being considered popularity data. When the first popularity value is greater than a preset threshold, the first target data is determined to be popularity data. By maintaining an exclusion list in this application embodiment, some unnecessary cached data can be avoided from being stored in the popularity message list.
[0088] For example, in this embodiment of the application, steps S101 to S104 are executed periodically. During the periodic execution, the first target data that meets the conditions is determined as the popularity data, and the popularity message list is continuously updated and maintained. For example, in a certain period, a first target data is determined as the popularity data and indicated by the popularity message list. In the next period, if a new first target data is determined as the popularity data, the popularity data indicated by the popularity message list may change.
[0089] Furthermore, in the embodiments of this application, steps S105 to S106 are also executed periodically. In one embodiment, the period of a certain execution of steps S105 to S106 is described as the first period. The first period can be the first execution period of the cache management method in the embodiments of this application, or it can be any period of the cache management method executed periodically. No specific restrictions are placed on this.
[0090] Please see Figure 4 In some embodiments, the cache management method may further include steps S301 to S302:
[0091] Step S301: In the second cycle following the first cycle, determine whether the second target data is still in the hot message list;
[0092] In step S302, if the second target data is no longer in the hot message list, the second target data is released from the first-level cache and sent to the second-level cache.
[0093] For example, the storage status of the popularity data list and the first-level cache in this application embodiment is not static, but constantly updated. When new cached data comes in, the new cached data can be judged to determine whether to update the popularity message list and the first-level cache.
[0094] Specifically, in the periodic execution steps S101 to S104 of this application embodiment, the first target data in each execution cycle can be continuously judged, and the first target data that meets the conditions can be determined as popular data. For example, in a certain cycle, a first target data can be determined as popular data and indicated through a popular message list. In the next cycle, if a new first target data is determined as popular data, the popular data determined in the next cycle can be indicated through a popular message list.
[0095] Therefore, if the second target data is in the popularity data list in the first period, the second target data is stored in the first-level cache. In the subsequent second period, it is necessary to determine whether the popularity message list has changed. The second period is any period after the first period. When the popularity message list changes in the second period and the indicated popularity data no longer contains the second target data, it means that the second target data in the second period is no longer popularity data. Therefore, the second target data is released from the first-level cache and sent to the second-level cache or other caches. In this embodiment, sending to the second-level cache is taken as an example.
[0096] This application embodiment improves the system's adaptability and ensures the system's responsiveness to trending data by continuously receiving new cached data and continuously updating the trending message list and first-level cache.
[0097] Please see Figure 5 In some embodiments, step S103 may include steps S401 to S403:
[0098] Step S401: Obtain the first size of the first-level cache;
[0099] Step S402: Obtain the second size of the first target data;
[0100] Step S403: Determine the first target data as heat data based on the first heat value, the first size, and the second size.
[0101] For example, in the process of determining the popularity data in this embodiment, it is necessary to combine the data size of the first-level cache and the data size of the first target data to be cached. Specifically, in the process of determining the popularity data in this embodiment, the cache space size of the first-level cache can be obtained firstly and described as a first size, and the data size of the first target data can be obtained and described as a second size. Then, based on the first popularity value, the first size and the second size, the first target data is determined to be the popularity data. This embodiment can determine the popularity data by adding data length to popularity. By considering the storage space of the first-level cache and the data size of the first target data to be cached, the caching mechanism of the first-level cache and the popularity message list can be made more reasonable.
[0102] There are several ways to obtain the initial size of the first-level cache. For example, the user can enter the initial size in the client or management center; or, the client or management center can scan the storage space of the first-level cache in the client to obtain the initial size.
[0103] There are several ways to obtain the second size of the first target data. For example, the user can input the second size in the client or management center; or, the client or management center can scan the data file of the first target data to obtain the second size; or, the first target data contains a field that stores the second size information, and the client or management center can read this field to obtain the second size.
[0104] Specifically, by considering the storage space of the first-level cache and the size of the first target data to be cached, it is possible to determine which first target data with a first popularity value greater than a preset threshold can be considered as popular data. For example, if the sum of the second sizes of multiple first target data with first popularity values greater than the preset threshold is greater than the first size of the first-level cache, it is necessary to further determine whether some first target data needs to be discarded, and further determine which first target data can be used as popular data; if the sum of the second sizes of multiple first target data with first popularity values greater than the preset threshold is less than the first size of the first-level cache, then all of these first target data can be determined as popular data.
[0105] This application embodiment can record the storage space of the first-level cache and the data size of the first target data, and record the changes in the storage space size in the first-level cache so that corresponding adjustments can be made when it approaches saturation.
[0106] Please see Figure 6 In some embodiments, step S403 may include steps S501 to S503:
[0107] Step S501: Arrange the first target data in descending order according to the first heat value to form a candidate data queue;
[0108] Step S502: In order from front to back, the second size of the first target data in the candidate data queue is accumulated until the sum exceeds the first size;
[0109] Step S503: Remove the last accumulated first target data from the accumulated first target data, and use the remaining first target data in the candidate data queue as the heat data.
[0110] For example, in this embodiment, the hot message list is updated based on the heat value and the data length value. Specifically, in this embodiment, multiple first target data to be cached can be received. The multiple data are judged. If the first heat value is greater than a preset threshold, the corresponding first target data is not directly determined as hot data. At this time, the storage capacity of the first-level cache needs to be considered. In this embodiment, each first target data is also arranged according to the first heat value. The candidate data queue is obtained in descending order of the first heat value. For example, this application arranges the candidate data queue in descending order according to the size of the first heat value corresponding to each first target data. Then, the second size of the first target data in the candidate data queue is accumulated in the order from front to back to obtain the accumulated value.
[0111] It should be noted that when the above accumulated value is less than the first size, it means that the sum of the data sizes of the first target data determined at this time has not exceeded the storage limit of the first-level cache. Therefore, these first target data can be directly identified as hot data, and the resulting hot message list can be pushed to the client. The client can then configure the corresponding first target data into the first-level cache according to the hot message list.
[0112] When the accumulated value exceeds the first size, it indicates that the sum of the sizes of the first target data determined at this time exceeds the storage limit of the first-level cache. If all these first target data are determined as hot data and ultimately cached in the first-level cache, it will exceed the storage capacity of the first-level cache and affect the stability of the system. Therefore, in this embodiment, the last accumulated first target data is removed from the accumulated first target data, and the remaining first target data in the candidate data queue is used as hot data. For example, in this embodiment, after arranging the data sizes of the first target data in the candidate data queue, the hot value of the first target data at the end of the queue is less than the hot values of all the first target data before it. Therefore, the first target data is removed, and the first target data with a higher hot value is used as hot data.
[0113] It should be noted that, when removing the first target data at the tail of the queue, if the size of the removed first target data at the tail is still too small, such that the sum of the second sizes of the first target data before the candidate data queue still exceeds the first size, then it is necessary to remove the first target data at the tail of the queue again, so that the final sum of the second sizes is less than the first size.
[0114] In this embodiment, the popularity data is determined by the first size and the second size, which ensures that the first target data indicated in the popularity message list is always popular and will not exceed the storage capacity of the first-level cache, thus guaranteeing the stability of the cache.
[0115] Furthermore, it is understood that in this application embodiment, it is also possible to determine whether a certain first target data received later is hot data. When the sum of the second sizes of the first target data indicated in the hot message list is close to the first size and the storage of the first-level cache is saturated, the first hot value of the newly received first target data is compared with the first hot value of the first target data already in the hot message list. If it is greater than the first target data that is ranked last in the hot message list, that is, the first target data with the smallest first hot value, is removed, and the newly received first target data is determined to be hot data.
[0116] This application embodiment realizes real-time monitoring of cache status based on the actual configuration size of the cache, intelligently pushing new high-popularity data and eliminating low-popularity data.
[0117] It is understood that in this embodiment of the application, user configuration information can also be obtained, and new first target data can be set as popularity data according to the user configuration information, or the first target data that needs to be deleted from the popularity message list can be determined according to the configuration information. This embodiment of the application does not impose specific restrictions on this.
[0118] In some embodiments, please refer to Figure 7 Step S102 may include steps S601 to S602:
[0119] Step S601: Obtain access data of the first target data, and obtain the number of times the first target data was accessed within a preset time based on the access data;
[0120] Step S602: Determine the first popularity value of the first target data based on the number of visits.
[0121] There are multiple ways to obtain access data. For example, access data can be obtained by parsing the logs of the cache management system. Specifically, the client and the management center can store logs from daily operations. By parsing these logs, the access data in this embodiment can be obtained. The cache management system in this embodiment can record each access to the first target data in the logs. By recording the access to the first target data in the logs, for example, the number of times the first target data is accessed can be recorded; or, the access data can be obtained by the user inputting it in the client or the management center; or, the client or the management system can directly accumulate the access to the first target data. For example, the access count can be counted each time the first target data is accessed, and the number of times the first target data is accessed can be used as access data. Similarly, the access time of each access to the first target data can be accumulated to obtain the access duration of the first target data and used as access data.
[0122] There are multiple ways to obtain logs in this application embodiment. For example, the client or management center can obtain log data through interface push and push it to the message queue in the client or management center for parsing; in addition, logs can also be pushed to the message queue asynchronously, without specific restrictions.
[0123] This application embodiment can parse the access data stored within a preset time period to obtain the number of times the first target data is accessed within the preset time period, calculate the access frequency of the first target data based on the number of accesses and the preset time period, and use the calculated access frequency as the first popularity value of the corresponding first target data; or, in this application embodiment, the number of accesses can be directly used as the first popularity value.
[0124] In this embodiment, the first popularity value of the first target data is determined based on the number of times the first target data is accessed within a preset time. This allows subsequent determination of whether the first target data is popular based on the number of times it is accessed. Ultimately, the first target data with a high number of accesses can be identified as popular data. With the configuration described above, since a large amount of popular data can be obtained from the first-level cache according to the indication of the popular message list, the access of a large number of data access requests to the second-level cache is reduced, thereby reducing the occupation of network bandwidth, avoiding system congestion caused by a large number of data access requests accessing the second-level cache, and improving system stability.
[0125] Figure 8 This is an optional flowchart of the cache reading method provided in the embodiments of this application. Figure 8 The method may include, but is not limited to, steps S701 to S704.
[0126] Step S701: Obtain the client's cached data access request;
[0127] Step S702: Determine the fourth target data to be read based on the cached data access request;
[0128] Step S703: Obtain a preset list of trending messages. The list of trending messages is used to indicate trending data cached in the first-level cache.
[0129] Step S704: If the fourth target data corresponds to the hot data in the hot message list, return the fourth target data from the first-level cache according to the cache data access request.
[0130] For example, the cache reading method in this application embodiment can be applied in the cache management system described above. For instance, it can be applied in the client described above to obtain a cache data access request, query and return the required cache data.
[0131] In this embodiment of the application, a cache data access request from the client can be obtained. A cache data access request is a data request used to request the required cache data. The cache data access request can be entered by the user in the client.
[0132] For example, the client can determine the fourth target data to be read based on the cached data access request. The cached data access request can carry the identification information of the cached data to be read. By parsing the identification information, the fourth target data to be read can be determined. Alternatively, the client can query a preset lookup table based on the cached data access request. The lookup table can indicate the correspondence between different requests and the corresponding cached data, thereby determining the fourth target data to be read.
[0133] Fourth target data is a medium of symbols that can be input into a computer and processed by computer programs. It is a general term for numbers, letters, symbols, and analog quantities that are used to input into electronic computers for processing and have certain meanings. Fourth target data is the form and carrier of information, and can be data such as symbols, text, numbers, voice, images, and video.
[0134] For example, in this embodiment of the application, a pre-set hot message list can be used to indicate hot data. The hot message list is an information queue that stores information. The hot message list can be pre-configured in a cache management system; for example, it can be pre-configured in a management center. The management center can also send the hot message list to clients, allowing clients to perform cache management based on the pre-set hot message list. There are many ways to indicate hot data using a hot message list, and these methods will not be elaborated upon here.
[0135] For example, during the cache reading phase, the client can read cached data based on the list of trending messages. For instance, when the client stores a list of trending messages, upon receiving a cached data access request, it first checks if there is corresponding data in the list. If so, it means the fourth target data to be read is trending data, which is pre-stored in the first-level cache, and the data is returned from the first-level cache. If not, it means the data to be read is not trending data, and the data needs to be returned from the second-level cache or other caches.
[0136] When the client does not store a list of trending messages, after receiving a cached data access request, the client can send the request to the management center to check if there is corresponding fourth target data in the management center's list of trending messages. If there is, it means that the fourth target data to be read is trending data, which is pre-stored in the first-level cache. The management center then sends an instruction to the client, and the client returns the data from the first-level cache. If there is no data, it means that the data to be read is not trending data. The management center then sends an instruction to the client, instructing the client to return the data from the second-level cache or other caches.
[0137] This application embodiment implements the configuration of popularity data, summarizes popularity data through a popularity message list, and synchronously stores the popularity data in the popularity message list in the first-level cache. After the configuration of this application, when the client is faced with a large amount of popularity data access, it can directly return data from the first-level cache, thereby improving the response speed of data reading.
[0138] Please see Figure 9This application also provides a cache management system that can implement the above-described cache management method. The cache management system includes:
[0139] The first data acquisition module 901 is used to acquire the first target data;
[0140] The heat calculation module 902 is used to obtain access data of the first target data and determine the first heat value of the first target data based on the access data.
[0141] The heat data determination module 903 is used to determine the first target data whose first heat value is greater than a preset threshold as heat data;
[0142] The hot message list acquisition module 904 is used to acquire the hot message list, which is used to indicate the hotness data;
[0143] The second data acquisition module 905 is used to acquire the second target data to be cached;
[0144] The heat data caching module 906 is used to store the second target data in the first-level cache if the second target data is in the heat message list.
[0145] For example, the cache management system in this application embodiment can execute the above cache management method. The cache management system includes the management center in the above embodiment. The management center can be connected to the client, which will not be described in detail here.
[0146] For example, the first data acquisition module 901 in this application embodiment can acquire first target data. First target data is a medium of symbols that can be input into a computer and processed by a computer program. It is a general term for numbers, letters, symbols, and analog quantities that are used to input into an electronic computer for processing and have a certain meaning. First target data is the form and carrier of information, and can be data such as symbols, text, numbers, voice, images, and videos.
[0147] There are several ways to obtain the first target data. For example, the first target data can be user input data, which the user can input in the client and then send to the management center through the client; or, the first target data can be data generated by the cache management system during the execution of any program, which can be used to determine the content of the first-level cache.
[0148] For example, the heat calculation module 902 in this application embodiment can obtain access data of the first target data. Access data is a kind of data that indicates the access status of the first target data. Access data can be the data generated when the first target data provided by the client is accessed within a unit of time, and it is the access record of the user accessing the first target data.
[0149] Access data can take many forms. For example, access data can be the number of times the first target data is accessed; access frequency can be calculated based on the number of times the first target data is accessed per unit time, and the access frequency can be used as access data; or, access data can be the access time of the first target data, including specific time points within a day or week; or, access data can be the access duration of the first target data. This application embodiment does not impose specific limitations.
[0150] For example, a first popularity value can be determined based on the access data of the first target data. In this embodiment of the application, by determining the first popularity value of the first target data, the importance of the first target data can be indicated. The first target data with a high first popularity value indicates that it is important or that users frequently need to access it.
[0151] There are many ways to determine the first popularity value based on access data. For example, in this embodiment, access data can be used as the first popularity value. When the access data is the number of visits, the number of visits can be used as the first popularity value; when the access data is the access time, different numerical values can be determined according to the access time in different time periods, and then the obtained values can be used as the first popularity value; when the access data is the access duration, the access duration can be used as the first popularity value. Furthermore, there can be multiple access data sets in this embodiment. When there are multiple access data sets, a weighted calculation can be performed based on the weights of different access data sets to obtain the first popularity value. For example, when the access data includes the aforementioned number of visits, access time, and access duration, the values corresponding to the number of visits, access time, and access duration can be multiplied by their respective weights, and then weighted to obtain the first popularity value.
[0152] For example, the popularity data determination module 903 in this application embodiment is used to determine the first target data whose first popularity value is greater than a preset threshold as popular data. The first target data is determined to be popular data only if its first popularity value is greater than the preset threshold through the filtering in this application embodiment. For popular data, this application needs to improve the response capability of reading popular data. Therefore, determining popular data helps to improve the reading speed of popular data in the future. For the first target data whose first popularity value is less than the preset threshold, this application judges it as data other than popular data. For this type of data, this application embodiment does not require it to have a relatively high reading response speed. Therefore, subsequent steps do not need to process it specifically.
[0153] It should be noted that popularity data refers to data frequently accessed by users. The preset threshold is a pre-defined threshold for popularity, which can be a numerical value. For example, when the number of visits is used as the primary popularity value, the popularity threshold can be a preset number of visits to limit the popularity data; when the value obtained based on the visit time is used as the primary popularity value, the popularity threshold can be a preset value to limit the popularity data; when the visit duration is used as the primary popularity value, the popularity threshold can be a preset duration to limit the popularity data.
[0154] By setting a preset threshold, the required popularity data in this application embodiment can be filtered out, thereby improving the ability to judge popularity data. It is understood that the preset threshold can be set according to actual storage needs, and no specific restrictions are imposed in this application embodiment.
[0155] For example, the hot message list acquisition module 904 in this embodiment of the application is used to acquire a hot message list. The hot message list is used to indicate hot data. By pre-setting the hot message list, the hot message list can be used to indicate hot data. The hot message list is an information queue that stores information. The hot message list can be pre-configured in the cache management system. For example, the hot message list can be pre-configured in the management center. The management center can also send the hot message list to the client so that the client can also perform cache management according to the preset hot message list.
[0156] There are many ways to indicate trending data in a trending message list. For example, a trending message list can store the identification information of the first target data that is determined to be trending data, and use the stored identification information to indicate the trending data. The identification information can be the data name or header information, etc. Alternatively, the first target data that is determined to be trending data can be directly stored in the trending message list, and the trending data can be indicated by storing the data file of the first target data.
[0157] For example, in this embodiment of the application, the second data acquisition module 905 is used to acquire second target data to be cached. After determining the popularity data and indicating the popularity data through the popularity message list, the data to be cached can be filtered in this embodiment of the application. The data to be cached in this embodiment of the application is called the second target data.
[0158] The second target data is the data that needs to be stored during the caching process. Similar to the first target data, the second target data is a medium of symbols that can be input into a computer and processed by a computer program. It is a general term for numbers, letters, symbols, and analog quantities that have certain meanings and are used to input into an electronic computer for processing. The second target data is also a form of information representation and carrier, which can be data such as symbols, text, numbers, voice, images, and videos.
[0159] There are many ways to obtain secondary target data. Secondary target data can be obtained by the client or the management center. For example, secondary target data can be user input data; the user can input the secondary target data in the client and then send it to the management center through the client. Alternatively, the user can directly input the secondary target data in the management center, and then the management center will send the secondary target data to the client. Furthermore, secondary target data can also be data that needs to be stored, generated by the cache management system during the execution of any program.
[0160] For example, the popularity data caching module 906 in this embodiment can store the second target data in the first-level cache. During the caching process of the second target data, it is necessary to determine whether the second target data is popularity data. Specifically, after receiving the second target data to be cached, if the second target data is in the popularity message list, that is, if the popularity data indicated in the popularity message list corresponds to the second target data, it indicates that the second target data is popularity data. Therefore, the second target data is stored in the first-level cache, so that the data in the popularity message list corresponds to the data in the first-level cache. In this embodiment, the popularity message list can be updated and maintained according to the first target data, and the second target data to be cached can be judged so that data that meets the requirements is used as data in the first-level cache.
[0161] It should be noted that the first-level cache is the client's local cache, which is the cache most closely integrated with the client's processor.
[0162] When the second target data is obtained from the management center, there are several ways to store it in the first-level cache. For example, the management center can send the second target data to the client, so that the client can determine whether the second target data is in the hot message list, and if the result is yes, store the second target data in the client's first-level cache; the management center can also directly determine whether the second target data is in the hot message list, and if the result is yes, send an instruction message and the second target data to the client, so that the client stores the second target data in its first-level cache according to the instruction message.
[0163] When the second target data is obtained by the client, there are several ways to store it in the first-level cache. For example, if the client has a list of trending messages obtained from the management center, the client can directly determine whether the second target data is in the list, and if the result is yes, store the second target data in the client's first-level cache. Alternatively, if the client does not have a list of trending messages stored, the client can send the second target data, or its identifier, to the management center after obtaining it. The management center can then determine whether the second target data is in the list based on the received second target data or its identifier, and if the result is yes, send an instruction to the client, causing the client to store the second target data in its first-level cache according to the instruction.
[0164] For example, during the cache read phase, the client can read cached data based on the list of popular messages. For instance, when the client stores a list of popular messages, upon receiving a cached data access request, it first checks if there is corresponding data in the list. If so, it means the data to be read is popular data, which is the second target data pre-stored in the first-level cache, and the data is returned from the first-level cache. If not, it means the data to be read is not popular data, and the data needs to be returned from the second-level cache or other caches.
[0165] When the client does not store a list of trending messages, after receiving a cached data access request, the client can send the request to the management center to check if there is corresponding data in the management center's list of trending messages. If there is, it means that the data to be read is trending data, which is the second target data pre-stored in the first-level cache. The management center then sends an instruction to the client, and the client returns the data from the first-level cache. If there is no data, it means that the data to be read is not trending data. The management center then sends an instruction to the client, instructing the client to return the data from the second-level cache or other caches.
[0166] The cache management system in this embodiment configures the popularity data by executing a cache management method. It aggregates the popularity data through a popularity message list and synchronously stores the popularity data indicated in the popularity message list in the first-level cache. After configuration, when the client faces a large amount of popularity data access, it can directly return data from the first-level cache, thereby improving the response speed of data reading. In addition, since a large amount of popularity data can be obtained from the first-level cache according to the indication of the popularity message list, the access of a large number of data access requests to the second-level cache is reduced, thereby reducing the occupation of network bandwidth, avoiding system blockage caused by a large number of data access requests accessing the second-level cache, and improving system stability.
[0167] The specific implementation of this cache management system is basically the same as the specific embodiments of the cache management method described above, and will not be repeated here. Subject to meeting the requirements of the embodiments of this application, the cache management system may also be equipped with other functional modules to implement the cache management method in the above embodiments.
[0168] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described cache management method or cache retrieval method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0169] Please see Figure 10 , Figure 10 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:
[0170] The processor 1001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0171] The memory 1002 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called and executed by the processor 1001 using the cache management method and read method of the embodiments of this application.
[0172] Input / output interface 1003 is used to implement information input and output;
[0173] The communication interface 1004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0174] Bus 1005 transmits information between various components of the device (e.g., processor 1001, memory 1002, input / output interface 1003, and communication interface 1004);
[0175] The processor 1001, memory 1002, input / output interface 1003 and communication interface 1004 are connected to each other within the device via bus 1005.
[0176] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described cache management method and read method.
[0177] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0178] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0179] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0180] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0181] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0182] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0183] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0184] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0185] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0186] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0187] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0188] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A cache read method, characterized in that, The cache read method is applied to a cache management system, and the method includes: Get the client's cached data access request; The fourth target data to be read is determined based on the cached data access request; Obtain a preset list of trending messages, which is used to indicate trending data cached in the first-level cache; If the fourth target data corresponds to the hot data in the hot message list, the fourth target data is returned from the first-level cache according to the cache data access request; The cache management system includes: The first data acquisition module is used to acquire the first target data; A popularity calculation module is used to acquire access data of the first target data and determine a first popularity value of the first target data based on the access data. The heat data determination module is used to determine the first target data whose first heat value is greater than a preset threshold as heat data; A hot message list acquisition module is used to acquire a hot message list, wherein the hot message list is used to indicate the hot data; The second data acquisition module is used to acquire the second target data to be cached. The heat data caching module is used to store the second target data in the first-level cache if the second target data is in the heat message list.
2. The cache reading method according to claim 1, characterized in that, The cache management system is used to implement a cache management method, which includes: Obtain the first target data; Obtain access data for the first target data, and determine a first popularity value for the first target data based on the access data; The first target data whose first heat value is greater than a preset threshold is determined as heat data; Obtain a list of trending messages, which is used to indicate the trending data; Retrieve the second target data to be cached; If the second target data is in the list of trending messages, the second target data will be stored in the first-level cache.
3. The cache reading method according to claim 2, characterized in that, The step of determining the first target data whose first heat value is greater than a preset threshold as heat data includes: Obtain a preset exclusion list, which is used to indicate third target data that should not be cached in the first-level cache; When the first popularity value is greater than a preset threshold, and the first target data does not correspond to any of the third target data in the exclusion list, the first target data is determined to be popularity data.
4. The cache reading method according to claim 2, characterized in that, in: The steps from obtaining the first target data to obtaining the list of trending messages are executed periodically. The steps of obtaining the second target data to be cached and storing the second target data in the first-level cache if the second target data is in the hot message list are executed in the first cycle. The method further includes: In the second period following the first period, it is determined whether the second target data is still in the list of trending messages; If the second target data is no longer in the list of trending messages, the second target data is released from the first-level cache and sent to the second-level cache.
5. The cache reading method according to claim 2, characterized in that, The step of determining the first target data whose first heat value is greater than a preset threshold as heat data includes: Obtain the first size of the first-level cache; Obtain the second size of the first target data; Based on the first heat value, the first size, and the second size, the first target data is determined to be heat data.
6. The cache reading method according to claim 5, characterized in that, The step of determining the first target data as heat data based on the first heat value, the first size, and the second size includes: Based on the first popularity value, the first target data are arranged in descending order to form a candidate data queue; The second size of the first target data in the candidate data queue is accumulated sequentially from front to back until the sum exceeds the first size; Remove the last accumulated first target data from the accumulated first target data, and use the remaining first target data in the candidate data queue as the heat data.
7. The cache reading method according to claim 2, characterized in that, The step of acquiring access data of the first target data and determining a first popularity value of the first target data based on the access data includes: Obtain access data for the first target data, and determine the number of times the first target data was accessed within a preset time period based on the access data; The first popularity value of the first target data is determined based on the number of visits.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the cache read method according to any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the cache read method according to any one of claims 1 to 7.