Added doc and changed accessibility of support class.
This commit is contained in:
parent
7a2a2d4ca6
commit
e7f5558aa5
@ -22,6 +22,13 @@ public class Cache<K, V> {
|
||||
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<K, V> {
|
||||
return value.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cache of all values.
|
||||
*/
|
||||
public void clearCache() {
|
||||
writeLock.lock();
|
||||
try {
|
||||
|
@ -2,7 +2,7 @@ package ca.recrown.islandsurvivalcraft.caching;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class UsageStack<K, V> {
|
||||
class UsageStack<K, V> {
|
||||
private volatile CacheValue<K, V> first, last;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user