Interface ClickHouseCache<K,V>


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 final int
    Default cache size.
  • Method Summary

    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.
    get(K key)
    Gets value from cache if it exists.
    <T> T
    unwrap(Class<T> clazz)
    Gets inner cache object to gain more access.
  • Field Details

    • DEFAULT_CACHE_SIZE

      static final int DEFAULT_CACHE_SIZE
      Default cache size.
      See Also:
  • Method Details

    • 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 key
      V - type of value
      Parameters:
      capacity - capacity of the cache, zero or negative number will be treated as DEFAULT_CACHE_SIZE
      expireSeconds - seconds to expire after access
      loadFunc - 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 - when clazz is null