Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
The existing cache implementation could be replaced with java.util.LinkedHashMap. This change would replace our custom implementation with an implementation which will be maintained for us.
To have the same behaviour as our implementation LinkedHashMap must be subclasses. The LinkedHashMap.removeEldestEntry must be overwritten and return true if size limit is reached.
This could be something like this:
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.Map;
public class Cache<K, V> extends LinkedHashMap<K,V> {
private final int capacity;
public Cache(int capacity)
{ this.capacity = capacity; } @Override
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
}
Attachments
Issue Links
- links to