diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java index e8ef468..07924df 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java @@ -26,7 +26,7 @@ public class Cache { while (occurrences.get(occurrenceOrder.peek()) > 1) { occurencesTrackedPoll(); } - data.remove(occurrenceOrder.poll()); + data.remove(occurencesTrackedPoll()); } occurrencesTrackedAdd(key); } @@ -63,12 +63,12 @@ public class Cache { * @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();