I need a simple caching mechanism.
I want to keep up with the last 100 most recent items that have been added, but nothing more. When I add another item, I want the collection to automatically delete the 101st item. Imagine you pushing LifeSaver candies through the handset as I add another candy at one end of the tube and another candy will drop out at the other end.
It would be easy to write your own. My add method will first remove the oldest item before doing the add. I'm just wondering if there is already such a class.
I looked at the related classes of Collection, List, Queue, etc. I looked at Google Guava . But they do not have such a simple function.
This is a tricky topic for Google as I don’t know the jargon for this behavior.
java collections
Basil Bourque Feb 11 '14 at 8:29 2014-02-11 08:29
source share