java.lang.Object
org.apache.jena.atlas.lib.cache.CacheSimple<K,V>
- All Implemented Interfaces:
Cache<K,V>
A simple fixed size cache that uses the hash code to address a slot.
The clash policy is to overwrite.
The cache has very low overhead - there is no object creation during lookup or insert.
This cache is not thread safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(K key) Does the cache contain the key?Get from cache; if not present, call theFunctionto fill the cache slot.getIfPresent(K key) Get from cache - or return null.Get from cache; if not present, call theCallableto try to fill the cache.static <K,V> V getOrFillNoSync(Cache<K, V> cache, K key, Callable<V> callable) Implementation of getOrFill based on Cache.get and Cache.put This function is not thread safe.static <K,V> V getOrFillNoSync(Cache<K, V> cache, K key, Function<K, V> function) Implementation of getOrFill based on Cache.get and Cache.put This function is not thread safe.booleanisEmpty()keys()Iterate over all keys.voidInsert into the cachevoidRemove from cache - return true if key referenced an entrylongsize()Current size of cache
-
Constructor Details
-
CacheSimple
public CacheSimple(int size) -
CacheSimple
-
-
Method Details
-
clear
public void clear() -
containsKey
Description copied from interface:CacheDoes the cache contain the key?- Specified by:
containsKeyin interfaceCache<K,V>
-
getIfPresent
Description copied from interface:CacheGet from cache - or return null.- Specified by:
getIfPresentin interfaceCache<K,V>
-
getOrFill
Description copied from interface:CacheGet from cache; if not present, call theCallableto try to fill the cache. This operation should be atomic. -
get
Description copied from interface:CacheGet from cache; if not present, call theFunctionto fill the cache slot. This operation should be atomic. -
getOrFillNoSync
Implementation of getOrFill based on Cache.get and Cache.put This function is not thread safe. -
getOrFillNoSync
Implementation of getOrFill based on Cache.get and Cache.put This function is not thread safe. -
put
Description copied from interface:CacheInsert into the cache -
remove
Description copied from interface:CacheRemove from cache - return true if key referenced an entry -
size
public long size()Description copied from interface:CacheCurrent size of cache -
keys
Description copied from interface:CacheIterate over all keys. Iterating over the keys requires the caller be thread-safe. -
isEmpty
public boolean isEmpty()
-