|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jopendocument.util.cache.ICache<K,V,D>
K - key type, eg String.V - value type, eg List of SQLRow.D - source data type, eg SQLTable.public class ICache<K,V,D>
To keep results computed from some data. The results will be automatically invalidated after some period of time or when the data is modified.
| Constructor Summary | |
|---|---|
ICache()
|
|
ICache(int delay)
|
|
ICache(int delay,
int size)
|
|
ICache(int delay,
int size,
java.lang.String name)
Creates a cache with the given parameters. |
|
| Method Summary | |
|---|---|
void |
addRunning(K key)
Tell this cache that we're in process of getting the value for key, so if someone else ask have them wait. |
CacheResult<V> |
check(K key)
Check if key is in cache, in that case returns the value otherwise adds key to running and returns NOT_IN_CACHE. |
void |
clear()
|
void |
clear(K select)
|
CacheResult<V> |
get(K sel)
If sel is in cache returns its value, else if key is running block until the key
is put (or the current thread is interrupted). |
boolean |
isRunning(K sel)
|
void |
put(K sel,
V res)
Put a result which doesn't depend on variable data in this cache. |
java.util.Set<? extends CacheWatcher<K,D>> |
put(K sel,
V res,
java.util.Set<? extends D> data)
Put a result in this cache. |
void |
removeRunning(K key)
|
void |
setWatcherFactory(CacheWatcherFactory<K,D> f)
|
int |
size()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ICache()
public ICache(int delay)
public ICache(int delay,
int size)
public ICache(int delay,
int size,
java.lang.String name)
delay - the delay in seconds before a key is cleared.size - the maximum size of the cache, negative means no limit.name - name of this cache and associated thread.
java.lang.IllegalArgumentException - if size is 0.| Method Detail |
|---|
public final void setWatcherFactory(CacheWatcherFactory<K,D> f)
public final CacheResult<V> get(K sel)
sel is in cache returns its value, else if key is running block until the key
is put (or the current thread is interrupted). Otherwise the key is not in cache so return a
CacheResult of state CacheResult.State.NOT_IN_CACHE.
sel - the key we're getting the value for.
public final void addRunning(K key)
key - the key we're getting the value for.put(Object, Object, Set)public final void removeRunning(K key)
public final boolean isRunning(K sel)
public final CacheResult<V> check(K key)
NOT_IN_CACHE.
key - the key to be checked.
null.addRunning(Object)
public final void put(K sel,
V res)
sel - the key.res - the result associated with sel.
public final java.util.Set<? extends CacheWatcher<K,D>> put(K sel,
V res,
java.util.Set<? extends D> data)
sel - the key.res - the result associated with sel.data - the data from which res is computed.
public final void clear(K select)
public final void clear()
public final int size()
public final java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||