A standard Java LRU Cache implementation example in Java points to an example depot URL
http://www.exampledepot.com/egs/java.util/coll_Cache.html
How is removeEldestEntry called by default after adding a new entry to the code snippet below?
final int MAX_ENTRIES = 100;
Map cache = new LinkedHashMap(MAX_ENTRIES+1, .75F, true) {
public boolean removeEldestEntry(Map.Entry eldest) {
return size() > MAX_ENTRIES;
}
};
Object key = "key";
cache.put(key, object);
Object o = cache.get(key);
if (o == null && !cache.containsKey(key)) {
}
cache = (Map)Collections.synchronizedMap(cache);
source
share