问题
I would like to use Android's LruCache in my plain old non-Android Java projects. Is there an equivalent data structure in regular Java or do I have to roll out my own implementation?
回答1:
In regular Java you can do it with a LinkedHashMap, using the 3-argument constructor to make it access-ordered, and overriding removeEldestEntry to expire entries.
来源:https://stackoverflow.com/questions/53417187/is-there-an-equivalent-of-androids-lrucache-in-java