LinkedHashMap
as LRU cache. Also, I've found such code with a direct link as comment in Apache Roller source code.
LinkedHashMap
can be used as LRU cache because it supports ordering it's elements not only by insert order, but also by access-order. Also there is protected method removeEldestEntry
in the LinkedHashMap
that runs in the put()
and putAll()
methods. If that method returns true, than least recently inserted/accessed element will be removed.
No comments:
Post a Comment