Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between LRU and LFU

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the difference between LRU and LFU". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between LRU and LFU".

Common cache culling strategies are

FIFO (First In First Out) first-in, first-out, eliminates the earliest data.

LRU (Least Recently Used) removes the least recently used.

LFU (Least Frequently Used) removes the least frequently used data.

FIFO first-in-first-out is easy to understand, LRU and LFU make people a little confused, Baidu encyclopedia explanation silly a little confused.

I found some information and gave an example to sort it out.

If there is data in the cache as follows:

Yao Maomao | Silent King II | Pure smile

Only 3 data can be stored in the cache, and now you need to add one more data:

Java geek technology

It means getting rid of a cached data.

At this time, the cache records the access order of the most recent period of time, from farthest to most recent, in the following order:

Yao Maomao | Silent Wang 2 | Yao Maomao | Pure smile | Yao Maomao | Silent Wang 2 | Pure smile

According to LRU rules, Yao Mao will be eliminated because it has not been used for the longest time. "Silent King II" and "Pure smile" have been used since Yao Maomao.

So the disadvantages of LRU are also obvious, high-frequency data that has not been used recently may be eliminated.

It may mislead a large number of hot data due to a batch query of cold data.

Thank you for your reading, the above is the content of "what is the difference between LRU and LFU". After the study of this article, I believe you have a deeper understanding of what is the difference between LRU and LFU, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report