The special day (Labor Day, May 1, 2015) marks the return and the new journey, and uses the principles and differences of LRU and LFU to inspire others. lrulfu
I haven't written any new blog for a long time. There are many reasons. The reason is that I am busy with my work, my life is busy, and I am tired. To put it bluntly, I am too lazy to write my blog.
After a long period of silence, I finally had to start again. I felt that I had to settle in my current status first, and then I had to empty myself. I had to leave myself empty so that I could continue to improve.
The blog content that will be updated later will be subject to analysis of difficult issues related to the Android Framework, principles of mechanism implementation, source code call analysis, and some common small algorithms and language features, program principle.
Today, we will introduce the ideas and principles of the LRU and LFU cache algorithms commonly used in the Android Framework and apps, in fact, the principle and philosophy of these cache algorithms are the same as those of the Virtual Memory Page Replacement Algorithm in Linux, but the specifics are different.
LFU (Least Frequently Used):The minimum frequency algorithm is used. The train of thought and principle are:If a piece of data is rarely used in the recent period of time, it will be less likely to be used in the future,The general purpose of this algorithm is: When cache content needs to be updated and has been fully stored, quickly find and replace the content that has been used for the entire cache at least times.
LRU (LeastRecently Used ):Algorithm has not been used for the longest time. The idea and principles are as follows:If a data is not accessed in the recent period, it will be very unlikely to be accessed in the future,The purpose of this algorithm is to quickly find the content that has not been used in the cache for the longest time when the cached content needs to be updated and has been fully stocked, then, delete and reconstruct the cache structure, and store the released memory location to the updated content.
Reference link:
Http://www.cnblogs.com/dolphin0520/p/3749259.html
Http://www.cnblogs.com/dolphin0520/p/3741519.html
Http://blog.sina.com.cn/s/blog_631d3a630101mhup.html
Http://qyappchentao.sinaapp.com/linux-mem-al/
Http://blog.sina.com.cn/s/blog_50197c290101ft7a.html
Http://blog.csdn.net/summerhust/article/details/6867171
Http://dennis-zane.iteye.com/blog/128278
Http://blog.csdn.net/luoweifu/article/details/8297084/