public class Cache<K,V>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Cache.Factory<K,V>
Factory interface for creating various cacheable objects.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<K,V> |
cache |
private Cache.Factory<K,V> |
factory |
private static java.util.logging.Logger |
LOGGER |
Constructor and Description |
---|
Cache(Cache.Factory<K,V> factory)
Constructs this cache using the specified
Factory . |
Modifier and Type | Method and Description |
---|---|
V |
get(K key)
If a value isn't associated with the specified key, a new
Callable will be created wrapping the Factory
specified via the constructor and passed to a FutureTask . |
V |
remove(K key) |
private static final java.util.logging.Logger LOGGER
private final Cache.Factory<K,V> factory
public Cache(Cache.Factory<K,V> factory)
Factory
.factory
- public V get(K key)
Callable
will be created wrapping the Factory
specified via the constructor and passed to a FutureTask
. This task
will be passed to the backing ConcurrentMap. When FutureTask.get()
is invoked, the Factory will return the new Value which will be cached
by the FutureTask
.key
- the key the value is associated withCopyright © 2002-2013 Oracle America, Inc. All Rights Reserved.