|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onemind.commons.java.datastructure.LookupCache
public abstract class LookupCache
A lookup cache implements simple lookup caching algorithm for looking up things. The derived class simply implement the produce(Object key) method which is assumed an expensive operation and the results will be cached by the lookup cache implementation. There's no public method on lookup cache, the developer should provide application specific lookup interface.
Field Summary | |
---|---|
private java.util.Map |
_cache
the hit cache * |
private boolean |
_doNegCache
indicate whether to do negative caching * |
private static java.util.logging.Logger |
_logger
the logger * |
private java.util.Set |
_negCache
the negative cache * |
Constructor Summary | |
---|---|
LookupCache()
|
|
LookupCache(boolean doNegCache)
|
Method Summary | |
---|---|
protected void |
clearNegCache()
Clear all the negative cache |
protected boolean |
isInCache(java.lang.Object o)
Test if the key is in cache |
protected boolean |
isInNegCache(java.lang.Object o)
Get whether the object is in negative cache |
protected java.lang.Object |
lookup(java.lang.Object key)
The main lookup method. |
protected abstract java.lang.Object |
produce(java.lang.Object key)
Produce the object given the key. |
protected void |
setDoNegativeCache(boolean b)
Turn on/off the negative cache |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.util.logging.Logger _logger
private java.util.Map _cache
private java.util.Set _negCache
private boolean _doNegCache
Constructor Detail |
---|
public LookupCache()
public LookupCache(boolean doNegCache)
doNegCache
- whether to do negative cachingMethod Detail |
---|
protected final java.lang.Object lookup(java.lang.Object key)
key
- the key
protected abstract java.lang.Object produce(java.lang.Object key)
key
- the key
protected void setDoNegativeCache(boolean b)
b
- true to turn on the neg cacheprotected boolean isInNegCache(java.lang.Object o)
o
- the object
protected boolean isInCache(java.lang.Object o)
o
- the object
protected void clearNegCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |