A label updating method based on LRU
The LRU-based label update method addresses resource wastage in existing methods by analyzing user behavior to determine update frequencies and adjusting storage lists, ensuring efficient and accurate label updates and optimized resource use.
Patent Information
- Application Number
- CN202410962164.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Existing label update methods face challenges in accurately predicting update frequency and quantity, leading to resource wastage due to their reliance on fixed or batch updates.
A method based on the Least Recently Used (LRU) algorithm that collects and analyzes user historical behavior data to determine initial and real-time update frequencies, adjusts the historical storage chain list, and performs over-time detection to optimize label updates, ensuring the most frequently used labels are preserved and infrequently used ones are removed.
This approach provides a more efficient and accurate label update strategy by dynamically adjusting the storage chain list, optimizing resource usage, and ensuring the relevance and accuracy of stored labels, thereby reducing storage and computational resource waste.
Smart Images

Figure CN118885492B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a label updating method based on LRU. Background Art
[0002] With the rapid development of the information society, data processing technology is increasingly being used in all walks of life. As an important element in the data processing process, tags play a vital role in applications such as classification, search, and recommendation.
[0003] The patent document with Chinese patent application publication number CN117648608A discloses a user label update method, system, device and storage medium based on time series, and the method includes: the user label update method based on time series includes real-time acquisition of user status data and a first user label, inputting the user status data into a preset trend analysis model to obtain time series data; acquiring a first time data feature based on the time series data, and generating label update data according to the first time data feature; inputting the label update data into the first user label, updating the first user label according to the label update data, and obtaining a second user label; acquiring label association information based on the second user label and the first user label, and constructing a label mapping table according to the label association information.
[0004] Existing tag update methods often use scheduled updates or batch updates. Since the update frequency and update amount of tags are difficult to accurately predict, it leads to a waste of resources. Summary of the invention
[0005] To this end, the present invention provides a label updating method based on LRU, which can solve the problem of resource waste.
[0006] To achieve the above object, the present invention provides a label updating method based on LRU, the method comprising:
[0007] Acquire a number of historical behavior data within a historical period of the user, and determine a number of historical tags and their corresponding access timestamps based on the number of historical behavior data;
[0008] Creating a history storage linked list based on the history tags and the access timestamps corresponding to the history tags;
[0009] Determining an initial update frequency of any of the history tags based on a number of the access timestamps;
[0010] Collect the user's real-time behavior data within a preset time period, and determine the user's real-time tag based on the real-time behavior data;
[0011] Matching the real-time tag with the historical storage linked list to obtain a matching result, and calculating the real-time update frequency of the tag according to the matching result;
[0012] Adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency, and adjusting the history sorting of the history storage linked list based on the matching result to obtain an updated storage linked list;
[0013] The update storage linked list is traversed, an expiration detection is performed on the update timestamps corresponding to the plurality of update tags, and the update storage linked list is adjusted again according to the expiration detection result to obtain a final storage linked list.
[0014] Furthermore, the step of determining a number of historical tags based on a number of historical behavior data of the user includes:
[0015] Obtaining historical transaction records of the user, wherein the historical transaction records include historical transaction information, historical transaction time, historical transaction amount, and historical commodity type;
[0016] determining a plurality of said access timestamps based on said historical transaction time;
[0017] The historical tag is determined based on the historical transaction information, the historical transaction amount and the historical commodity type.
[0018] Furthermore, it is characterized in that the step of determining the historical tag based on the historical transaction information, the historical transaction amount and the historical commodity type includes:
[0019] Determine the historical transaction frequency based on the historical transaction information, and determine the transaction activity based on the transaction frequency;
[0020] Determine the total historical transaction amount based on the historical transaction amount, and determine the consumption capacity based on the total historical transaction amount;
[0021] determining a product preference based on the historical product types;
[0022] The historical tag is determined based on the transaction activity, the spending power, and the commodity preference.
[0023] Furthermore, the step of determining the initial update frequency of any of the history tags based on the plurality of access timestamps includes:
[0024] Sort the access timestamps corresponding to any of the history tags based on the time series to obtain a sorting result;
[0025] Calculate the time interval between two adjacent access timestamps based on the sorting results;
[0026] Calculate the mean of a number of said time intervals and use the mean as the mean period;
[0027] Calculate the ratio of the number of access timestamps corresponding to any of the history tags to the total number of access timestamps of the history tags, and use the ratio as the access frequency;
[0028] The initial update frequency is determined based on the averaging period, the access frequency, and an adjustment coefficient.
[0029] Furthermore, the step of matching the real-time tag with the historical storage linked list includes:
[0030] Traverse the historical storage linked list with the real-time tag, and if the historical storage linked list contains the real-time tag, mark the corresponding historical tag in the historical storage linked list to obtain a marked tag;
[0031] If the real-time tag is not included in the historical storage linked list, the similarity between the real-time tag and several historical tags is calculated to obtain a similarity calculation result;
[0032] If the similarity calculation result is greater than or equal to the preset similarity, the historical tag corresponding to the maximum value of the similarity calculation result is marked to obtain a marked tag.
[0033] Furthermore, the step of calculating the real-time update frequency of the tag according to the matching result includes:
[0034] When the matching result is that the history storage linked list contains the marking tag, obtaining a plurality of marking timestamps corresponding to the marking tag;
[0035] Calculate the marking duration based on the plurality of marking timestamps;
[0036] Calculate a first update frequency based on the number of the marking tags and the marking duration;
[0037] When the matching result is that the historical storage linked list does not contain the marking tag, obtaining several real-time timestamps corresponding to the real-time tag;
[0038] Calculate the real-time duration based on the real-time timestamps;
[0039] A second update frequency is calculated based on the number of the real-time tags and the real-time duration.
[0040] Furthermore, the step of adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency includes:
[0041] increasing the history length or decreasing the history length according to a comparison result between the first update frequency and the initial update frequency;
[0042] The history length is increased according to a comparison result of the second update frequency and the initial update frequency.
[0043] Furthermore, the step of adjusting the history order of the history storage linked list based on the matching result includes:
[0044] When the matching result is that the historical storage linked list contains the marking tag, obtaining the position of the marking tag in the historical storage linked list;
[0045] Traversing the history storage linked list based on the latest marking timestamp corresponding to the marking tag, and moving the marking tag according to the traversal result;
[0046] When the matching result is that the historical storage linked list does not contain the marking tag, the real-time tag and its corresponding real-time timestamp are added to the head of the historical storage linked list.
[0047] Furthermore, the step of performing expiration detection on update timestamps corresponding to a plurality of update tags includes:
[0048] Calculating the expiration time according to the difference between the current timestamp and the update timestamp;
[0049] The expiration time is compared with a preset time, and whether it is expired is determined according to the comparison result.
[0050] Furthermore, the step of re-adjusting the update storage linked list according to the expiration detection result includes:
[0051] When the expiration time is greater than the preset time, the update tag is removed from the update storage linked list, and the order of the remaining tags is updated;
[0052] When the expiration time is less than or equal to the preset time, the update linked list is not adjusted.
[0053] Compared with the prior art, the beneficial effect of the present invention lies in that by collecting and analyzing the user's historical behavior data, the user's interests and needs can be deeply understood, providing a basis for the accurate update of subsequent tags, the use of a linked list structure can efficiently manage historical tags, and at the same time, combined with the access timestamp, the LRU algorithm can be conveniently implemented to ensure that the most frequently used tags are retained, and the determination of the initial update frequency provides accurate data support for the update of subsequent tags, making the subsequent update strategy more reasonable and effective, and the collection and analysis of real-time behavior data can reflect the user's current interests and needs, providing an important basis for the real-time update of tags, by matching real-time tags and historical tags, evaluating the real-time usage of tags, and then calculating the real-time update frequency, providing real-time feedback for the tag update strategy, and dynamically adjusting the historical storage linked list according to the initial and real-time update frequencies to ensure that the most frequently used tags are retained and remove infrequently used tags, thereby optimizing the use of storage resources, and expiration detection can timely discover and remove expired tags to ensure that the tags in the storage linked list are valid and accurate, while optimizing the use of storage resources.
[0054] In particular, by sorting the access timestamps through the time series, we can clearly see the time series of the historical tags being accessed, so as to understand the usage pattern of the tags, calculate the time intervals between adjacent access timestamps, and take the mean as the mean period, which reflects the average period of tag use and provides an important basis for determining the update frequency. The access frequency of historical tags is calculated, the relative importance of tags is quantified, and the initial update frequency of each historical tag is dynamically determined based on the mean period, access frequency and adjustment coefficient. This can improve the efficiency and accuracy of tag updates. By setting a suitable initial update frequency for each historical tag, unnecessary frequent updates or untimely updates can be avoided, thereby improving the overall performance and stability of the system and optimizing the use of storage resources.
[0055] In particular, by traversing the historical storage linked list, it is possible to quickly locate whether there is a label identical to the real-time label, thereby improving the matching efficiency. When there is no label identical to the real-time label in the historical storage linked list, the similarity between the real-time label and the existing historical label is calculated, and the correlation between the real-time label and the historical label is quantified. By setting a preset similarity threshold, the strictness of the matching is adjusted according to actual needs, thereby enhancing the flexibility of label updating. Through similarity calculation and matching, historical labels that are highly correlated with the real-time label are identified, thereby avoiding repeated storage of similar labels and optimizing the use of storage space.
[0056] In particular, by comparing the first update frequency and the initial update frequency, the history length of the history storage linked list is dynamically adjusted. When the first update frequency is higher than or equal to the initial update frequency, the history length is increased to adapt to the high-frequency update of the data. When the first update frequency is lower than the initial update frequency, the history length is reduced to optimize the use of storage space. For the case where the real-time update frequency is higher than or equal to the initial update frequency, the history length is increased according to the ratio of the real-time update frequency to the initial update frequency, thereby ensuring that the system can retain sufficient historical data to support accurate analysis and prediction of data changes. When the real-time update frequency is lower than the initial update frequency, the history length is not adjusted, thereby avoiding unnecessary waste of storage space. Dynamically adjusting the history length of the history storage linked list helps to improve data processing efficiency. By accurately controlling the history length of the history storage linked list, excessive data storage can be avoided, thereby reducing the waste of storage space, computing resources and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A schematic diagram of a flow chart of a label updating method based on LRU provided in an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of a flow chart of determining an initial update frequency of a label update method based on LRU provided in an embodiment of the present invention;
[0059] Figure 3 A schematic diagram of the process of matching a real-time label with a historical storage linked list in a label update method based on LRU provided in an embodiment of the present invention;
[0060] Figure 4 A schematic diagram of a flow chart of performing expiration detection on an update timestamp in a label update method based on LRU provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0061] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0062] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0063] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be understood as a limitation on the present invention.
[0064] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0065] See also Figure 1 As shown, an embodiment of the present invention provides a label updating method based on LRU, the method comprising:
[0066] Step S100, obtaining a number of historical behavior data within a historical period of the user, and determining a number of historical tags and their corresponding access timestamps based on the number of historical behavior data;
[0067] Step S200, creating a history storage linked list based on the history tags and the access timestamps corresponding to the history tags;
[0068] Step S300, determining an initial update frequency of any of the history tags based on a number of the access timestamps;
[0069] Step S400, collecting real-time behavior data of the user within a preset time period, and determining the user's real-time tag according to the real-time behavior data;
[0070] Step S500, matching the real-time tag with the historical storage linked list, obtaining a matching result, and calculating the real-time update frequency of the tag according to the matching result;
[0071] Step S600, adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency, and adjusting the history order of the history storage linked list based on the matching result to obtain an updated storage linked list;
[0072] Step S700, traverse the update storage linked list, perform expiration detection on the update timestamps corresponding to a number of update tags, adjust the update storage linked list again according to the expiration detection result, and obtain a final storage linked list.
[0073] Specifically, the step of creating a storage linked list based on a number of historical tags of a user according to the embodiment of the present invention includes:
[0074] Create several empty bidirectional linked lists as historical storage linked lists;
[0075] Using the history tags and their corresponding access timestamps as nodes of a bidirectional linked list;
[0076] If the history storage linked list is empty, adding the bidirectional linked list node to the head of the history storage linked list;
[0077] If the historical storage linked list is not empty, traverse the historical storage linked list, mark the last node in the traversal result whose access timestamp is less than the access timestamp of the new bidirectional linked list node, and insert the new bidirectional linked list node after the node or to the end of the historical storage linked list.
[0078] Specifically, an example of a history storage linked list in an embodiment of the present invention is: if the access timestamp corresponding to history tag A is [25, 45, 150, 320], the access timestamp corresponding to history tag B is [15, 100], and the access timestamp corresponding to history tag C is [50, 240], then the latest access timestamp of each tag is selected as the representative timestamp, and a bidirectional linked list is created in ascending order of the representative timestamps:
[0079] Initialize an empty doubly linked list as the history storage list;
[0080] Adding history tag A as a bidirectional linked list node to the head of the history storage linked list;
[0081] Compare the representative timestamp 100 corresponding to the history tag B with the representative timestamp 320 of the node A, and insert the node B corresponding to the history tag B before the node A according to the comparison result;
[0082] Compare the representative timestamp 240 corresponding to the history label C with the representative timestamp 100 corresponding to the node B and the representative timestamp 320 corresponding to the node A, and insert the node C corresponding to the history label C between the node A and the node B according to the comparison result;
[0083] The corresponding final history storage linked list is shown in the following table:
[0084] History Tags Access timestamp B [15,100] C [50,240] A [25,45,150,320]
[0085] Specifically, the historical period in the embodiment of the present invention is one year;
[0086] The preset time period is 1 / 12 of the historical period.
[0087] Specifically, the embodiments of the present invention can deeply understand the interests and needs of users by collecting and analyzing historical behavior data of users, and provide a basis for accurate updating of subsequent tags. The use of a linked list structure can efficiently manage historical tags. At the same time, combined with access timestamps, the LRU algorithm can be conveniently implemented to ensure that the most frequently used tags are retained. The determination of the initial update frequency provides accurate data support for the update of subsequent tags, making the subsequent update strategy more reasonable and effective. The collection and analysis of real-time behavior data can reflect the current interests and needs of users, providing an important basis for the real-time update of tags. By matching real-time tags and historical tags, the real-time usage of tags is evaluated, and then the real-time update frequency is calculated to provide real-time feedback for the tag update strategy. According to the initial and real-time update frequencies, the historical storage linked list is dynamically adjusted to ensure that the most frequently used tags are retained and infrequently used tags are removed, thereby optimizing the use of storage resources. Expiration detection can timely detect and remove expired tags, ensuring that the tags in the storage linked list are valid and accurate, and optimizing the use of storage resources.
[0088] Specifically, the step of determining a number of historical tags and their corresponding access timestamps based on a number of historical behavior data includes:
[0089] Obtaining historical transaction records of the user, wherein the historical transaction records include historical transaction information, historical transaction time, historical transaction amount, and historical commodity type;
[0090] determining a plurality of said access timestamps based on said historical transaction time;
[0091] The historical tag is determined based on the historical transaction information, the historical transaction amount and the historical commodity type.
[0092] Specifically, the step of determining the historical tag based on the historical transaction information, the historical transaction amount and the historical commodity type includes:
[0093] Determine the historical transaction frequency based on the historical transaction information, and determine the transaction activity based on the transaction frequency;
[0094] Determine the total historical transaction amount based on the historical transaction amount, and determine the consumption capacity based on the total historical transaction amount;
[0095] determining a product preference based on the historical product types;
[0096] The historical tag is determined based on the transaction activity, the spending power, and the commodity preference.
[0097] Specifically, an example of determining the historical tag based on the user transaction preference in an embodiment of the present invention is: user L has conducted 50 transactions on the platform in the past year, with a total transaction amount of RMB 50,000, of which the types of purchased goods mainly include electronic products (accounting for 40%) and books (accounting for 30%), with 2 returns and 5 exchanges. User L has conducted 50 transactions in one year, with a transaction frequency of about 4 times / month. Compared with the average transaction frequency of 6 times / month of all users counted by the platform, it is determined that the user's transaction activity is medium-low activity. Compared with the minimum transaction frequency of 2 times / month of all users counted by the platform, it is determined that the user's transaction activity is medium activity.
[0098] Comparing the user's total transaction amount of 50,000 yuan with the average total transaction amount of 45,000 yuan for all users in the platform statistics, the user's consumption capacity is determined to be high;
[0099] Based on the fact that the largest proportion of products purchased by users is electronic products (accounting for 40%), it is determined that the user's product preference is digital electronics;
[0100] Based on the above, the user tags are determined to be [moderate activity, high spending power, digital electronics].
[0101] Specifically, the embodiments of the present invention accurately determine the user's transaction activity, consumption capacity and product preferences by carefully analyzing the user's transaction frequency, total transaction amount and product type, thereby more accurately obtaining user tags to provide strong support for subsequent tag updates and management.
[0102] See also Figure 2 As shown, the step of determining the initial update frequency of any of the history tags based on the plurality of access timestamps includes:
[0103] Step S310, sorting the access timestamps corresponding to any of the history tags based on the time series to obtain a sorting result;
[0104] Step S320, calculating the time interval between two adjacent access timestamps according to the sorting result;
[0105] Step S330, calculating the average of the plurality of time intervals, and taking the average as the average period;
[0106] Step S340, calculating the ratio of the number of access timestamps corresponding to any of the history tags to the total number of access timestamps of the history tags, and taking the ratio as the access frequency;
[0107] Step S350: determining the initial update frequency based on the averaging period, the access frequency and the adjustment coefficient.
[0108] Specifically, the time sequence described in the embodiment of the present invention is from earliest to latest.
[0109] Specifically, the adjustment period in the embodiment of the present invention is obtained by dividing the sum of the maximum time interval and the minimum time interval by the difference between the maximum time interval and the minimum time interval;
[0110] Assume that a certain historical tag has the following access timestamps (unit: seconds) in the past week: [1, 100, 500, 1000, 1200, 1800, 2400], the time interval is: [99, 400, 500, 200, 600, 600], the average period is: (99+400+500+200+600+600) / 5=479.8 seconds, and assume that the total number of historical tag access timestamps is 1000, and the number of access timestamps of this tag is 23, then the access frequency is: 23 / 100=0.23, then the initial update frequency can be set to the average period multiplied by the access frequency and then multiplied by the adjustment coefficient, and the initial update frequency is: 479.8×0.007×((600+99) / (600-99))=153.96 seconds.
[0111] Specifically, the embodiment of the present invention sorts the access timestamps by time series, clearly sees the time series of the historical tags being accessed, and thus understands the usage pattern of the tags, calculates the time intervals between adjacent access timestamps, and obtains the mean as the mean period, which reflects the average period of tag use and provides an important basis for determining the update frequency. The access frequency of the historical tags is calculated, the relative importance of the tags is quantified, and the initial update frequency of each historical tag is dynamically determined in combination with the mean period, access frequency and adjustment coefficient, which can improve the efficiency and accuracy of tag updates. By setting a suitable initial update frequency for each historical tag, unnecessary frequent updates or untimely updates can be avoided, thereby improving the overall performance and stability of the system and optimizing the use of storage resources.
[0112] See also Figure 3 As shown, the step of matching the real-time tag with the historical storage linked list includes:
[0113] Step S510, traversing the historical storage linked list with the real-time tag, if the historical storage linked list contains the real-time tag, marking the corresponding historical tag in the historical storage linked list to obtain a marking tag;
[0114] Step S520: If the real-time tag is not included in the history storage linked list, the similarity between the real-time tag and several history tags is calculated to obtain a similarity calculation result;
[0115] Step S530: If the similarity calculation result is greater than or equal to the preset similarity, the historical tag corresponding to the maximum value of the similarity calculation result is marked to obtain a marked tag.
[0116] Specifically, the embodiment of the present invention further includes that if the similarity calculation result is less than the preset similarity, the history storage linked list does not include the marking tag.
[0117] Specifically, the preset similarity in the embodiment of the present invention is 85%.
[0118] Specifically, in the embodiment of the present invention, the similarity calculation can be implemented by cosine similarity, Jaccard similarity or other suitable similarity algorithms. Among them, a possible example is that the real-time label is "smart bracelet", and the label is converted into a vector representation by using a word embedding model (such as Word2Vec) or a TF-IDF-based method, and the cosine value of the "smart bracelet" vector and each historical label vector is calculated to determine the similarity between them. The similarity result between the "smart bracelet" and the historical label "smart electronics" is calculated to be greater than the preset similarity, and "smart electronics" is used as a marking label.
[0119] Specifically, the embodiment of the present invention traverses the historical storage linked list to quickly locate whether there is a label identical to the real-time label, thereby improving the matching efficiency. When there is no label identical to the real-time label in the historical storage linked list, the similarity between the real-time label and the existing historical label is calculated, and the correlation between the real-time label and the historical label is quantified. By setting a preset similarity threshold, the strictness of the matching is adjusted according to actual needs, thereby enhancing the flexibility of label updating. Through similarity calculation and matching, historical labels that are highly correlated with the real-time label are identified, thereby avoiding repeated storage of similar labels and optimizing the use of storage space.
[0120] Specifically, the step of calculating the real-time update frequency of the tag according to the matching result includes:
[0121] When the matching result is that the history storage linked list contains the marking tag, obtaining a plurality of marking timestamps corresponding to the marking tag;
[0122] Calculate the marking duration based on the plurality of marking timestamps;
[0123] Calculate a first update frequency based on the number of the marking tags and the marking duration;
[0124] When the matching result is that the historical storage linked list does not contain the marking tag, obtaining several real-time timestamps corresponding to the real-time tag;
[0125] Calculate the real-time duration based on the real-time timestamps;
[0126] A second update frequency is calculated based on the number of the real-time tags and the real-time duration.
[0127] Specifically, the first update frequency in the embodiment of the present invention is the number of marked tags divided by the marking duration;
[0128] The second update frequency is the number of real-time tags divided by the real-time duration.
[0129] Specifically, the embodiment of the present invention accurately measures the activity of a specific tag within a period of time by calculating the marking duration of the marked tag and the real-time duration of the real-time tag, which helps the system to more accurately understand user needs and tag usage trends. Based on the calculated first update frequency and second update frequency, a basis is provided for tag management. By calculating the real-time update frequency, more personalized and accurate services are provided to users according to the activity of the tag. The real-time update frequency, as a data indicator, provides accurate data support for tag update decisions and optimizes resource utilization.
[0130] Specifically, the step of adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency includes:
[0131] increasing the history length or decreasing the history length according to a comparison result between the first update frequency and the initial update frequency;
[0132] The history length is increased according to a comparison result of the second update frequency and the initial update frequency.
[0133] Specifically, in the embodiment of the present invention, when the first update frequency is greater than or equal to the initial update frequency, the ratio of the first update frequency to the initial update frequency is calculated, the ratio is used as the growth coefficient, and the increased history length = ratio × history length;
[0134] When the first update frequency is less than the initial update frequency, the difference between the first update frequency and the initial update frequency is calculated, and the ratio of the difference to the initial update frequency is calculated, and the ratio is used as the reduction amplitude, and the history length after reduction = (1-ratio) × history length;
[0135] When the second update frequency is greater than or equal to the initial update frequency, the ratio of the second update frequency to the initial update frequency is calculated, and the ratio is used as the growth rate, and the increased history length = (1 + ratio) × history length;
[0136] When the second update frequency is less than the initial update frequency, the history length is not adjusted.
[0137] Specifically, the embodiment of the present invention dynamically adjusts the history length of the history storage linked list by comparing the first update frequency and the initial update frequency. When the first update frequency is higher than or equal to the initial update frequency, the history length is increased to adapt to the high-frequency update of data. When the first update frequency is lower than the initial update frequency, the history length is reduced to optimize the use of storage space. For the case where the real-time update frequency is higher than or equal to the initial update frequency, the history length is increased according to the ratio of the real-time update frequency to the initial update frequency, thereby ensuring that the system can retain sufficient historical data to support accurate analysis and prediction of data changes. When the real-time update frequency is lower than the initial update frequency, the history length is not adjusted, thereby avoiding unnecessary waste of storage space. Dynamically adjusting the history length of the history storage linked list helps to improve data processing efficiency. By accurately controlling the history length of the history storage linked list, excessive data storage is avoided, thereby reducing the waste of storage space, computing resources and maintenance costs.
[0138] Specifically, the step of adjusting the history order of the history storage linked list based on the matching result includes:
[0139] When the matching result is that the historical storage linked list contains the marking tag, obtaining the position of the marking tag in the historical storage linked list;
[0140] Traversing the history storage linked list based on the latest marking timestamp corresponding to the marking tag, and moving the marking tag according to the traversal result;
[0141] When the matching result is that the historical storage linked list does not contain the marking tag, the real-time tag and its corresponding real-time timestamp are added to the head of the historical storage linked list.
[0142] Specifically, in an embodiment of the present invention, when the matching result is that the historical storage linked list contains a marked label, the historical storage linked list is traversed and adjusted according to the latest marked timestamp, and the latest marked label is moved to a position closer to the head in the linked list to ensure that the most recently updated or most frequently used data is located at the front end of the linked list, thereby improving the efficiency of data access. By moving the latest marked label to the front end of the linked list, historical data is more effectively organized and managed, which helps to improve the overall performance of the system. When the matching result is that the historical storage linked list does not contain a marked label, the real-time label and its corresponding real-time timestamp are added to the head of the historical storage linked list to reflect the changes in new data in real time, ensuring that the system can process and respond to new data input in a timely manner. By adding new data to the head of the linked list, the old data is gradually moved backwards, thereby maintaining the freshness and availability of the data. By sorting and adjusting the historical storage linked list, data query and retrieval requests are processed more efficiently.
[0143] See also Figure 4As shown, the step of performing expiration detection on update timestamps corresponding to a plurality of update tags includes:
[0144] Step S710, calculating the expiration time according to the difference between the current timestamp and the update timestamp;
[0145] Step S720, comparing the expiration time with a preset time, and determining whether it is expired according to the comparison result.
[0146] Specifically, the step of re-adjusting the update storage linked list according to the expiration detection result includes:
[0147] When the expiration time is greater than the preset time, the update tag is removed from the update storage linked list, and the order of the remaining tags is updated;
[0148] When the expiration time is less than or equal to the preset time, the update linked list is not adjusted.
[0149] Specifically, the embodiments of the present invention can accurately determine which update tags have expired by calculating the expiration time and comparing it with the preset time, thereby avoiding the storage of invalid data, improving the efficiency of data management, ensuring the accuracy and real-time of data in the system, removing expired update tags to release storage space, enabling the system to more effectively utilize limited resources, and improving the overall performance of the system. It removes expired tags and updates the sorting of remaining tags to ensure that the data in the update storage linked list is valid and up-to-date, which helps to speed up the data retrieval process, and by re-adjusting the update storage linked list to maintain the consistency and integrity of its internal data, it helps to improve the stability of the system and reduce potential problems caused by data inconsistencies or errors.
[0150] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0151] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A label updating method based on LRU, characterized in that: include: Acquire a number of historical behavior data within a historical period of the user, and determine a number of historical tags and their corresponding access timestamps based on the number of historical behavior data; Creating a history storage linked list based on the history tags and the access timestamps corresponding to the history tags; Determining an initial update frequency of any of the history tags based on a number of the access timestamps; The step of determining the initial update frequency of any one of the history tags based on the plurality of access timestamps comprises: Sort the access timestamps corresponding to any of the history tags based on the time series to obtain a sorting result; Calculate the time interval between two adjacent access timestamps based on the sorting results; Calculate the mean of a number of said time intervals and use the mean as the mean period; Calculate the ratio of the number of access timestamps corresponding to any of the history tags to the total number of access timestamps of the history tags, and use the ratio as the access frequency; Determining the initial update frequency based on the averaging period, the access frequency and the adjustment coefficient; Collect the user's real-time behavior data within a preset time period, and determine the user's real-time tag based on the real-time behavior data; Matching the real-time tag with the historical storage linked list to obtain a matching result, and calculating the real-time update frequency of the tag according to the matching result; The step of calculating the real-time update frequency of the tag according to the matching result includes: When the matching result is that the history storage linked list contains a marking tag, obtaining a number of marking timestamps corresponding to the marking tag; Calculate the marking duration based on the plurality of marking timestamps; Calculate a first update frequency based on the number of the marking tags and the marking duration; When the matching result is that the historical storage linked list does not contain the marking tag, obtaining several real-time timestamps corresponding to the real-time tag; Calculate the real-time duration based on the real-time timestamps; Calculating a second update frequency based on the number of the real-time tags and the real-time duration; Adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency, and adjusting the history sorting of the history storage linked list based on the matching result to obtain an updated storage linked list; The update storage linked list is traversed, an expiration detection is performed on the update timestamps corresponding to the plurality of update tags, and the update storage linked list is adjusted again according to the expiration detection result to obtain a final storage linked list.
2. The LRU-based label updating method according to claim 1, characterized in that: The step of determining a plurality of historical tags based on a plurality of historical behavior data comprises: Obtaining historical transaction records of the user, wherein the historical transaction records include historical transaction information, historical transaction time, historical transaction amount, and historical commodity type; determining a plurality of said access timestamps based on said historical transaction time; The historical tag is determined based on the historical transaction information, the historical transaction amount and the historical commodity type.
3. The LRU-based label updating method according to claim 2, characterized in that: The step of determining the historical tag based on the historical transaction information, the historical transaction amount and the historical commodity type comprises: Determine the historical transaction frequency based on the historical transaction information, and determine the transaction activity based on the transaction frequency; Determine the total historical transaction amount based on the historical transaction amount, and determine the consumption capacity based on the total historical transaction amount; determining a product preference based on the historical product types; The historical tag is determined based on the transaction activity, the spending power, and the commodity preference.
4. The LRU-based label updating method according to claim 3, characterized in that: The step of matching the real-time tag with the historical storage linked list comprises: Traverse the historical storage linked list with the real-time tag, and if the historical storage linked list contains the real-time tag, mark the corresponding historical tag in the historical storage linked list to obtain a marked tag; If the real-time tag is not included in the historical storage linked list, the similarity between the real-time tag and several historical tags is calculated to obtain a similarity calculation result; If the similarity calculation result is greater than or equal to the preset similarity, the historical tag corresponding to the maximum value of the similarity calculation result is marked to obtain a marked tag.
5. The LRU-based label updating method according to claim 4, characterized in that: The step of adjusting the history length of the history storage linked list based on the initial update frequency and the real-time update frequency comprises: increasing the history length or decreasing the history length according to a comparison result between the first update frequency and the initial update frequency; The history length is increased according to a comparison result of the second update frequency and the initial update frequency.
6. The LRU-based label updating method according to claim 5, characterized in that: The step of adjusting the historical order of the historical storage linked list based on the matching result comprises: When the matching result is that the historical storage linked list contains the marking tag, obtaining the position of the marking tag in the historical storage linked list; Traversing the history storage linked list based on the latest marking timestamp corresponding to the marking tag, and moving the marking tag according to the traversal result; When the matching result is that the historical storage linked list does not contain the marking tag, the real-time tag and its corresponding real-time timestamp are added to the head of the historical storage linked list.
7. The LRU-based label updating method according to claim 6, characterized in that: The step of performing expiration detection on update timestamps corresponding to a plurality of update tags comprises: Calculating the expiration time according to the difference between the current timestamp and the update timestamp; The expiration time is compared with a preset time, and whether it is expired is determined according to the comparison result.
8. The LRU-based label updating method according to claim 7, characterized in that: The step of re-adjusting the update storage linked list according to the expiration detection result comprises: When the expiration time is greater than the preset time, the update tag is removed from the update storage linked list, and the order of the remaining tags is updated; When the expiration time is less than or equal to the preset time, the update storage linked list is not adjusted.
Citation Information
Patent Citations
User tag updating method, system and equipment based on time sequence and storage medium
CN117648608A
Big data real-time user tag method and system, computer equipment and storage medium
CN116127162A
Data label storage management method and device, equipment and storage medium
CN116680276A