From e7f5558aa5ae678789e44014a52c68ad082f4fd8 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 28 Apr 2020 17:35:08 -0500 Subject: [PATCH] Added doc and changed accessibility of support class. --- .../ca/recrown/islandsurvivalcraft/caching/Cache.java | 10 ++++++++++ .../islandsurvivalcraft/caching/UsageStack.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java index 4318ece..ce859da 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java @@ -22,6 +22,13 @@ public class Cache { this(1024); } + /** + * Sets the value with the respective associated key. + * If the addition of this value and key cause the cache to be bigger than its designated max size, + * It will remove one of the least used values in the cache to accomodate. + * @param key The key to associate with the value. + * @param value The value to store. + */ public void set(K key, V value) { writeLock.lock(); try { @@ -62,6 +69,9 @@ public class Cache { return value.value; } + /** + * Clears the cache of all values. + */ public void clearCache() { writeLock.lock(); try { diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/UsageStack.java b/src/main/java/ca/recrown/islandsurvivalcraft/caching/UsageStack.java index f0efa5b..ad14305 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/UsageStack.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/caching/UsageStack.java @@ -2,7 +2,7 @@ package ca.recrown.islandsurvivalcraft.caching; import java.util.concurrent.locks.ReentrantLock; -public class UsageStack { +class UsageStack { private volatile CacheValue first, last; private final ReentrantLock lock = new ReentrantLock();