public class CacheManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CacheManager.ClassKey
Represents the key used to differentiate between multiple classes
when retrieving their cache sizes.
|
| Modifier and Type | Field and Description |
|---|---|
static java.util.Map<CacheManager.ClassKey,java.lang.Integer> |
cacheValues
Map that contains cache values for each class (even multiple cache values)
|
private static CentralLogger |
LOG
Logger
|
| Constructor and Description |
|---|
CacheManager() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> LRUCache<K,V> |
createLRUCache(java.lang.Class<?> clazz,
int defaultSize)
Creates a LRUCache instance based on the parameters specified.
|
static <K,V> LRUCache<K,V> |
createLRUCache(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize)
Creates a LRUCache instance based on the parameters specified.
|
static <K,V> LRUCache<K,V> |
createLRUCache(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize,
java.util.function.Function<V,java.lang.Boolean> expirationTest)
Creates a LRUCache instance based on the parameters specified.
|
static <K,V> LRUCache<K,V> |
createLRUCache(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize,
java.util.function.Function<V,java.lang.Boolean> expirationTest,
CapacityPolicy capacityPolicy)
Creates a LRUCache instance based on the parameters specified.
|
static <K,V> java.util.Map<K,V> |
createMapCache(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize) |
private static int |
getCacheSize(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize)
Method that looks for the configured size of a cache and returns it's size.
|
static void |
initialize()
Initializes the cacheValues map and if the configuration from the directory
file can be accessed, it will populate the map with the configuration values
found for each class.
|
private static final CentralLogger LOG
public static java.util.Map<CacheManager.ClassKey,java.lang.Integer> cacheValues
public static void initialize()
null.public static <K,V> LRUCache<K,V> createLRUCache(java.lang.Class<?> clazz, int defaultSize)
createLRUCache(Class, String, int),
it invokes the method assuming the last parameter is null.K - The key type.V - The value type.clazz - The class for which the cache is created.defaultSize - The default size of the cache if it doesn't exist in the configuration.public static <K,V> LRUCache<K,V> createLRUCache(java.lang.Class<?> clazz, java.lang.String discriminator, int defaultSize)
createLRUCache(Class, String, int, Function),
it invokes the method assuming the last parameter is null.K - The key type.V - The value type.clazz - The class for which the cache is created.discriminator - The value used to differentiate between caches of the same class.defaultSize - The default size of the cache if it doesn't exist in the configuration.public static <K,V> LRUCache<K,V> createLRUCache(java.lang.Class<?> clazz, java.lang.String discriminator, int defaultSize, java.util.function.Function<V,java.lang.Boolean> expirationTest)
createLRUCache(Class, String, int, Function, CapacityPolicy),
it invokes the method assuming the last parameter is null.K - The key type.V - The value type.clazz - The class for which the cache is created.discriminator - The value used to differentiate between caches of the same class.defaultSize - The default size of the cache if it doesn't exist in the configuration.expirationTest - A function which confirms whether an expiration candidate element may actually be expired.public static <K,V> LRUCache<K,V> createLRUCache(java.lang.Class<?> clazz, java.lang.String discriminator, int defaultSize, java.util.function.Function<V,java.lang.Boolean> expirationTest, CapacityPolicy capacityPolicy)
K - The key type.V - The value type.clazz - The class for which the cache is created.discriminator - The value used to differentiate between caches of the same class.defaultSize - The default size of the cache if it doesn't exist in the configuration.expirationTest - A function which confirms whether an expiration candidate element may actually be expired.capacityPolicy - The policy to follow when capacity cannot be ensured, due to expirationTest vetoing
expiration candidates.public static <K,V> java.util.Map<K,V> createMapCache(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize)
K - The key type.V - The value type.clazz - The class for which the cache is created.discriminator - The value used to differentiate between caches of the same class.defaultSize - The default size of the cache if it doesn't exist in the configuration.private static int getCacheSize(java.lang.Class<?> clazz,
java.lang.String discriminator,
int defaultSize)
null will also be used
as a discriminator, but only if it was not originally null.clazz - The class for which the cache is created.discriminator - The value used to differentiate between caches of the same class.defaultSize - The default size of the cache if it doesn't exist in the configuration.