Removing unused methods on Cache and synchronizing it since FieldAttributes contains a static instance of this type.
This commit is contained in:
parent
1e2fbd81f5
commit
439d931c5a
|
@ -48,14 +48,4 @@ interface Cache<K, V> {
|
|||
* @return the value for the given {@code key}
|
||||
*/
|
||||
V removeElement(K key);
|
||||
|
||||
/**
|
||||
* Removes everything from this cache.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @return the number of objects in this cache
|
||||
*/
|
||||
int size();
|
||||
}
|
||||
|
|
|
@ -37,28 +37,18 @@ final class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
|
|||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
public void addElement(K key, V value) {
|
||||
public synchronized void addElement(K key, V value) {
|
||||
put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
}
|
||||
|
||||
public V getElement(K key) {
|
||||
public synchronized V getElement(K key) {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
public V removeElement(K key) {
|
||||
public synchronized V removeElement(K key) {
|
||||
return remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<K, V> entry) {
|
||||
return size() > maxCapacity;
|
||||
|
|
Loading…
Reference in New Issue
Block a user