public interface Cache<K,V>
Modifier and Type | Interface and Description |
---|---|
static interface |
Cache.CacheFilter<V>
CacheFileter is used to select values to remove during a removeAll
invocation.
|
static interface |
Cache.CacheListener<V>
Callback listener for cache events.
|
static interface |
Cache.TimeOut
A cache entry can implement this interface
to provide its timeout.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V value)
Add a new entry to the cache.
|
void |
checkIn(K key)
Marks the entry available, so it can be accessed again.
|
V |
checkOut(K key,
boolean loadIfNotFound)
Marks the entry checked-out, so this entry can not be accessed until
checked-in.
|
void |
destroy()
Destroy the cache.
|
Cache.CacheListener<V> |
getListener()
Gets the listener for cache events.
|
void |
init()
Initialize the cache.
|
V |
remove(K key)
Removes the entry from the cache.
|
void |
removeAll(Cache.CacheFilter<V> filter)
Removes all of the entries that match the specified filter.
|
void |
setListener(Cache.CacheListener<V> listener)
Sets the listener for cache events.
|
Cache.CacheListener<V> getListener()
void setListener(Cache.CacheListener<V> listener)
void add(K key, V value)
V checkOut(K key, boolean loadIfNotFound) throws java.lang.Exception
java.lang.IllegalStateException
- if the entry is already checked out.java.lang.Exception
- if an entry is loaded and the afterLoad method threw an
exceptionvoid checkIn(K key)
java.lang.IllegalStateException
- if the entry is not checked out.void removeAll(Cache.CacheFilter<V> filter)
void init()
void destroy()