|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Cache<K,V>
Simple cache interface with add, remove, get, clear and size methods. If null
is passed as parameter an IllegalArgumentException is thrown.
If the cache cleans it self (for example a LIFO cache with maximum size) the
elementCleaned method is invoked. Override the default
implementation (that does nothing) if needed.
TODO: Create a pluggable, scalable, configurable, self analyzing/adaptive, statistics/reportable cache architecture. Emil will code that in four hours when he has time.
| Method Summary | |
|---|---|
void |
clear()
Removing all cached elements. |
void |
elementCleaned(V value)
|
V |
get(K key)
Returns the cached element for key. |
String |
getName()
Returns the name of the cache. |
long |
hitCount()
|
boolean |
isAdaptive()
|
int |
maxSize()
|
long |
missCount()
|
void |
put(K key,
V value)
Adds element to cache. |
void |
putAll(Map<K,V> map)
|
V |
remove(K key)
Removes the element for key from cache and returns it. |
void |
resize(int newSize)
|
void |
setAdaptiveStatus(boolean status)
|
int |
size()
Returns the cache size. |
| Method Detail |
|---|
String getName()
void put(K key,
V value)
element to cache.
key - the key for the elementelement - the element to cacheV remove(K key)
key from cache and returns it. If
the no element for key exists null is
returned.
key - the key for the element
null if element didn't
existV get(K key)
key. If the element isn't
in cache null is returned.
key - the key for the element
null if element didn't existvoid clear()
int size()
void elementCleaned(V value)
int maxSize()
void resize(int newSize)
boolean isAdaptive()
void setAdaptiveStatus(boolean status)
void putAll(Map<K,V> map)
long hitCount()
long missCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||