Polish MimeTypeUtils LRU cache
This commit improves the cache implementation by skipping the ordering of most recently used cached keys when the cache is at least half empty. See gh-23211
This commit is contained in:
parent
511a430906
commit
5a308ad5bd
|
|
@ -433,7 +433,13 @@ public abstract class MimeTypeUtils {
|
|||
public V get(K key) {
|
||||
this.lock.readLock().lock();
|
||||
try {
|
||||
if (this.queue.remove(key)) {
|
||||
if (this.queue.size() < this.maxSize / 2) {
|
||||
V cached = this.cache.get(key);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
else if (this.queue.remove(key)) {
|
||||
this.queue.add(key);
|
||||
return this.cache.get(key);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue