I need a simple caching mechanism.
I want to keep up to the last 100 most-recent items that were added, but no more than that limit. As I add another item, I want the collection to automatically delete the 101st item. Imagine pushing LifeSaver candies through a tube – as I add another candy at one end of the tube, at the other end another candy will fall out.
It would be simple to write my own. My "add" method would first delete the oldest item before performing tho "add". I just wonder if there is already such a class written.
I looked at the bundled Collection classes, List, Queue, and so on. I looked a Google Guava as well. But none seem to have this simple feature.
This is a difficult topic to google, as I do not know the jargon for this behavior.