Made sure occurrences are properly tracked.
This commit is contained in:
parent
4b6cfacc47
commit
dcec9fd7e7
@ -26,7 +26,7 @@ public class Cache<Key, Value> {
|
||||
while (occurrences.get(occurrenceOrder.peek()) > 1) {
|
||||
occurencesTrackedPoll();
|
||||
}
|
||||
data.remove(occurrenceOrder.poll());
|
||||
data.remove(occurencesTrackedPoll());
|
||||
}
|
||||
occurrencesTrackedAdd(key);
|
||||
}
|
||||
@ -63,12 +63,12 @@ public class Cache<Key, Value> {
|
||||
* @param key the key associated with the value.
|
||||
* @return the value associated to the key.
|
||||
*/
|
||||
public Value getValue(Key key) {
|
||||
public synchronized Value getValue(Key key) {
|
||||
occurrencesTrackedAdd(key);
|
||||
return data.get(key);
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
public synchronized void clearCache() {
|
||||
data.clear();
|
||||
occurrenceOrder.clear();
|
||||
occurrences.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user