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.
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
Discards any cached value for key key
.
Discards all entries in the cache.
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.
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.
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 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.
Discards any cached values for keys keys
.
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.
A semi-persistent mapping from keys to values. Cache entries are manually added using
getOrElseUpdate(key, loader)
orput(key, value)
, and are 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.
0.7 (copied from Guava-libraries)