Adding to usage list before to hashmap for better concurrency.
This commit is contained in:
@@ -35,8 +35,8 @@ public class Cache<K, V> {
|
||||
CacheValue<K, V> val = new CacheValue<>();
|
||||
val.key = key;
|
||||
val.value = value;
|
||||
data.put(key, val);
|
||||
usage.add(val);
|
||||
data.put(key, val);
|
||||
if (data.size() > maxSize) {
|
||||
data.remove(usage.pop().key);
|
||||
}
|
||||
|
Reference in New Issue
Block a user