Class CaffeinatedGuava

java.lang.Object
com.github.benmanes.caffeine.guava.CaffeinatedGuava

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

    • 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.
      Type Parameters:
      K - the most general key type to create caches for
      V - the most general value type to create caches for
      K1 - the key type of the cache
      V1 - the value type of the cache
      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.
      Type Parameters:
      K - the most general key type to create caches for
      V - the most general value type to create caches for
      K1 - the key type of the cache
      V1 - the value type of the cache
      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.
      Type Parameters:
      K - the most general key type to create caches for
      V - the most general value type to create caches for
      K1 - the key type of the cache
      V1 - the value type of the cache
      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.
      Type Parameters:
      K - the type of keys
      V - the type of values
      Parameters:
      loader - the cache loader used to obtain new values
      Returns:
      a cache loader exposed under the Caffeine APIs