Package com.clickhouse.client
Interface ClickHouseCache<K,V>
-
- All Known Implementing Classes:
CaffeineCache,JdkLruCache
public interface ClickHouseCache<K,V>Wrapper interface depicts essential methods required by a client-side cache.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CACHE_SIZEDefault cache size.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <K,V>
ClickHouseCache<K,V>create(int capacity, long expireSeconds, Function<K,V> loadFunc)Creates a cache with specific capacity and load function.Vget(K key)Gets value from cache if it exists.<T> Tunwrap(Class<T> clazz)Gets inner cache object to gain more access.
-
-
-
Field Detail
-
DEFAULT_CACHE_SIZE
static final int DEFAULT_CACHE_SIZE
Default cache size.- See Also:
- Constant Field Values
-
-
Method Detail
-
create
static <K,V> ClickHouseCache<K,V> create(int capacity, long expireSeconds, Function<K,V> loadFunc)
Creates a cache with specific capacity and load function.- Type Parameters:
K- type of keyV- type of value- Parameters:
capacity- capacity of the cache, zero or negative number will be treated asDEFAULT_CACHE_SIZEexpireSeconds- seconds to expire after accessloadFunc- non-null load function- Returns:
- cache
-
get
V get(K key)
Gets value from cache if it exists.- Parameters:
key- key, in genernal should NOT be null- Returns:
- non-null value in general
-
unwrap
<T> T unwrap(Class<T> clazz)
Gets inner cache object to gain more access.- Type Parameters:
T- type of the cache- Parameters:
clazz- non-null class of the cache- Returns:
- inner cache object
- Throws:
NullPointerException- whenclazzis null
-
-