|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
V - The type of value objects.public static interface Cache.Handler<V>
The handler returned by Cache.lock(K), to be used for unlocking and storing the
result. This handler should be used as below (note the try … catch
blocks, which are mandatory):
Value V = null;
Cache.Handler<V> handler = cache.lock(key);
try {
value = handler.peek();
if (value == null) {
value = createMyObject(key);
}
} finally {
handler.putAndUnlock(value);
}
See the Cache javadoc for a more complete example.
| utility/geotk-utility (download) | View source code for this class |
| Method Summary | |
|---|---|
V |
peek()
If the value is already in the cache, returns it. |
void |
putAndUnlock(V result)
Stores the given value in the cache and release the lock. |
| Method Detail |
|---|
V peek()
null.
This method should be invoked after the Handler creation in case a value
has been computed in an other thread.
null if none.
void putAndUnlock(V result)
throws IllegalStateException
finally block, no matter
what the result is.
result - The result to store in the cache, or null for removing
the entry from the cache. If an entry is removed, a new computation
will be attempted the next time a handler is created for the same key.
IllegalStateException - May be thrown if this method is not invoked in
the pattern described in class javadoc, or if a key collision occurs.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||