Cache replacement algorithm: The difference between LRU and LFU

Source: Internet
Author: User

LFU (Least frequently used) The least recently used algorithm. It is based on the idea that " if a data is used very infrequently in the last period of time, then the likelihood of being used in the future is also very small". LRU (Least recently used).

Note the difference between the LFU and the LRU algorithm, the LRU elimination rule is based on the access time, and the LFU is based on the number of visits. To give a simple example:

Suppose the cache size is 3, the data access sequence is set (2,2), set (2), get (1), get (2), set (3,3), set (+),

The LFU algorithm should be eliminated at set (3,3), and LRU should be eliminated.

  

Cache replacement algorithm: The difference between LRU and LFU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.