🧑🏫 Discussion
Why do computers have multiple memory levels?
Cache is small but blazing fast (like having a notepad on your desk). RAM is larger but slower (like a
filing cabinet). Your CPU checks cache first — if the data's there ("cache hit"), great! If not ("cache
miss"), it must wait for RAM. How does caching affect your phone's speed? Apps you use
often stay in cache, so they open instantly. Apps you haven't used in a while get evicted and take longer
to load.
🎴 Activity
Simulate an LRU Cache with Playing Cards: Deal 10 cards face down (RAM). Pick 3 to flip
face up (Cache). When you need a card, check if it's face up (cache hit = fast!). If not, flip a face-up
card down and flip the needed card up (cache miss = eviction). The least recently used card gets
evicted — just like a real CPU cache!