public interface Cache<K,V>
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears current cache.
|
V |
get(K key)
Retrieves an object from the cache.
|
boolean |
isEmpty()
Returns
true if cache is empty. |
boolean |
isFull()
Returns
true if max cache capacity has been reached
only if cache is size limited. |
int |
limit()
Returns cache size or
0 if there is no size limit. |
int |
prune()
Prunes objects from cache and returns the number of removed objects.
|
void |
put(K key,
V object)
Adds an object to the cache with default timeout.
|
void |
put(K key,
V object,
long timeout)
Adds an object to the cache with specified timeout after which it becomes expired.
|
V |
remove(K key)
Removes an object from the cache and returns removed value of
null
if object was not in the cache or was expired. |
int |
size()
Returns current cache size.
|
default java.util.Map<K,V> |
snapshot() |
java.util.Map<K,V> |
snapshot(boolean peek)
Creates a snapshot from current cache values.
|
long |
timeout()
Returns default timeout or
0 if it is not set. |
int limit()
0
if there is no size limit.long timeout()
0
if it is not set.void put(K key, V object)
put(Object, Object, long)
void put(K key, V object, long timeout)
prune()
is invoked to make room for new object.
Cached value must be non-null.V get(K key)
null
if object
is not longer in cache or if it is expired.int prune()
boolean isFull()
true
if max cache capacity has been reached
only if cache is size limited.V remove(K key)
null
if object was not in the cache or was expired.void clear()
int size()
boolean isEmpty()
true
if cache is empty.java.util.Map<K,V> snapshot(boolean peek)
peek
- if set, snapshot will just peek the object and not get them (and modify last access)Copyright © 2003-present Jodd Team