Package org.jdbi.v3.core.cache
Interface JdbiCache<K,V>
- Type Parameters:
K
- A key type for the cache.V
- A value type for the cache.
- All Known Implementing Classes:
CaffeineCache
,CaffeineLoadingCache
,NoopCache
public interface JdbiCache<K,V>
A generic cache implementation for JDBI internal use.
All implementations of this interface must be threadsafe!
All implementations of this interface must be threadsafe!
-
Method Summary
Modifier and TypeMethodDescriptionReturns the cached value for a key.<T> T
getStats()
Return implementation specific statistics for the cache object.getWithLoader
(K key, JdbiCacheLoader<K, V> loader) Returns a cached value for a key.
-
Method Details
-
get
Returns the cached value for a key.- Parameters:
key
- The key value. Must not be null.- Returns:
- The cached value or null if no value was cached.
-
getWithLoader
Returns a cached value for a key. If no value is cached, create a new value using the provided cache loader.- Parameters:
key
- The key value. Must not be null.loader
- AJdbiCacheLoader
implementation. May be called with the provided key value.- Returns:
- The cached value or null if no value was cached.
-
getStats
<T> T getStats()Return implementation specific statistics for the cache object. This can be used to expose statistic information about the underlying implementation.- Returns:
- An implementation specific object.
-