Gave newly cached items usage greater than the lowest.
This commit is contained in:
parent
a412986044
commit
28b9a8005c
@ -17,9 +17,8 @@ public class Cache <CacheValueType> {
|
||||
public synchronized CacheValue<CacheValueType> retrieveCache(Identifier identifier) {
|
||||
if (dataCache.containsKey(identifier)) {
|
||||
ids.remove(identifier);
|
||||
dataCache.get(identifier);
|
||||
CacheValue<CacheValueType> val = dataCache.get(identifier);
|
||||
val.getValue();
|
||||
val.identifier.usage++;
|
||||
ids.add(val.identifier);
|
||||
return dataCache.get(identifier);
|
||||
}
|
||||
@ -27,6 +26,9 @@ public class Cache <CacheValueType> {
|
||||
dataCache.remove(ids.poll());
|
||||
}
|
||||
CacheValue<CacheValueType> value = new CacheValue<>(identifier);
|
||||
if (!ids.isEmpty()) {
|
||||
identifier.usage += ids.peek().usage;
|
||||
}
|
||||
ids.add(identifier);
|
||||
dataCache.put(identifier, value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user