Class CaffeinatedGuava


  • public final class CaffeinatedGuava
    extends Object
    Static utility methods pertaining to adapting between Caffeine and Guava cache interfaces.
    • Method Detail

      • build

        public static <K,​V,​K1 extends K,​V1 extends V> Cache<K1,​V1> build​(Caffeine<K,​V> builder)
        Returns a Caffeine cache wrapped in a Guava Cache facade.
        Parameters:
        builder - the configured cache builder
        Returns:
        a cache exposed under the Guava APIs
      • build

        public static <K,​V,​K1 extends K,​V1 extends V> LoadingCache<K1,​V1> build​(Caffeine<K,​V> builder,
                                                                                                        CacheLoader<? super K1,​V1> loader)
        Returns a Caffeine cache wrapped in a Guava LoadingCache facade.
        Parameters:
        builder - the configured cache builder
        loader - the cache loader used to obtain new values
        Returns:
        a cache exposed under the Guava APIs
      • build

        public static <K,​V,​K1 extends K,​V1 extends V> LoadingCache<K1,​V1> build​(Caffeine<K,​V> builder,
                                                                                                        CacheLoader<? super K1,​V1> loader)
        Returns a Caffeine cache wrapped in a Guava LoadingCache facade.
        Parameters:
        builder - the configured cache builder
        loader - the cache loader used to obtain new values
        Returns:
        a cache exposed under the Guava APIs
      • caffeinate

        public static <K,​V> CacheLoader<K,​V> caffeinate​(CacheLoader<K,​V> loader)
        Returns a Caffeine cache loader that delegates to a Guava cache loader.
        Parameters:
        loader - the cache loader used to obtain new values
        Returns:
        a cache loader exposed under the Caffeine APIs