Package org.apache.jena.atlas.lib.cache
Class CacheWrapper<Key,T>
- java.lang.Object
-
- org.apache.jena.atlas.lib.cache.CacheWrapper<Key,T>
-
-
Constructor Summary
Constructors Constructor Description CacheWrapper(Cache<Key,T> cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Key key)Does the cache contain the key?TgetIfPresent(Key key)Get from cache - or return null.TgetOrFill(Key key, java.util.concurrent.Callable<T> callable)Get from cache, of not present, call theCallableto try to fill the cache.booleanisEmpty()java.util.Iterator<Key>keys()Iterate over all keys.voidput(Key key, T thing)Insert into the cachevoidremove(Key key)Remove from cache - return true if key referenced an entryvoidsetDropHandler(java.util.function.BiConsumer<Key,T> 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(Key key)
Description copied from interface:CacheDoes the cache contain the key?- Specified by:
containsKeyin interfaceCache<Key,T>
-
getIfPresent
public T getIfPresent(Key key)
Description copied from interface:CacheGet from cache - or return null.- Specified by:
getIfPresentin interfaceCache<Key,T>
-
getOrFill
public T getOrFill(Key key, java.util.concurrent.Callable<T> 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<Key> keys()
Description copied from interface:CacheIterate over all keys. Iterating over the keys requires the caller be thread-safe.
-
put
public void put(Key key, T thing)
Description copied from interface:CacheInsert into the cache
-
remove
public void remove(Key key)
Description copied from interface:CacheRemove from cache - return true if key referenced an entry
-
setDropHandler
public void setDropHandler(java.util.function.BiConsumer<Key,T> dropHandler)
Description copied from interface:CacheRegister a callback - called when an object is dropped from the cache (optional operation)- Specified by:
setDropHandlerin interfaceCache<Key,T>
-
-