Lab · Caching
Learn caching by playing: six worlds from your first hit to choosing eviction policies. Free play with the open visualizer is further down.
6 worlds · 12 missions
Decide what stays on the shelf.
Your database is slow and your visitors are impatient. You run a tiny, fast shelf between them. Keep the right things on it.
Choose your difficulty
Least-recently-used eviction is the default policy behind most caches. Access a key — if it's already cached, it jumps to the front. If the cache is full and you access something new, whatever's been idle longest gets evicted.
Cache — most recently used on the left
Access a key to populate the cache.
Hit rate
0%
Recent accesses
No accesses yet.
6 worlds, 12 missions and 25 glossary topics.
Understand what a cache is and why it forgets things.
Missions: Get your first hit, Push A off the shelf.
Use the least-recently-used rule on purpose.
Missions: Save A, sacrifice B, Reach a 60% hit rate.
Find where LRU fails and size a cache properly.
Missions: Break LRU completely, Choose the smallest cache.
Compare eviction policies and design for real systems.
Missions: Make FIFO beat LRU, Show why frequency matters.
Keep cached data correct while it is being changed.
Missions: Where evicting the newest wins, Incident room: writes.
Run caches across many machines without falling over.
Missions: The long shift, Incident room: outage.
A Least Recently Used cache has limited room and, when full, removes the item that has gone the longest without being used.
LRU removes what was used longest ago. LFU removes what is used least often, which keeps steady favourites but can hold on to items that were popular only in the past.
Many requests miss on the same key at once and all go to the database. Locking, request coalescing or refreshing early prevents it.
It is free and needs no account. It has 6 worlds and 12 missions, and your progress is saved only in your own browser.