LoadingCache

class LoadingCache[K, V](val underlying: LoadingCache[K, V]) extends Cache[K, V]
Companion:
object
class Cache[K, V]
class Object
trait Matchable
class Any

Value members

Concrete methods

def get(key: K): V

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.

If another call to this method is currently loading the value for key, this thread simply waits for that thread to finish and returns its loaded value. Note that multiple threads can concurrently load values for distinct keys.

Value parameters:
key

key with which the specified value is to be associated

Returns:

the current (existing or computed) value associated with the specified key

Throws:
java.lang.IllegalArgumentException

if the computation detectably attempts a recursive update to this cache that would otherwise never complete

java.lang.RuntimeException

or Error if the CacheLoader does so, in which case the mapping is left unestablished

java.util.concurrent.CompletionException

if a checked exception was thrown while loading the value

def getAll(keys: Iterable[K]): Map[K, V]

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.

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.

Value parameters:
keys

the keys whose associated values are to be returned

Returns:

the mapping of keys to values for the specified keys in this cache

Throws:
java.lang.RuntimeException

or Error if the loader does so

java.util.concurrent.CompletionException

if a checked exception was thrown while loading the value

def refresh(key: K): Future[V]

Loads a new value for the key, asynchronously. While the new value is loading the previous value (if any) will continue to be returned by get(key) unless it is evicted.

Loads a new value for the key, asynchronously. While the new value is loading the previous value (if any) will continue to be returned by get(key) unless it is evicted.

Value parameters:
key

key with which a value may be associated

override def toString: String
Definition Classes
Cache -> Any

Inherited methods

def asMap(): Map[K, V]

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 a view of the entries stored in this cache as a thread-safe map. Modifications made to the map directly affect the cache.

Returns:

a thread-safe view of this cache

Inherited from:
Cache
def cleanUp(): Unit

Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.

Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.

Inherited from:
Cache

Returns the approximate number of entries in this cache.

Returns the approximate number of entries in this cache.

Returns:

the estimated number of mappings

Inherited from:
Cache
def get(key: K, mappingFunction: K => V): V

Returns the value associated with key in this cache, obtaining that value from mappingFunction if necessary. This method provides a simple substitute for the conventional "if cached, return; otherwise create, cache and return" pattern.

Returns the value associated with key in this cache, obtaining that value from mappingFunction if necessary. This method provides a simple substitute for the conventional "if cached, return; otherwise create, cache and return" pattern.

Value parameters:
key

key with which the specified value is to be associated

mappingFunction

the function to compute a value

Returns:

the current (existing or computed) value associated with the specified key

Throws:
java.lang.IllegalStateException

if the computation detectably attempts a recursive update to this cache that would otherwise never complete

java.lang.RuntimeException

or Error if the mappingFunction does so, in which case the mapping is left unestablished

Inherited from:
Cache
def getAll(keys: Iterable[K], mappingFunction: Iterable[K] => Map[K, V]): Map[K, V]

Returns the future of 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.

Returns the future of 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.

A single request to the mappingFunction is performed for all keys which are not already present in the cache.

Value parameters:
keys

the keys whose associated values are to be returned

mappingFunction

the function to compute the values

Returns:

an unmodifiable mapping of keys to values for the specified keys in this cache

Throws:
java.lang.RuntimeException

or Error if the mappingFunction does so, in which case the mapping is left unestablished

Inherited from:
Cache
def getAllPresent(keys: Iterable[K]): Map[K, V]

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 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.

Value parameters:
keys

the keys whose associated values are to be returned

Returns:

the mapping of keys to values for the specified keys found in this cache

Inherited from:
Cache
def getIfPresent(key: K): Option[V]

Returns 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, or None if there is no cached value for key.

Value parameters:
key

key whose associated value is to be returned

Returns:

an option value containing the value to which the specified key is mapped, or None if this map contains no mapping for the key

Inherited from:
Cache
def invalidate(key: K): Unit

Discards any cached value for key key.

Discards any cached value for key key.

Value parameters:
key

key whose mapping is to be removed from the cache

Inherited from:
Cache

Discards all entries in the cache.

Discards all entries in the cache.

Inherited from:
Cache
def invalidateAll(keys: Iterable[K]): Unit

Discards any cached values for keys keys.

Discards any cached values for keys keys.

Value parameters:
keys

the keys whose associated values are to be removed

Inherited from:
Cache
def policy(): Policy[K, V]

Returns access to inspect and perform low-level operations on this cache based on its runtime characteristics. These operations are optional and dependent on how the cache was constructed and what abilities the implementation exposes.

Returns access to inspect and perform low-level operations on this cache based on its runtime characteristics. These operations are optional and dependent on how the cache was constructed and what abilities the implementation exposes.

Returns:

access to inspect and perform advanced operations based on the cache's characteristics

Inherited from:
Cache
def put(key: K, value: V): Unit

Associates value with key in this cache. If the cache previously contained a value associated with key, the old value is replaced by value.

Associates value with key in this cache. If the cache previously contained a value associated with key, the old value is replaced by value.

Value parameters:
key

key with which the specified value is to be associated

value

value to be associated with the specified key

Inherited from:
Cache
def putAll(map: Map[K, V]): Unit

Copies all of the mappings from the specified map to the cache.

Copies all of the mappings from the specified map to the cache.

Value parameters:
map

mappings to be stored in this cache

Inherited from:
Cache

Returns a current snapshot of this cache's cumulative statistics. All statistics are initialized to zero, and are monotonically increasing over the lifetime of the cache.

Returns a current snapshot of this cache's cumulative statistics. All statistics are initialized to zero, and are monotonically increasing over the lifetime of the cache.

Returns:

the current snapshot of the statistics of this cache

Inherited from:
Cache

Concrete fields

override val underlying: LoadingCache[K, V]