Minor improvement to cache by reducing area under lock.
This commit is contained in:
parent
98e4265db7
commit
925296f326
@ -31,11 +31,11 @@ public class Cache<Key, Value> {
|
||||
if (data.size() > maxSize) {
|
||||
int occ = 0;
|
||||
do {
|
||||
Key potentialKey = occurrenceOrder.poll();
|
||||
CacheValue<Value> potential = data.get(potentialKey);
|
||||
potential.occurrence--;
|
||||
cleaningLock.lock();
|
||||
try {
|
||||
Key potentialKey = occurrenceOrder.poll();
|
||||
CacheValue<Value> potential = data.get(potentialKey);
|
||||
potential.occurrence--;
|
||||
occ = potential.occurrence;
|
||||
if (occ < 1) {
|
||||
data.remove(potentialKey);
|
||||
|
Loading…
Reference in New Issue
Block a user