Package org.apache.jena.atlas.lib.cache
Class Cache1<K,V>
- java.lang.Object
-
- org.apache.jena.atlas.lib.cache.Cache1<K,V>
-
-
Constructor Summary
Constructors Constructor Description Cache1()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(K key)Does the cache contain the key?VgetIfPresent(K key)Get from cache - or return null.VgetOrFill(K key, java.util.concurrent.Callable<V> callable)Get from cache, of not present, call theCallableto try to fill the cache.booleanisEmpty()java.util.Iterator<K>keys()Iterate over all keys.voidput(K key, V thing)Insert into the cachevoidremove(K key)Remove from cache - return true if key referenced an entryvoidsetDropHandler(java.util.function.BiConsumer<K,V> dropHandler)Register a callback - called when an object is dropped from the cache (optional operation)longsize()Current size of cache
-
-
-
Method Detail
-
containsKey
public boolean containsKey(K key)
Description copied from interface:CacheDoes the cache contain the key?- Specified by:
containsKeyin interfaceCache<K,V>
-
getIfPresent
public V getIfPresent(K key)
Description copied from interface:CacheGet from cache - or return null.- Specified by:
getIfPresentin interfaceCache<K,V>
-
getOrFill
public V getOrFill(K key, java.util.concurrent.Callable<V> callable)
Description copied from interface:CacheGet from cache, of not present, call theCallableto try to fill the cache. This operation should be atomic.
-
keys
public java.util.Iterator<K> keys()
Description copied from interface:CacheIterate over all keys. Iterating over the keys requires the caller be thread-safe.
-
remove
public void remove(K key)
Description copied from interface:CacheRemove from cache - return true if key referenced an entry
-
setDropHandler
public void setDropHandler(java.util.function.BiConsumer<K,V> dropHandler)
Description copied from interface:CacheRegister a callback - called when an object is dropped from the cache (optional operation)- Specified by:
setDropHandlerin interfaceCache<K,V>
-
-