Package org.apache.beam.fn.harness
Class Caches.ClearableCache<K,V>
- java.lang.Object
-
- org.apache.beam.fn.harness.Caches.ClearableCache<K,V>
-
- All Implemented Interfaces:
Cache<K,V>
- Enclosing class:
- Caches
public static class Caches.ClearableCache<K,V> extends java.lang.ObjectA cache that tracks keys that have been inserted into the cache and supports clearing them.The set of keys that are tracked are only those provided to
peek(K)andcomputeIfAbsent(K, java.util.function.Function<K, V>).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.beam.fn.harness.Cache
Cache.Shrinkable<V>
-
-
Constructor Summary
Constructors Constructor Description ClearableCache(Cache<K,V> cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all tracked keys from the cache.VcomputeIfAbsent(K key, java.util.function.Function<K,V> loadingFunction)Looks up the specified key and returns the associated value.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
-
computeIfAbsent
public V computeIfAbsent(K key, java.util.function.Function<K,V> loadingFunction)
Description copied from interface:CacheLooks 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.
- Specified by:
computeIfAbsentin interfaceCache<K,V>
-
put
public void put(K key, V value)
Description copied from interface:CacheInserts a new value associated with the given key or updates an existing association of the same key with the new value.
-
remove
public void remove(K key)
Description copied from interface:CacheRemoves the mapping for a key from the cache if it is present.
-
clear
public void clear()
Removes all tracked keys from the cache.
-
-