Cache data updating method and computer readable storage medium

By using the target naive Bayesian model to predict data popularity and update the cache in advance, the problem of low cache hit rate during data renewal in the existing technology is solved, and timely renewal and efficient cache access of data are achieved.

CN119537401APending Publication Date: 2025-02-28TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411694883.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing technology cannot update cached data in time when data renewal, resulting in a low cache hit rate.

Method used

By predicting data popularity, use the target naive Bayesian model, identify popular data and obtain the latest data from the database in advance and write it to the cache.

Benefits of technology

Improve the cache hit rate, ensuring that the data can be renewed in time and readable, thereby avoiding the excessive amount of cached data affecting efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537401A_ABST
    Figure CN119537401A_ABST
Patent Text Reader

Abstract

The invention discloses a cache data updating method and a computer readable storage medium, and is applied to the technical field of data caching, and the method comprises the steps: predicting the popularity of each piece of data by using a target naive Bayesian model according to the popularity corresponding to each piece of data in a preset historical time, and determining the predicted popularity of each piece of data; wherein the popularity is a popularity value determined according to the request quantity corresponding to the data; comparing the predicted popularity of each piece of data with a preset popularity threshold, and determining hot data; acquiring latest data corresponding to the hot data from a database; and writing the latest data into the cache. According to the method and the device, the future popularity of each piece of data is predicted according to the popularity corresponding to each piece of data in the preset historical time, the hot data is determined according to the predicted popularity, and the data needing to be read is acquired from the database in advance for caching to realize data renewal, so that the hit rate of caching is improved, and the data can be read from the cache in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data cache, and in particular to a cache data updating method and a computer-readable storage medium. Background Art

[0002] Currently, when renewing data, the expiration time in the cache will be delayed when the data in the cache is read again to achieve the purpose of renewal. Before reading, the data in the cache may have expired and cannot be renewed, and the data cannot be read from the cache, resulting in a lower cache hit rate.

[0003] Therefore, the current cache renewal method cannot renew the data in the cache in time, resulting in a relatively low cache hit rate. Summary of the invention

[0004] In view of this, an object of the present invention is to provide a cache data updating method and a computer-readable storage medium, which solve the problem of low cache hit rate in the prior art.

[0005] In order to solve the above technical problems, the present invention provides a cache data updating method, comprising:

[0006] According to the heat corresponding to each data at the preset historical time, the heat of each data is predicted using the target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data;

[0007] Compare the predicted heat of each data with a preset heat threshold to determine the hot data;

[0008] Acquire the latest data corresponding to the hot data from the database;

[0009] The latest data is written into the cache.

[0010] Optionally, before predicting the heat of each data using the target naive Bayes model according to the heat corresponding to each data at a preset historical time and determining the predicted heat of each data, the method further includes:

[0011] Determine the request frequency corresponding to each data according to the request volume corresponding to each data in the preset historical time;

[0012] The heat corresponding to each data is determined according to the request frequency.

[0013] Optionally, according to the heat corresponding to each data at a preset historical time, the heat of each data is predicted using a target naive Bayes model to determine the predicted heat of each data, including:

[0014] According to the heat corresponding to each data at the current moment, the heat of each data is predicted using the naive Bayes model to determine the predicted heat corresponding to each data at the next moment; wherein the next moment is the next moment of the current moment.

[0015] Optionally, according to the heat corresponding to each data at the current moment, using the naive Bayes model to predict the heat of each data, and determining the predicted heat corresponding to each data at the next moment, includes:

[0016] According to the popularity corresponding to each data identifier at the current moment, the popularity of each data is predicted using the naive Bayes model to determine the predicted popularity corresponding to each data identifier at the next moment; wherein each data identifier includes a music medal identifier, and the music medal identifier is an identifier that can represent the user's interest and achievement in the field of music;

[0017] Correspondingly, obtaining the latest data corresponding to the hot data from the database includes:

[0018] The latest data is obtained from the database according to each data identifier.

[0019] Optionally, comparing the predicted popularity of each data with a preset popularity threshold to determine the hot data includes:

[0020] Determine whether the predicted heat of each data is greater than the preset heat threshold;

[0021] When the value is greater than the preset heat threshold, the current data is determined to be the hot data;

[0022] When it is not greater than the preset heat threshold, the current data is determined to be non-hot data.

[0023] Optionally, before predicting the heat of each data using the target naive Bayes model according to the heat corresponding to each data at a preset historical time and determining the predicted heat of each data, the method further includes:

[0024] Obtain historical request data from the database;

[0025] Performing data labeling processing on the historical request data to determine labeled data; wherein the labeled data is data including a request data identification tag, a request time tag, and a request data heat tag;

[0026] The naive Bayes model is trained using the labeled data including the request data identification label, the request time label and the request data heat label to obtain the target naive Bayes model; wherein the target naive Bayes model is a model that predicts the heat at future moments based on the request time and corresponding heat of the data.

[0027] Optionally, before performing data labeling processing on the historical request data and determining the labeled data, the method further includes:

[0028] Determine the data request frequency corresponding to each of the historical request data;

[0029] Determine the first heat parameter value corresponding to each of the historical request data using a preset heat mapping table; wherein the preset heat mapping table is a table including data request frequencies and corresponding heat parameter values;

[0030] The request data heat label corresponding to each historical request data is determined according to the first heat parameter value.

[0031] Optionally, before performing data labeling processing on the historical request data and determining the labeled data, the method further includes:

[0032] Determine the request volume corresponding to each of the historical request data;

[0033] Determine a second heat parameter value corresponding to each of the historical request data according to the request amount corresponding to each of the historical request data;

[0034] The request data heat label corresponding to each historical request data is determined according to the second heat parameter value.

[0035] Optionally, the request time tag is a minute-level request time tag or an hour-level request time tag.

[0036] Optionally, obtaining the latest data corresponding to the hot data from the database includes:

[0037] Determine whether the predicted time corresponding to the predicted heat of each data is greater than the existing cache renewal time; wherein the existing cache renewal time is the time for caching the data set corresponding to each data;

[0038] When the predicted time is greater than the existing cache renewal time, determining not to execute the step of obtaining the latest data corresponding to the hot data from the database;

[0039] When the predicted time is not greater than the existing renewal time, it is determined to execute the step of acquiring the latest data corresponding to the hot data from the database.

[0040] The present application also provides a cache data updating device, comprising:

[0041] A heat prediction module is used to predict the heat of each data according to the heat corresponding to each data at a preset historical time, using a target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data;

[0042] A hot data determination module, used to compare the predicted heat of each data with a preset heat threshold to determine the hot data;

[0043] A data acquisition module, used to acquire the latest data corresponding to the hot data from the database;

[0044] The data cache module is used to write the latest data into the cache.

[0045] The present application also provides a cache data updating device, including:

[0046] Memory for storing computer programs;

[0047] A processor is used to implement the steps of the cache data updating method as described above when executing the computer program.

[0048] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the cache data updating method as described above are implemented.

[0049] The present application also provides a computer program product, including a computer program / instruction, which implements the steps of the cache data updating method as described above when executed by a processor.

[0050] It can be seen that the present invention predicts the heat of each data by using the target naive Bayes model according to the heat corresponding to each data at the preset historical time, and determines the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data; the predicted heat of each data is compared with the preset heat threshold to determine the hot data; the latest data corresponding to the hot data is obtained from the database; and the latest data is written to the cache. Compared with the current situation where the data in the cache may have expired before reading, and will not be renewed, and the data cannot be read from the cache, the present application predicts the future heat of each data according to the heat corresponding to each data at the preset historical time, determines the hot data according to the heat, obtains the latest data from the database in advance and writes it to the cache, thereby improving the hit rate of the cache, so that the data can be read in time.

[0051] In addition, the present invention also provides a cache data updating device, equipment and computer-readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0053] Figure 1 A flowchart of a cache data updating method provided by an embodiment of the present invention;

[0054] Figure 2 A flowchart of a naive Bayes model training method provided by an embodiment of the present invention;

[0055] Figure 3 A flowchart of a naive Bayesian model training method provided by an embodiment of the present invention;

[0056] Figure 4 A flowchart of a cache data updating method provided by an embodiment of the present invention;

[0057] Figure 5 A schematic diagram of the structure of a cache data updating device provided by an embodiment of the present invention;

[0058] Figure 6 A schematic diagram of the structure of a cache data updating device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] Please refer to Figure 1 , Figure 1 A flowchart of a cache data update method provided by an embodiment of the present invention. The method may include:

[0061] S101, predicting the heat of each data according to the heat corresponding to each data at a preset historical time using a target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data.

[0062] The execution subject of this embodiment is an electronic device. For example, the electronic device in this embodiment can be a computer, or the electronic device in this embodiment can also be a mobile phone. The data in this embodiment is data that needs to be stored in the cache and read from the cache. This embodiment does not limit the specific preset historical time. For example, the preset historical time in this embodiment can be the last moment, such as the last second, the last minute, the last hour, etc. The preset historical time in this embodiment is the historical time relative to the time corresponding to the predicted heat. In this embodiment, the heat is determined according to the request amount corresponding to each data, so as to predict the future heat according to the historical heat. The specific time corresponding to the predicted heat is not limited in this embodiment. For example, the predicted heat in this embodiment can be the heat of the next second, or the predicted heat in this embodiment can also be the heat of the next minute. It can be understood that in order to renew the expired data in time, the smaller the time corresponding to the predicted heat, the more timely the data can be stored in the cache in advance. The naive Bayes model in this embodiment is a classification algorithm based on the Bayesian theorem, which assumes that the features are independent of each other. In practical applications, the naive Bayes model will learn and predict according to the label. The target naive Bayes model in this embodiment uses data identification, time, and data heat as labels for training during the training phase, so that the target naive Bayes model can predict heat. The request volume in this embodiment refers to the total number of requests for the data by the system per unit time. The input of the target naive Bayes model in this embodiment is the heat corresponding to each data at a preset historical time, and the output is the predicted heat of each data.

[0063] It should be further explained that, in order to improve the accuracy of heat determination, before predicting the heat of each data using the target naive Bayes model according to the heat corresponding to each data at the preset historical time and determining the predicted heat of each data, it may also include: determining the request frequency corresponding to each data according to the request amount corresponding to each data at the preset historical time; and determining the heat corresponding to each data according to the request frequency. This embodiment may determine the request frequency per minute according to the preset historical time; or this embodiment may determine the request frequency per second according to the preset historical time.

[0064] It should be further explained that in order to improve the timeliness of the predicted heat, the above-mentioned prediction of the heat of each data according to the preset historical time using the target naive Bayes model to predict the heat of each data and determine the predicted heat of each data may include: predicting the heat of each data according to the heat corresponding to each data at the current moment using the naive Bayes model to determine the predicted heat corresponding to each data at the next moment; wherein the next moment is the next moment of the current moment. The current moment and the next moment in this embodiment are two adjacent moments. When the current moment is 10:37, the next moment is 10:38. This embodiment determines the heat corresponding to the data at the next moment according to the heat of the data at the current moment. Since the current moment and the next moment are adjacent moments, the predicted heat can be obtained in time.

[0065] It should be further explained that in order to improve the efficiency of data acquisition, the above-mentioned prediction of the heat of each data using the naive Bayes model according to the heat corresponding to each data at the current moment, and determining the predicted heat corresponding to each data at the next moment, can include: predicting the heat of each data using the naive Bayes model according to the heat corresponding to each data identifier at the current moment, and determining the predicted heat corresponding to each data identifier at the next moment; wherein each data identifier includes a music medal identifier, and the music medal identifier is an identifier that can represent the user's interest and achievements in the field of music; accordingly, obtaining the latest data corresponding to the popular data from the database includes: obtaining the latest data from the database according to each data identifier. In this embodiment, when determining the heat and obtaining the latest data, it can be directly obtained according to the identifier corresponding to each data, and the required data can be quickly located through the identifier, which improves the retrieval speed. The music medal identifier in this embodiment can represent the user's activity on the music platform, listening achievements, and support for specific genres or singers.

[0066] S102, comparing the predicted popularity of each data with a preset popularity threshold to determine the popular data.

[0067] This embodiment does not limit the specific preset heat threshold value, as long as it can be consistent with the unit of the predicted heat. When the predicted heat is the request amount, the preset heat threshold value in this embodiment can be the request amount 100 times; or when the predicted heat is the request parameter value, the preset heat threshold value in this embodiment can also be the request parameter value 5. In this embodiment, the predicted heat of each data is compared with the preset heat threshold value, and the data greater than or equal to the preset heat threshold value is regarded as hot data, otherwise the data is non-hot data.

[0068] It should be further explained that the above-mentioned comparison of the predicted heat of each data with the preset heat threshold to determine the hot data may include: judging whether the predicted heat of each data is greater than the preset heat threshold; when it is greater than the preset heat threshold, determining that the current data is hot data; when it is not greater than the preset heat threshold, determining that the current data is non-hot data. The preset heat threshold in this embodiment is a threshold set by the user according to demand or experience. For example, when the predicted heat is a predicted parameter value, the request volume can be divided into 5 segments, each 2000 segment, the parameter value less than 2000 is 1, the parameter value of 2000-4000 is 2, the parameter value of 4000-6000 is 3, the parameter value of 6000-8000 is 4, and the parameter value greater than 8000 is 5. The preset heat threshold in this embodiment can be 3, and the specific value of the predicted heat of each data can be determined according to the request volume. If the value is greater than 3, the current data is determined to be hot data; when it is not greater than the preset heat threshold, the current data is determined to be non-hot data.

[0069] S103, obtaining the latest data corresponding to the popular data from the database.

[0070] This embodiment does not limit the specific database, as long as the data is stored in the database. For example, the database in this embodiment may be a MySQL (a widely used relational database management system) database; or the database in this embodiment may also be an Oracle (Oracle Corporation, an enterprise-level database) database. The latest data corresponding to the hot data in this embodiment means that the database may store multiple data corresponding to the hot data (data in the form of historical moments, data in the form of the latest moment), and the data that needs to be written into the cache in this embodiment is the latest data corresponding to the hot data.

[0071] It should be further explained that, in order to prevent repeated acquisition of data, the above-mentioned acquisition of the latest data corresponding to the hot data from the database may include:

[0072] S1031, determining whether the predicted time corresponding to the predicted heat of each data is greater than the existing cache renewal time; wherein the existing cache renewal time is the time set for caching the data corresponding to each data;

[0073] S1032, when the predicted time is greater than the existing cache renewal time, determining not to execute the step of obtaining the latest data corresponding to the hot data from the database;

[0074] S1033: When the predicted time is not greater than the existing renewal time, determine to execute the step of obtaining the latest data corresponding to the hot data from the database.

[0075] The existing cache renewal time in this embodiment refers to the existing scheduled refresh time. In order to prevent data from being renewed again immediately after it is renewed, resulting in repeated renewals, this embodiment will determine whether the predicted time corresponding to the predicted heat of each data is greater than the existing cache renewal time. When the predicted time is greater than the existing cache renewal time, it means that the data has been renewed before the predicted time and there is no need to repeat the renewal. Otherwise, it is necessary to execute the step of obtaining the latest data corresponding to the hot data from the database. It is understandable that the existing cache renewal time is 12:00 every day. If the predicted time of the hot data is 12:01, it means that the data has been renewed at 12:00 and there is no need to renew it again at 12:01. It should be noted that when judging whether the predicted time corresponding to the predicted heat of each data is greater than the existing cache renewal time, the judgment of the time interval between the predicted time corresponding to the predicted heat and the existing cache renewal time can be added. According to the expiration rules corresponding to all data, a time interval is determined. For example, the data is generally updated every 3 minutes. If the time interval is greater than 3 minutes, even if the predicted time is greater than the existing cache renewal time, it is necessary to execute the step of obtaining the latest data corresponding to the hot data from the database.

[0076] S104, writing the latest data into the cache.

[0077] The cache in this embodiment refers to storing objects that are frequently called by a program or system in memory so that they can be quickly called when used without having to create new duplicate instances. This can reduce system overhead and improve system efficiency. This embodiment writes the latest data corresponding to the hot data into the cache so that the hot data can be directly called when it is needed.

[0078] A cache data update method provided by an embodiment of the present invention may include: S101, predicting the heat of each data using a target naive Bayes model according to the heat corresponding to each data at a preset historical time, and determining the predicted heat of each data; wherein the heat is a heat value determined according to the request amount corresponding to the data; S102, comparing the predicted heat of each data with a preset heat threshold to determine the hot data; S103, obtaining the latest data corresponding to the hot data from a database; S104, writing the latest data into the cache. This embodiment predicts the heat of each data at the next time point according to the heat corresponding to each data at a preset historical time, determines the hot data according to the heat, obtains the latest data corresponding to the hot data from the database in advance for caching, and realizes data renewal, so that when reading data from the cache, the data can be read, thereby improving the cache hit rate, and because only the hot data is written into the cache in advance, it is not necessary to renew all the data, avoiding excessive cache data and affecting cache efficiency.

[0079] In order to make the present invention easier to understand, please refer to Figure 2 , Figure 2 A flowchart of a naive Bayes model training method provided by an embodiment of the present invention may specifically include:

[0080] S201, obtaining historical request data from a database.

[0081] The executor of this embodiment is an electronic device. The electronic device in this embodiment may be a mobile phone; or the electronic device in this embodiment may also be a computer. This embodiment does not limit the specific historical request data, and the historical request data is the data of the most recent preset days. For example, the historical request data in this embodiment may be the data of the most recent week; or the historical request data in this embodiment may also be the data of the most recent half month. The historical request data in this embodiment refers to the data requested from the cache.

[0082] This embodiment can also filter the historical request data after obtaining it, so as to eliminate low-frequency data. The low-frequency data in this embodiment can filter data with a request number per minute lower than a preset number, for example, filtering data with a request number per minute lower than once.

[0083] S202, perform data labeling processing on the historical request data to determine the labeled data; wherein the labeled data is data including a request data identification tag, a request time tag, and a request data heat tag.

[0084] In this embodiment, all corresponding identifiers, corresponding request times, and corresponding heats in the historical request data are determined, so as to perform data labeling processing on the data. The request data identification tag in this embodiment uniquely identifies a piece of data, the request time tag in this embodiment identifies the request time of the data; the request data heat tag in this embodiment determines the heat corresponding to the data. This embodiment does not limit the method for determining the request data identifier. For example, in this embodiment, the request data identifier may be an ID (IDentity, identity identification number); or the request data identifier in this embodiment may be a UUID (Universally Unique Identifier, unique identifier). This embodiment does not limit the way of request time labeling. For example, this embodiment can be divided according to the minute level to obtain a request time tag at the minute level, or it can also be divided according to the hour level to obtain a request time tag at the hour level. This embodiment does not limit the way of determining the request data heat tag, for example, the request data heat tag in this embodiment can be determined by the request frequency, or the request data heat tag in this embodiment can also be determined by the request amount. It is understandable that in order to improve the timeliness of predicted heat, the request time tag can be a request time tag at the minute level. Because when the time tag is at the minute level, the data heat of the next minute can be directly predicted, so that it can be cached in time. If it is at the hourly level, if the data is updated relatively quickly, it will not be cached in time.

[0085] S203, using labeled data including request data identification labels, request time labels and request data heat labels to train the naive Bayes model to obtain a target naive Bayes model; wherein the target naive Bayes model is a model that predicts the heat at future moments based on the request time and corresponding heat of the data.

[0086] This embodiment uses labeled data to train the Naive Bayes model, which means that the labeled data is divided into input data and output data according to the request time label. The input data refers to the data used as input for training the Naive Bayes model, and the output data refers to the data used as output for training the Naive Bayes model. The time of the output data is greater than the time of the input data. For example, the time interval between the output data and the input data can be one minute.

[0087] It should be further explained that, before performing data annotation processing on the historical request data and determining the annotated data, it may also include: determining the data request frequency corresponding to each historical request data;

[0088] The first heat parameter value corresponding to each historical request data is determined by using a preset heat mapping table; wherein the preset heat mapping table is a table including data request frequency and corresponding heat parameter values; the request data heat label corresponding to each historical request data is determined according to the first heat parameter value. The data request frequency in this embodiment may be the number of times the data is requested per minute. The preset heat mapping table in this embodiment is a table including data request frequency and request data heat. For example, when the data request frequency is lower than 2000, the heat parameter value is determined to be 1, when the data request frequency is greater than 2000 and less than 4000, the heat parameter value is determined to be 2, when the data request frequency is greater than 4000 and less than 6000, the heat parameter value is determined to be 3... This embodiment can directly determine the corresponding first heat parameter value according to the data request frequency through the preset heat mapping table, thereby improving the efficiency of determining the request data heat label.

[0089] It should be further explained that before the historical request data is annotated and the annotated data is determined, the following may be included: determining the request amount corresponding to each historical request data; determining the second heat parameter value corresponding to each historical request data according to the request amount corresponding to each historical request data;

[0090] The request data heat label corresponding to each historical request data is determined according to the second heat parameter value. The method of determining the second heat parameter value according to the request amount is not limited in this embodiment. For example, this embodiment can determine the second heat parameter value according to the proportion of the request amount, and the proportion of the request amount refers to the proportion of the request amount of the data in the total request amount. For example, if the proportion of the request amount is less than 5%, the second heat parameter value is determined to be 0, if the proportion of the request amount is greater than 5% and less than 10%, the second heat parameter value is determined to be 1, if the proportion of the request amount is greater than 10% and less than 30%, the second heat parameter value is determined to be 2, if the proportion of the request amount is greater than 30% and less than 50%, the second heat parameter value is determined to be 3, if the proportion of the request amount is greater than 50% and less than 80%, the second heat parameter is determined to be 4; if the proportion of the request amount is greater than 80% and less than 100%, the second heat parameter value is determined to be 5. In addition to determining the heat parameter value by request frequency, this embodiment can also determine the heat parameter value according to the proportion of the request amount.

[0091] A naive Bayes model training method provided by an embodiment of the present invention may include: S201, obtaining historical request data from a database. S202, performing data labeling processing on the historical request data to determine the labeled data; wherein the labeled data is data including a request data identification label, a request time label, and a request data heat label. S203, training a naive Bayes model using the labeled data including the request data identification label, the request time label, and the request data heat label to obtain a target naive Bayes model; wherein the target naive Bayes model is a model that predicts the heat at future moments based on the request time and corresponding heat of the data. The embodiment of the present invention trains a naive Bayes model using labeled data including the request data identification label, the request time label, and the request data heat label, so that the target naive Bayes model can predict the heat of data at future moments, thereby loading the latest data from the database into the cache in advance, improving the cache hit rate, protecting the database, and avoiding too many requests from penetrating the bottom layer.

[0092] In order to make the present invention easier to understand, please refer to Figure 3 , Figure 3 A flow chart of a naive Bayes model training method provided in an embodiment of the present invention may specifically include:

[0093] S301, reading the request data of the latest 7 days from the database, and performing data cleansing on all the request data according to the request volume and request volume threshold corresponding to the request data to obtain cleansed data.

[0094] In this embodiment, when the request amount corresponding to the request data is lower than the request amount threshold, the data is filtered.

[0095] S302, determine the ID corresponding to the cleaned data and the time at the minute level, and determine the heat corresponding to each request data in the cleaned data according to the request volume, and label each request data according to the ID, time and heat to obtain labeled data.

[0096] S303, dividing the labeled data into input data and output data, using the input data as the input of the Naive Bayes model, using the output data as the output of the Naive Bayes model, training the Naive Bayes model, and obtaining a target Naive Bayes model; wherein the time of the input data is less than the time of the output data.

[0097] In order to make the present invention easier to understand, please refer to Figure 4 , Figure 4 A flow chart of a cache data update method provided by an embodiment of the present invention may specifically include:

[0098] S401, determine the ID, time and popularity corresponding to each data.

[0099] The time in this embodiment can be a historical time or a current time.

[0100] S402: predict the predicted heat corresponding to each data using the target naive Bayes model according to the ID, time and heat corresponding to each data.

[0101] S403, comparing the predicted heat of each data with a preset heat threshold, determining the hot data, and determining the hot ID corresponding to the hot data.

[0102] S404, accessing the database according to the hot ID, and writing the latest data corresponding to the hot ID into the cache.

[0103] There are two features in the embodiments of the present invention: the ID (x) identifier and the time (y). Now, if we want to classify the data F, then the probability that the data F belongs to the class c is P(c|F) = P(c|(x,y)). According to the theory of Naive Bayes (assuming that multiple features do not affect each other and are independent of each other), we have: P(c|(x,y)) = P(c|x) * P(c|y); where: P(c|x) = P(x|c) * P(c) / p(x), P(c|y). Similarly, there are two results for the data to be classified now: 1. Popular, assumed to be c1; 2. Not popular, assumed to be c2. Then, for the classification problem of the data F, we need to solve two probabilities: P(c1|F) and P(c2|F): If P(c1|F) > P(c2|F), then F belongs to the class c1. If P(c1|F) < P(c2|F), then F belongs to the class c2. According to Bayes' principle, we can get: P(c1|F) = P(F|c1) * P(c1) / p(F); P(c2|F) = P(F|c1) * P(c2) / p(F); and for the classification problem, we don't need to solve the exact values, we only need to compare the magnitudes of P(c1|F) and P(c2|F). Therefore, for P(c|F), it can be further simplified to solve: P(c|F) = P(x|c) * P(c) * P(y|c) * P(c). Suppose there is the following data set: ID, time, whether it is popular (heat is greater than 3); 1 (ID), 1 (time) and yes (whether it is popular); 1, 2 and yes; 2, 1 and no; 2, 2 and no; The features of this data set are: medal ID and time period, and the target set is whether it is popular. Given features: 1. The medal ID is represented by x; 2. The time is represented by y. Given targets: 1. Not popular is represented by c1; 2. Popular is represented by c2. To find out whether a certain feature is popular, we need to find out which one is larger between P(c1|(x,y)) and P(c2|(x,y)).From the data set, we can know that: P(c1)=2 / 4=0.5; P(c2)=2 / 4=0.5; P(x=1|c1)=0.5; P(x=1|c2)=0; P(x=2|c1)=0; P(x=2|c2)=0.5; P(y=1|c1)=0.25; P(y=1|c2)=0.25; P(y=2|c1)=0.25; P(y=2|c2)=0.25; If we want to predict whether it is popular when the medal ID is 1 and the time period is 1, we have: P(c1|(x=1,y=1))=P(x=1|c1)*P(c1)*P(y=1|c1)*P(c1)=0.5*0.5*0.25*0.5=0.03125; P(c2|(x=1,y=1))=P(x=1|c2)*P(c2)*P(y=1|c2)*P(c2)=0*0.5*0.25*0.5=0; Since P(c1|(x=1,y=1)) is greater than P(c2|(x=1,y=1)), it can be concluded that the data is popular.

[0104] The following is an introduction to a cache data updating device provided in an embodiment of the present invention. The cache data updating device described below and the cache data updating method described above can be referred to each other.

[0105] Please refer to Figure 5 , Figure 5 A schematic diagram of a cache data updating device provided by an embodiment of the present invention may include:

[0106] The heat prediction module 100 is used to predict the heat of each data according to the heat corresponding to each data at a preset historical time using a target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data;

[0107] A hot data determination module 200 is used to compare the predicted heat of each data with a preset heat threshold to determine the hot data;

[0108] A data acquisition module 300 is used to acquire the latest data corresponding to the hot data from a database;

[0109] The data cache module 400 is used to write the latest data into the cache.

[0110] Further, based on the above embodiment, the cache data updating device may further include:

[0111] A request frequency determination module, used to determine the request frequency corresponding to each data according to the request amount corresponding to each data in a preset historical time;

[0112] The heat determination module is used to determine the heat corresponding to each data according to the request frequency.

[0113] Further, based on any of the above embodiments, the heat prediction module 100 may include:

[0114] The heat prediction unit is used to predict the heat of each data according to the heat corresponding to each data at the current moment by using the naive Bayes model, and determine the predicted heat corresponding to each data at the next moment; wherein the next moment is the next moment of the current moment.

[0115] Further, based on the above embodiment, the above heat prediction unit may include:

[0116] A prediction subunit according to the identifier is used to predict the heat of each data using the naive Bayes model according to the heat corresponding to each data identifier at the current moment, and determine the predicted heat corresponding to each data identifier at the next moment; wherein each data identifier includes a music medal identifier, and the music medal identifier is an identifier that can represent the user's interest and achievement in the field of music;

[0117] Accordingly, the data acquisition module 300 includes:

[0118] The minimum data acquisition unit is used to acquire the latest data from the database according to each data identifier.

[0119] Further, based on any of the above embodiments, the above hot data determination module 200 may include:

[0120] A first judging unit, configured to judge whether the predicted heat of each data is greater than the preset heat threshold;

[0121] A hot data determination unit, configured to determine that the current data is the hot data when the temperature is greater than the preset heat threshold;

[0122] The non-hot data determination unit is used to determine that the current data is non-hot data when the current data is not greater than the preset heat threshold.

[0123] It should be further explained that the cache data updating device may further include:

[0124] A historical request data acquisition module, used to acquire historical request data from the database;

[0125] A data annotation module, used to perform data annotation processing on the historical request data to determine the annotated data; wherein the annotated data is data including a request data identification tag, a request time tag, and a request data heat tag;

[0126] A model training module is used to train a naive Bayes model using the labeled data including the request data identification label, the request time label and the request data heat label to obtain the target naive Bayes model; wherein the target naive Bayes model is a model that predicts the heat at future moments based on the request time and corresponding heat of the data.

[0127] Further, based on the above embodiment, the cache data updating device may further include:

[0128] A historical request frequency determination module, used to determine the data request frequency corresponding to each of the historical request data;

[0129] A first heat parameter value determination module, used to determine the first heat parameter value corresponding to each of the historical request data using a preset heat mapping table; wherein the preset heat mapping table is a table including data request frequencies and corresponding heat parameter values;

[0130] The first request data heat label determination module is used to determine the request data heat label corresponding to each historical request data according to the first heat parameter value.

[0131] Further, based on the above embodiment, the cache data updating device may further include:

[0132] A historical request amount determination module, used to determine the request amount corresponding to each of the historical request data;

[0133] A second heat parameter value determination module, used to determine a second heat parameter value corresponding to each of the historical request data according to the request amount corresponding to each of the historical request data;

[0134] The second request data heat label determination module is used to determine the request data heat label corresponding to each historical request data according to the second heat parameter value.

[0135] Further, based on the above embodiment, the request time tag is a minute-level request time tag or an hour-level request time tag.

[0136] Further, based on any of the above embodiments, the data acquisition module 300 may include:

[0137] A second judgment unit is used to judge whether the prediction time corresponding to the predicted heat of each data is greater than the existing cache renewal time; wherein the existing cache renewal time is the time for caching the data set corresponding to each data;

[0138] a non-execution cache renewal unit, configured to determine not to execute the step of obtaining the latest data corresponding to the hot data from the database when the predicted time is greater than the existing cache renewal time;

[0139] The cache renewal unit is used to determine to execute the step of obtaining the latest data corresponding to the hot data from the database when the predicted time is not greater than the existing renewal time.

[0140] It should be noted that the order of the modules and units in the above cache data updating device can be changed without affecting the logic.

[0141] A cache data updating device provided by an embodiment of the present invention may include: a heat prediction module 100, which is used to predict the heat of each data according to the heat corresponding to each data at a preset historical time, using a target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data; a hot data determination module 200, which is used to compare the predicted heat of each data with a preset heat threshold to determine the hot data; a data acquisition module 300, which is used to obtain the latest data corresponding to the hot data from a database; and a data cache module 400, which is used to write the latest data into the cache. Compared with the situation before the current reading, when the data in the cache has expired and cannot be renewed, and the data needs to be read from the storage again, resulting in a lower cache hit rate, this embodiment predicts the heat of each data at the next time point according to the heat corresponding to each data at a preset historical time, determines the popular data according to the heat, obtains the latest data corresponding to the popular data from the database in advance for caching, and realizes data renewal, so that when reading data from the cache, the data can be read, thereby improving the cache hit rate, and because only the popular data is written to the cache in advance, there is no need to renew all the data, avoiding excessive cache data and affecting cache efficiency.

[0142] A cache data updating device provided by an embodiment of the present invention is introduced below. The cache data updating device described below and the cache data updating method described above can refer to each other.

[0143] Please refer to Figure 6 , Figure 6 A schematic diagram of a cache data update device provided by an embodiment of the present invention may include:

[0144] A memory 10, used for storing computer programs;

[0145] The processor 20 is used to execute a computer program to implement the above cache data updating method.

[0146] The memory 10 , the processor 20 , and the communication interface 30 all communicate with each other via a communication bus 40 .

[0147] In the embodiment of the present invention, the memory 10 is used to store one or more programs, and the program may include program code, and the program code includes computer operation instructions. In the embodiment of the present invention, the memory 10 may store programs for implementing the following functions:

[0148] According to the heat corresponding to each data at the preset historical time, the target naive Bayes model is used to predict the heat of each data to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data;

[0149] Compare the predicted popularity of each data with the preset popularity threshold to determine the popular data;

[0150] Get the latest data corresponding to the popular data from the database;

[0151] Write the latest data to the cache.

[0152] In a possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

[0153] In addition, the memory 10 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and processing hardware-based tasks.

[0154] The processor 20 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, a microprocessor or any conventional processor, etc. The processor 20 may call a program stored in the memory 10 .

[0155] The communication interface 30 may be an interface of a communication module, and is used to connect to other devices or systems.

[0156] Of course, it should be noted that Figure 6 The structure shown does not constitute a limitation on the cache data update device in the embodiment of the present invention. In actual applications, the cache data update device may include Figure 6 More or fewer components than shown, or combinations of certain components.

[0157] The computer-readable storage medium provided by an embodiment of the present invention is introduced below. The computer-readable storage medium described below and the cache data updating method described above can be referenced to each other.

[0158] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the cache data updating method are implemented.

[0159] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0160] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0161] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0162] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0163] The above is a detailed introduction to a cache data update method and a computer-readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A cache data updating method, characterized in that: include: According to the heat corresponding to each data at the preset historical time, the heat of each data is predicted using the target naive Bayes model to determine the predicted heat of each data; wherein the heat is a heat value determined according to the request volume corresponding to the data; Compare the predicted heat of each data with a preset heat threshold to determine the hot data; Acquire the latest data corresponding to the hot data from the database; The latest data is written into the cache.

2. The cache data updating method according to claim 1, characterized in that: According to the heat corresponding to each data at the preset historical time, the heat of each data is predicted by using the target naive Bayes model, and before determining the predicted heat of each data, the following is also included: Determine the request frequency corresponding to each data according to the request volume corresponding to each data in the preset historical time; The heat corresponding to each data is determined according to the request frequency.

3. The cache data updating method according to claim 1, characterized in that: According to the heat corresponding to each data at the preset historical time, the target naive Bayes model is used to predict the heat of each data to determine the predicted heat of each data, including: According to the heat corresponding to each data at the current moment, the heat of each data is predicted using the naive Bayes model to determine the predicted heat corresponding to each data at the next moment; wherein the next moment is the next moment of the current moment.

4. The cache data updating method according to claim 3, characterized in that: According to the heat corresponding to each data at the current moment, the heat of each data is predicted using the naive Bayes model to determine the predicted heat corresponding to each data at the next moment, including: According to the popularity corresponding to each data identifier at the current moment, the popularity of each data is predicted using the naive Bayes model to determine the predicted popularity corresponding to each data identifier at the next moment; wherein each data identifier includes a music medal identifier, and the music medal identifier is an identifier that can represent the user's interest and achievement in the field of music; Correspondingly, obtaining the latest data corresponding to the hot data from the database includes: The latest data is obtained from the database according to each data identifier.

5. The cache data updating method according to claim 1, characterized in that: Comparing the predicted heat of each data with a preset heat threshold to determine the hot data includes: Determine whether the predicted heat of each data is greater than the preset heat threshold; When the value is greater than the preset heat threshold, the current data is determined to be the hot data; When it is not greater than the preset heat threshold, the current data is determined to be non-hot data.

6. The cache data updating method according to any one of claims 1 to 5, characterized in that: According to the heat corresponding to each data at the preset historical time, the heat of each data is predicted by using the target naive Bayes model, and before determining the predicted heat of each data, the following is also included: Obtain historical request data from the database; Performing data labeling processing on the historical request data to determine labeled data; wherein the labeled data is data including a request data identification tag, a request time tag, and a request data heat tag; The naive Bayes model is trained using the labeled data including the request data identification label, the request time label and the request data heat label to obtain the target naive Bayes model; wherein the target naive Bayes model is a model that predicts the heat at future moments based on the request time and corresponding heat of the data.

7. The cache data updating method according to claim 6, characterized in that: Before performing data labeling processing on the historical request data and determining the labeled data, the method further includes: Determine the data request frequency corresponding to each of the historical request data; Determine the first heat parameter value corresponding to each of the historical request data using a preset heat mapping table; wherein the preset heat mapping table is a table including data request frequencies and corresponding heat parameter values; The request data heat label corresponding to each historical request data is determined according to the first heat parameter value.

8. The cache data updating method according to claim 6, characterized in that: Before performing data labeling processing on the historical request data and determining the labeled data, the method further includes: Determine the request volume corresponding to each of the historical request data; Determine a second heat parameter value corresponding to each of the historical request data according to the request amount corresponding to each of the historical request data; The request data heat label corresponding to each historical request data is determined according to the second heat parameter value.

9. The cache data updating method according to claim 6, characterized in that: The request time tag is a minute-level request time tag or an hour-level request time tag.

10. The cache data updating method according to claim 1, characterized in that: The acquiring the latest data corresponding to the hot data from the database includes: Determine whether the predicted time corresponding to the predicted heat of each data is greater than the existing cache renewal time; wherein the existing cache renewal time is the time for caching the data set corresponding to each data; When the predicted time is greater than the existing cache renewal time, determining not to execute the step of obtaining the latest data corresponding to the hot data from the database; When the predicted time is not greater than the existing renewal time, it is determined to execute the step of acquiring the latest data corresponding to the hot data from the database.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the cache data updating method according to any one of claims 1 to 10 are implemented.