Package org.jboss.weld.util.cache
Interface ComputingCache<K,V>
public interface ComputingCache<K,V>
A simple abstraction for computing cache.
Implementations are not required to support recursive computations. A cache client must be aware that such computations may
result in livelocks, inifinite
loops and other undesired situations.
- Author:
- Martin Kouba
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all cache entries.voidforEachValue(Consumer<? super V> consumer) Performs the given action for each cached value.<T> TgetCastValue(Object key) getValueIfPresent(K key) voidinvalidate(Object key) Invalidate the entry with the given key.longsize()
-
Method Details
-
getValue
- Parameters:
key-- Returns:
- the cache value
-
getCastValue
- Parameters:
key-- Returns:
- the cache value cast to the required type
-
getValueIfPresent
- Parameters:
key-- Returns:
- the cache value if present (i.e. no computation is performed)
-
size
long size()- Returns:
- the size of the cache
-
clear
void clear()Remove all cache entries. -
invalidate
Invalidate the entry with the given key. No-op if no such entry exists.- Parameters:
key-
-
getAllPresentValues
- Returns:
- an immutable map of entries
-
forEachValue
Performs the given action for each cached value.- Parameters:
consumer- the given action
-