When to use LRU vs LFU Cache Replacement algorithms?

Technology CommunityCategory: CachingWhen to use LRU vs LFU Cache Replacement algorithms?
VietMX Staff asked 3 years ago
  • LRU (Least Recently Used) is good when you are pretty sure that the user will more often access the most recent items, and never or rarely return to the old ones. An example: a general usage of an e-mail client. In most cases, the users are constantly accessing the most recent mails. They read them, postpone them, return back in a few minutes, hours or days, etc. They can find themselves searching for a mail they received two years ago, but it happens less frequently than accessing mails they received the last two hours.
  • On the other hand, LRU makes no sense in the context where the user will access some items much more frequently than others. An example: I frequently listen to the music I like, and it can happen that on 400 songs, I would listen the same five at least once per week, while I will listen at most once per year 100 songs I don’t like too much. In this case, LFU (Least Frequently Used) is much more appropriate.