public final class CacheImpl<K,V> extends Object implements Cache<K,V>
Constructor and Description |
---|
CacheImpl(CurrentTime currentTime,
long timeoutMillis)
Construct an expire-after-write cache
|
Modifier and Type | Method and Description |
---|---|
V |
get(K key,
Callable<V> valueFetcher)
Returns a value for the key if cached; otherwise creates, caches and returns
When it creates a value for a key, only one callable for the key is executed
|
void |
invalidate(K key)
Invalidates a key from the cache
|
@Inject public CacheImpl(CurrentTime currentTime, long timeoutMillis)
currentTime
- class that returns the current time for timeout purposestimeoutMillis
- a cache entry timeout after writepublic V get(K key, Callable<V> valueFetcher) throws ExecutionException
Cache
get
in interface Cache<K,V>
key
- a keyvalueFetcher
- a value fetcherExecutionException
public void invalidate(K key)
Cache
invalidate
in interface Cache<K,V>
key
- a keyCopyright © 2015 The Apache Software Foundation. All rights reserved.