Is there some kind of collection implementation that supports the expiration of elements.
For example:
Collection<User> cachedUsers = new ExpirableList<User>(10000);
Where
public ExpirableList(final long timeout){...}
And after a given time ( 10000ms in this particular example), the added items will be removed from the collection. Using this, we will prevent our cachedUsers collection from overflowing.
fiction
source share