mirror of
https://github.com/doocs/advanced-java.git
synced 2025-03-24 10:50:06 +08:00
Polish Javadoc in LRUCache
This commit is contained in:
parent
70d7136fad
commit
fa803c94cc
@ -62,10 +62,14 @@ class LRUCache<K, V> extends LinkedHashMap<K, V> {
|
||||
CACHE_SIZE = cacheSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钩子方法,通过put新增键值对的时候,若该方法返回true
|
||||
* 便移除该map中最老的键和值
|
||||
*/
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
|
||||
// 当 map中的数据量大于指定的缓存个数的时候,就自动删除最老的数据。
|
||||
return size() > CACHE_SIZE;
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user