Skip to content

Suman942/LRUCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Why does Glide load images so fast in Android apps?

It’s not magic – it’s LRU Cache (Least Recently Used Cache) at work! 🧑‍💻

When you open an app and scroll through images (say Instagram or your gallery app), Glide doesn’t download every image from the internet again. Instead, it:

1️⃣ Checks if the image is already in memory (cached).

2️⃣ If yes → instantly shows it.

3️⃣ If no → downloads it, stores it in cache, and displays it.

But memory is limited. So how does Glide decide which old images to remove?

👉 It uses LRU Cache – it removes the least recently used image when space runs out, keeping only the most relevant ones.

💡 Example:

You scroll through 10 images → all get cached.

You move to the 11th image → Glide removes the one you haven’t seen for the longest time, making space for the new one.

⚡ Efficiency:

get(key) → O(1)

put(key, value) → O(1)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages