Subclass method to control removal of the least recently used entry from the map.
This method exists for subclasses to override. A subclass may wish to
provide cleanup of resources when an entry is removed. For example:
protected boolean removeLRU(LinkEntry entry) {
releaseResources(entry.getValue()); // release resources held by entry
return true; // actually delete entry
}
Alternatively, a subclass may choose to not remove the entry or selectively
keep certain LRU entries. For example:
protected boolean removeLRU(LinkEntry entry) {
if (entry.getKey().toString().startsWith("System.")) {
return false; // entry not removed from LRUMap
} else {
return true; // actually delete entry
}
}
The effect of returning false is dependent on the scanUntilRemovable flag.
If the flag is true, the next LRU entry will be passed to this method and so on
until one returns false and is removed, or every entry in the map has been passed.
If the scanUntilRemovable flag is false, the map will exceed the maximum size.
NOTE: Commons Collections 3.0 passed the wrong entry to this method.
This is fixed in version 3.1 onwards.