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 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 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