Package org.apache.beam.fn.harness
Interface Cache<K,V>
-
- All Known Implementing Classes:
Caches.ClearableCache
@ThreadSafe public interface Cache<K,V>A cache allows for the storage and retrieval of values which are associated with keys.The cache allows for concurrent access and modification to its content and automatically controls the amount of entries in the cache to stay within configured resource limits.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCache.Shrinkable<V>An interface that marks an object that can be reduced in size instead of being evicted completely.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description VcomputeIfAbsent(K key, java.util.function.Function<K,V> loadingFunction)Looks up the specified key and returns the associated value.java.lang.StringdescribeStats()Returns a string containing caching statistics.Vpeek(K key)Looks up the specified key returningnullif the value is not within the cache.voidput(K key, V value)Inserts a new value associated with the given key or updates an existing association of the same key with the new value.voidremove(K key)Removes the mapping for a key from the cache if it is present.
-
-
-
Method Detail
-
peek
@Nullable V peek(K key)
Looks up the specified key returningnullif the value is not within the cache.
-
computeIfAbsent
V computeIfAbsent(K key, java.util.function.Function<K,V> loadingFunction)
Looks up the specified key and returns the associated value.If the key is not present in the cache, the specified function will be used to load and populate the cache.
-
put
void put(K key, V value)
Inserts a new value associated with the given key or updates an existing association of the same key with the new value.
-
remove
void remove(K key)
Removes the mapping for a key from the cache if it is present.
-
describeStats
java.lang.String describeStats()
Returns a string containing caching statistics.
-
-