Is there an equivalent of Android's LRUCache in Java?

别等时光非礼了梦想. 提交于 2019-12-25 01:27:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!