Package org.jdbi.v3.core.cache.internal
Class DefaultJdbiCache<K,V>
- java.lang.Object
-
- org.jdbi.v3.core.cache.internal.DefaultJdbiCache<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<K,DoubleLinkedList.Node<K,V>>cacheprivate JdbiCacheLoader<K,DoubleLinkedList.Node<K,V>>cacheLoaderprivate DoubleLinkedList<K,V>expungeQueueprivate intmaxSize
-
Constructor Summary
Constructors Constructor Description DefaultJdbiCache(DefaultJdbiCacheBuilder builder, JdbiCacheLoader<K,V> cacheLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidexpunge()Vget(K key)Returns the cached value for a key.DefaultJdbiCacheStatsgetStats()Return implementation specific statistics for the cache object.VgetWithLoader(K key, JdbiCacheLoader<K,V> loader)Returns a cached value for a key.private voidrefresh(DoubleLinkedList.Node<K,V> node)private JdbiCacheLoader<K,DoubleLinkedList.Node<K,V>>wrapLoader(JdbiCacheLoader<K,V> delegate)
-
-
-
Field Detail
-
cache
private final java.util.concurrent.ConcurrentMap<K,DoubleLinkedList.Node<K,V>> cache
-
expungeQueue
private final DoubleLinkedList<K,V> expungeQueue
-
cacheLoader
private final JdbiCacheLoader<K,DoubleLinkedList.Node<K,V>> cacheLoader
-
maxSize
private final int maxSize
-
-
Constructor Detail
-
DefaultJdbiCache
DefaultJdbiCache(DefaultJdbiCacheBuilder builder, JdbiCacheLoader<K,V> cacheLoader)
-
-
Method Detail
-
get
public V get(K key)
Description copied from interface:JdbiCacheReturns the cached value for a key.
-
getWithLoader
public V getWithLoader(K key, JdbiCacheLoader<K,V> loader)
Description copied from interface:JdbiCacheReturns a cached value for a key. If no value is cached, create a new value using the provided cache loader.- Specified by:
getWithLoaderin interfaceJdbiCache<K,V>- Parameters:
key- The key value. Must not be null.loader- AJdbiCacheLoaderimplementation. May be called with the provided key value.- Returns:
- The cached value or null if no value was cached.
-
getStats
public DefaultJdbiCacheStats getStats()
Description copied from interface:JdbiCacheReturn implementation specific statistics for the cache object. This can be used to expose statistic information about the underlying implementation.
-
wrapLoader
private JdbiCacheLoader<K,DoubleLinkedList.Node<K,V>> wrapLoader(JdbiCacheLoader<K,V> delegate)
-
refresh
private void refresh(DoubleLinkedList.Node<K,V> node)
-
expunge
private void expunge()
-
-