public interface LoadingCache<K,V> extends Closeable
get(Object, Callable) and stored in the cache until either evicted or manually invalidated.
 
Implementations of this interface are expected to be thread-safe, and can be safely accessed by multiple concurrent threads. This interface borrows ideas (and in some cases methods and javadoc) from Guava and JCache cache interface. Thanks Guava and JSR ! We elected to make this as close as possible to JSR API like that users can build bridges between all the existing implementations of JSR.
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Clean the used resources of the cache. 
 | 
V | 
get(K key,
   Callable<? extends V> valueLoader)
Returns the value associated with  
key in this cache, obtaining that value from
 valueLoader if necessary. | 
Map<K,V> | 
getAllPresent(Iterable<K> keys)
Returns a map of the values associated with  
keys in this cache. | 
V | 
getIfPresent(K key)  | 
LookupCacheStats | 
getStats()  | 
void | 
invalidate(K key)
Discards any cached value for key  
key. | 
void | 
invalidateAll()
Clears the contents of the cache. 
 | 
void | 
invalidateAll(Iterable<K> keys)
Discards any cached values for keys  
keys. | 
boolean | 
isClosed()  | 
void | 
putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to the cache. 
 | 
@Nullable V getIfPresent(K key)
key - must not be null
 Returns the value associated with key in this cache, or null if there is no
 cached value for key.
 a cache miss should be counted if the key is missing.Map<K,V> getAllPresent(Iterable<K> keys)
keys in this cache. The returned map will
 only contain entries which are already present in the cache.V get(K key, Callable<? extends V> valueLoader) throws ExecutionException
key in this cache, obtaining that value from
 valueLoader if necessary. No observable state associated with this cache is modified
 until loading completes.
 Warning: as with CacheLoader.load(K), valueLoader must not return
 null; it may either return a non-null value or throw an exception.
ExecutionException - if a checked exception was thrown while loading the valuecom.google.common.util.concurrent.UncheckedExecutionException - if an unchecked exception was thrown while loading the
     valuecom.google.common.util.concurrent.ExecutionError - if an error was thrown while loading the valuevoid putAll(Map<? extends K,? extends V> m)
IllegalStateException - if the cache is isClosed()void invalidate(K key)
key. Eviction can be lazy or eager.IllegalStateException - if the cache is isClosed()void invalidateAll(Iterable<K> keys)
keys. Eviction can be lazy or eager.IllegalStateException - if the cache is isClosed()void invalidateAll()
IllegalStateException - if the cache is isClosed()LookupCacheStats getStats()
IllegalStateException - if the cache is isClosed()boolean isClosed()
void close()
close in interface AutoCloseableclose in interface CloseableCopyright © 2011–2018. All rights reserved.