public abstract class AbstractHashbelt extends AbstractBaseCache
A hashbelt has six important values which get set at initialization:
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CAPACITY
Default capacity of cache.
|
static Class<? extends Container> |
DEFAULT_CONTAINER_CLASS
Default container class.
|
static int |
DEFAULT_CONTAINERS
Default number of containers for cache.
|
static int |
DEFAULT_MONITOR
Default monitor interval of cache in minutes.
|
static Class<? extends AbstractReaper> |
DEFAULT_REAPER_CLASS
Default reaper class.
|
static int |
DEFAULT_TTL
Default ttl of cache in seconds.
|
static String |
PARAM_CAPACITY
Mapped initialization parameter
capacity . |
static String |
PARAM_CONTAINER_CLASS
Mapped initialization parameter
container-class . |
static String |
PARAM_CONTAINERS
Mapped initialization parameter
containers . |
static String |
PARAM_MONITOR
Mapped initialization parameter
monitor . |
static String |
PARAM_REAPER_CLASS
Mapped initialization parameter
reaper-class . |
static String |
PARAM_TTL
Mapped initialization parameter
ttl . |
DEFAULT_DEBUG, DEFAULT_NAME, DEFAULT_TYPE, PARAM_DEBUG, PARAM_NAME, PARAM_TYPE
Constructor and Description |
---|
AbstractHashbelt() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close()
Life-cycle method to allow custom resource cleanup for a cache implementation.
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<Object,Object>> |
entrySet() |
int |
getCapacity()
Get real capacity of this cache.
|
protected Object |
getObjectFromCache(Object key)
Get object currently associated with given key from cache.
|
int |
getTTL()
Get real ttl of this cache.
|
void |
initialize(Properties params)
Lyfe-cycle method to allow custom initialization of cache implementations.
|
boolean |
isEmpty() |
Set<Object> |
keySet() |
protected ReadWriteLock |
lock()
Get reference to the ReadWriteLock of this cache instance.
|
protected Object |
putObjectIntoCache(Object key,
Object value)
Put given value with given key in cache.
|
protected Object |
removeObjectFromCache(Object key)
Remove any available association for given key.
|
int |
size() |
Collection<Object> |
values() |
expire, expireAll, getName, invokeMethod, invokeStaticMethod
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, get, getOrDefault, hashCode, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll
public static final String PARAM_CONTAINERS
containers
.public static final String PARAM_CONTAINER_CLASS
container-class
.public static final String PARAM_REAPER_CLASS
reaper-class
.public static final String PARAM_CAPACITY
capacity
.public static final String PARAM_TTL
ttl
.public static final String PARAM_MONITOR
monitor
.public static final int DEFAULT_CONTAINERS
public static final Class<? extends Container> DEFAULT_CONTAINER_CLASS
public static final Class<? extends AbstractReaper> DEFAULT_REAPER_CLASS
public static final int DEFAULT_CAPACITY
public static final int DEFAULT_TTL
public static final int DEFAULT_MONITOR
public final void initialize(Properties params) throws CacheAcquireException
initialize
in interface Cache
initialize
in class AbstractBaseCache
params
- Parameters to initialize the cache (e.g. name, capacity).CacheAcquireException
- If cache can not be initialized.public final void close()
close
in interface Cache
close
in class AbstractBaseCache
public final int getCapacity()
public final int getTTL()
public final int size()
public final boolean isEmpty()
public final boolean containsKey(Object key)
public final boolean containsValue(Object value)
public final void clear()
public final Collection<Object> values()
protected final ReadWriteLock lock()
protected final Object getObjectFromCache(Object key)
key
- The key to return the associated object for.protected final Object putObjectIntoCache(Object key, Object value)
key
- The key to associate the given value with.value
- The value to associate with given key.null
will
be returned if no value has been associated with key.protected final Object removeObjectFromCache(Object key)
key
- The key to remove any previously associate value for.null
will
be returned if no value has been associated with key.Copyright © 2014. All rights reserved.