public class StorageCache
extends java.lang.Object
cache.enabled
- LRU cache enabledcache.bytes
- cache limit (bytes)cache.initial.capacity
- cache initial capacitycache.load.factor
- cache load factorThe cache estimates the size of the objects it contains so it consumes no more than the configured memory limit.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.Object |
NULL_VALUE |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.Object key)
Returns true if the cache contains
key . |
<K> K |
get(java.lang.Object key)
Gets the value in the cache for
key or null if not found. |
long |
getWeight()
Gets the cache current weight.
|
void |
put(java.lang.Object key,
java.lang.Object value)
Puts the
key/value pair into the cache. |
void |
setMaxWeight(long maxWeight)
Sets the max weight in the cache.
|
int |
size()
Gets the cache size.
|
public <K> K get(java.lang.Object key)
key
or null if not found.
If the value associated with key
exists but is null, returns
StorageCache.NULL_VALUE
.
K
- return typekey
- key to get value forStorageCache.NULL_VALUE
public boolean contains(java.lang.Object key)
key
.key
- key to test presence forpublic void put(java.lang.Object key, java.lang.Object value)
key/value
pair into the cache.key
- keyvalue
- valuepublic void setMaxWeight(long maxWeight)
maxWeight
- max weightpublic int size()
public long getWeight()