Returns the backing Guava LoadingCache
delegate instance that methods are forwarded to.
Returns the backing Guava LoadingCache
delegate instance that methods are forwarded to.
Concrete subclasses override this method to supply the instance being decorated.
Returns a map of the values associated with keys
, creating or retrieving those values
if necessary.
Returns a map of the values associated with keys
, creating or retrieving those values
if necessary. The returned map contains entries that were already cached, combined with newly
loaded entries; it will never contain null keys or values.
The method simply forwards to getAll(keys)
.
Returns the value associated with key
in this cache, first loading that value if
necessary.
Returns the value associated with key
in this cache, first loading that value if
necessary. No observable state associated with this cache is modified until loading completes.
The method simply forwards to get(key)
.
Returns a view of the entries stored in this cache as a thread-safe map.
Returns a view of the entries stored in this cache as a thread-safe map. Modifications made to the map directly affect the cache.
Performs any pending maintenance operations needed by the cache.
Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.
Returns the value associated with key
in this cache, first loading that value if
necessary.
Returns the value associated with key
in this cache, first loading that value if
necessary. No observable state associated with this cache is modified until loading completes.
If another call to #get
or #getIfPresent
is currently loading the value for
key
, simply waits for that thread to finish and returns its loaded value. Note that
multiple threads can concurrently load values for distinct keys.
Caches loaded by a CacheLoader will call CacheLoader#load
to load new values
into the cache. If another value was associated
with key
while the new value was loading then a removal notification will be sent for
the new value.
The CacheLoader should not throw exceptions. If the calculation from a CacheLoader
can fail the use of CacheLoader[K,Option[V]]
or CacheLoader[K,Try[V]]
is preferred.
If the cache loader associated with this cache is known not to throw checked
exceptions, then prefer #getUnchecked
over this method.
ExecutionError
if an error was thrown while loading the value
ExecutionException
if a checked exception was thrown while loading the value
UncheckedExecutionException
if an unchecked exception was thrown while loading the
value
Returns a map of the values associated with keys
, creating or retrieving those values
if necessary.
Returns a map of the values associated with keys
, creating or retrieving those values
if necessary. The returned map contains entries that were already cached, combined with newly
loaded entries; it will never contain null keys or values.
Caches loaded by a CacheLoader will issue a single request to
CacheLoader#loadAll
for all keys which are not already present in the cache. All
entries returned by CacheLoader#loadAll
will be stored in the cache, over-writing
any previously cached values. This method will throw an exception if
CacheLoader#loadAll
returns null
, returns a map containing null keys or values,
or fails to return an entry for each requested key.
Note that duplicate elements in keys
, as determined by ==
, will
be ignored.
ExecutionError
if an error was thrown while loading the values
ExecutionException
if a checked exception was thrown while loading the values
UncheckedExecutionException
if an unchecked exception was thrown while loading the
values
Returns a map of the values associated with keys
in this cache.
Returns a map of the values associated with keys
in this cache.
The returned map will only contain entries which are already present in the cache.
Returns an Option which is Some(value)
with the value associated with
key
in this cache, or None
if there is no cached value for key
.
Returns an Option which is Some(value)
with the value associated with
key
in this cache, or None
if there is no cached value for key
.
Returns the value associated with key
in this cache, obtaining that value from
loader
if necessary.
Returns the value associated with key
in this cache, obtaining that value from
loader
if necessary. No observable state associated with this cache is modified
until loading completes. This method provides a simple substitute for the conventional
if cached, return; otherwise create, cache and return
pattern.
Warning: as with CacheLoader#load
, loader
must not return
null
; it may either return a non-null value or throw an exception.
The recommend way would be to use a Cache[K, Option[V]]
with loader
return None
instead of throwing an exception.
This method is equivalent to Cache.get(K, Callable<? extends V>)
from
the Guava-Libraries.
ExecutionError
if an error was thrown while loading the value
ExecutionException
if a checked exception was thrown while loading the value
UncheckedExecutionException
if an unchecked exception was thrown while loading the
value
Returns the value associated with key
in this cache, first loading that value if
necessary.
Returns the value associated with key
in this cache, first loading that value if
necessary. No observable state associated with this cache is modified until loading
completes. Unlike #get
, this method does not handle checked exceptions, and thus should
only be used in situations where checked exceptions are not thrown by the cache loader.
If another call to #get
or #getUnchecked
is currently loading the value for
key
, simply waits for that thread to finish and returns its loaded value. Note that
multiple threads can concurrently load values for distinct keys.
Caches loaded by a CacheLoader will call CacheLoader#load
to load new values
into the cache. Newly loaded values are added to the cache using
Cache.asMap().putIfAbsent
after loading has completed; if another value was associated
with key
while the new value was loading then a removal notification will be sent for
the new value.
Warning: this method silently converts checked exceptions to unchecked exceptions,
and should not be used with cache loaders which throw checked exceptions. In such cases use
#get
instead.
ExecutionError
if an error was thrown while loading the value
UncheckedExecutionException
if an exception was thrown while loading the value,
regardless of whether the exception was checked or unchecked
Discards any cached value for key key
.
Discards any cached value for key key
.
Discards all entries in the cache.
Discards all entries in the cache.
Discards any cached values for keys keys
.
Discards any cached values for keys keys
.
Adds a new key/value pair to this cache.
Adds a new key/value pair to this cache. If the cache previously contained a
value associated with the key
, the old value is replaced by the value
.
Prefer getOrElseUpdate(key, loader)
when using the conventional
if cached, return; otherwise create, cache and return
pattern.
Puts all key/value pairs from the specified Traversable
to the cache.
Puts all key/value pairs from the specified Traversable
to the cache.
The effect of this call is equivalent to that of calling put(key, value)
for
each (key, value)
in the Traversable
. The behavior of this operation is undefined
if the specified map is modified while the operation is in progress.
Loads a new value for key key
, possibly asynchronously.
Loads a new value for key key
, possibly asynchronously. While the new value is loading
the previous value (if any) will continue to be returned by get(key)
unless it is
evicted. If the new value is loaded successfully it will replace the previous value in the
cache; if an exception is thrown while refreshing the previous value will remain, and the
exception will be logged (using `java.util.logging.Logger`) and swallowed.
Caches loaded by a CacheLoader will call CacheLoader#reload
if the
cache currently contains a value for key
, and CacheLoader#load
otherwise.
Loading is asynchronous only if CacheLoader#reload
was overridden with an
asynchronous implementation.
Returns without doing anything if another thread is currently loading the value for
key
. If the cache loader associated with this cache performs refresh asynchronously
then this method may return before refresh completes.
Returns the approximate number of entries in this cache.
Returns the approximate number of entries in this cache.
Returns a current snapshot of this cache's cumulative statistics.
Returns a current snapshot of this cache's cumulative statistics. All stats are initialized to zero, and are monotonically increasing over the lifetime of the cache.
An adapter that wraps a Guava-
LoadingCache
in a LoadingCache and forwards all method calls to the underlying Guava-LoadingCache
.0.7