A cache measured in size
transcript
A feed app keeps pages in memory. The limit is total size. It is not a number of pages.
The newest page sits at the front. The oldest page sits at the back. A get moves a page to the front.
Pages of three and five are stored. A page of six is put, over the limit of ten. The total is now fourteen.
Remove the oldest page, and the total is eleven. That is still over ten. Remove the next, and the total is six.
A loop removes two pages, and it fits. Removing only one leaves the cache too full.
A drop removes a page on purpose. It also lowers the total. It answers one, or zero if missing.
In the interview, say what a get changes. Say what a put may remove. And say what a drop lowers.
A page can be bigger than the limit. Store nothing in that case. The answer is minus one.
The limit is total size. Loop until the total fits. Full breakdown in the lecture.