Interface JdbiCache<K,​V>

  • Type Parameters:
    K - A key type for the cache.
    V - A value type for the cache.
    All Known Implementing Classes:
    DefaultJdbiCache, NoopCache

    public interface JdbiCache<K,​V>
    A generic cache implementation for JDBI internal use.
    All implementations of this interface must be threadsafe!
    • Method Detail

      • get

        V get​(K key)
        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

        V getWithLoader​(K key,
                        JdbiCacheLoader<K,​V> loader)
        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 - A JdbiCacheLoader 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.