What is LRU (Least Recently Used)?

LRU stands for Least Recently Used, and it’s like having a special friend who always remembers who you talked to last, and forgets about people you didn’t talk to in a while.

Imagine you have a toy box with only 3 spots, and every time you play with a new toy, you put it on top of the pile. If you don't play with a toy for a long time, it goes to the bottom of the pile. When your toy box is full and you want a new toy, you take out the one at the bottom, because that’s the least recently used.

How It Works in Real Life

Think about your backpack when you go to school. You have 3 favorite snacks: apple, banana, and cookie. Every morning, you pick one snack to eat first. If you eat a banana today, you put it on top of your snack pile. If you don’t eat the apple for a few days, it goes down to the bottom.

When your snack pile is full, and you need more snacks, you take out the least recently used, that’s the one at the bottom, maybe the apple. That way, you always have the snacks you use most often ready!

LRU helps computers remember which things are being used a lot, and forget about the ones that aren’t, just like how you remember your favorite snacks!

Take the quiz →

Examples

  1. A computer uses LRU to keep track of which files are used most often, like remembering your favorite snacks in a lunchbox.
  2. Imagine you have a limited number of shelves for books. The ones you read the least recently get moved to the back.
  3. LRU helps you decide which apps to close when your phone is running out of space.

Ask a question

See also

Discussion

Recent activity