public abstract class AbstractCache<T extends TaskResult> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Compiler |
compiler
Reference to the compiler associated with this cache.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCache(Compiler compiler,
int size)
Initializes the internal reference to the associated
Compiler and creates a cache with the given initial size. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Task<T> |
createTask(String key)
Creates a new task to be put into the cache, if necessary.
|
protected abstract TaskResult.ResultType |
getExecutorQueueType()
Subclasses must return the executor queue type for the particular class.
|
Future<T> |
retrieve(String key)
Returns directly the
Future associated with the key or null
if an entry does not exist. |
Future<T> |
retrieve(String key,
boolean executeInline)
Returns a
Future corresponding to the named object template;
this will add a new entry if one does not yet exist for the given key. |
T |
waitForResult(String key)
A convenience method that will retrieve (or create) the task associated
with the key, wait for a result to be ready, and process any thrown
exceptions.
|
protected final Compiler compiler
protected AbstractCache(Compiler compiler, int size)
Compiler and creates a cache with the given initial size.compiler - Compiler related to this cachesize - number of initial entriespublic Future<T> retrieve(String key, boolean executeInline)
Future corresponding to the named object template;
this will add a new entry if one does not yet exist for the given key.key - key to use for the lookup, typically an object or template
nameexecuteInline - If the client is going to wait for the task to complete, then
it can indicate that the task can be run inline.Future that references the compiled templatepublic T waitForResult(String key) throws RuntimeException, ValidationException
key - Key for the associated task, usually an object or template
nameRuntimeExceptionValidationExceptionpublic Future<T> retrieve(String key)
Future associated with the key or null
if an entry does not exist. This method will not create a task for a
non-existent entry. This method is primarily used for testing.key - Key to use for the entity lookup.Future for the named template or null if it is not
in the cacheprotected abstract Task<T> createTask(String key)
key - Key used to generate the associated task.protected abstract TaskResult.ResultType getExecutorQueueType()
Copyright © 2014 Quattor. All Rights Reserved.