|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.ontopia.utils.CachedIndex<K,E>
public class CachedIndex<K,E>
INTERNAL: A LookupIndexIF which uses another, slower, LookupIndexIF as a fallback and caches the values attached to the most commonly requested keys using an LRU strategy. There is a maximum number of keys that can be stored in the index and the index will automatically prune the less-used keys to avoid the index growing above this maximum size.
Nested Class Summary | |
---|---|
class |
CachedIndex.Entry<A,B>
|
Constructor Summary | |
---|---|
CachedIndex(LookupIndexIF<K,E> fallback)
Creates an index with the given fallback and default settings. |
|
CachedIndex(LookupIndexIF<K,E> fallback,
boolean nulls)
Creates an index with the given fallback, default settings and the specified nulls setting. |
|
CachedIndex(LookupIndexIF<K,E> fallback,
int max,
int size,
boolean nulls)
Creates an index with the given fallback and settings. |
Method Summary | |
---|---|
E |
get(K key)
|
int |
getKeyNumber()
|
protected void |
prune()
Removes some of the keys in the cache, keeping only the most frequently requested keys. |
E |
put(K key,
E value)
|
E |
remove(K key)
|
void |
writeReport()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachedIndex(LookupIndexIF<K,E> fallback)
public CachedIndex(LookupIndexIF<K,E> fallback, boolean nulls)
public CachedIndex(LookupIndexIF<K,E> fallback, int max, int size, boolean nulls)
fallback
- The index to ask if the value is not found in the cache.max
- The max number of keys to store in the cache (default: 10000).size
- The initial size of the cache.nulls
- Store null values retrieved from fallback.Method Detail |
---|
public E get(K key)
get
in interface LookupIndexIF<K,E>
public E put(K key, E value)
put
in interface LookupIndexIF<K,E>
public E remove(K key)
remove
in interface LookupIndexIF<K,E>
public int getKeyNumber()
public void writeReport()
protected void prune()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |