Package org.jdbi.v3.cache.caffeine
Class CaffeineCacheBuilder
java.lang.Object
org.jdbi.v3.cache.caffeine.CaffeineCacheBuilder
- All Implemented Interfaces:
JdbiCacheBuilder
Cache builder using the caffeine caching library.
-
Constructor Summary
ConstructorDescriptionCaffeineCacheBuilder
(com.github.benmanes.caffeine.cache.Caffeine<Object, Object> caffeine) Wraps an existingCaffeine
object for Jdbi internal use. -
Method Summary
Modifier and TypeMethodDescription<K,
V> JdbiCache <K, V> build()
Creates an cache instance from the values in the builder.<K,
V> JdbiCache <K, V> buildWithLoader
(JdbiCacheLoader<K, V> cacheLoader) Creates an cache instance from the values in the builder and a supplied cache loader.static JdbiCacheBuilder
instance()
Returns a newJdbiCacheBuilder
which can be used to construct the internal caches.maxSize
(int maxSize) Sets an upper boundary to the cache size.
-
Constructor Details
-
CaffeineCacheBuilder
Wraps an existingCaffeine
object for Jdbi internal use.- Parameters:
caffeine
- ACaffeine
object.
-
-
Method Details
-
instance
Returns a newJdbiCacheBuilder
which can be used to construct the internal caches.- Returns:
- A
JdbiCacheBuilder
instance.
-
build
Description copied from interface:JdbiCacheBuilder
Creates an cache instance from the values in the builder.- Specified by:
build
in interfaceJdbiCacheBuilder
- Returns:
- A cache instance.
-
buildWithLoader
Description copied from interface:JdbiCacheBuilder
Creates an cache instance from the values in the builder and a supplied cache loader.- Specified by:
buildWithLoader
in interfaceJdbiCacheBuilder
- Parameters:
cacheLoader
- AJdbiCacheLoader
instance that is used to create a new value if no value is currently stored in the cache.
-
maxSize
Description copied from interface:JdbiCacheBuilder
Sets an upper boundary to the cache size.- Specified by:
maxSize
in interfaceJdbiCacheBuilder
- Parameters:
maxSize
- Sets the maximum size of the cache. If the value is zero or negative, the cache is unbounded.- Returns:
- The instance of the builder itself.
-