Class CaffeinatedGuava

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

public final class CaffeinatedGuava extends Object
An adapter to expose a Caffeine cache through the Guava interfaces.
Author:
ben.manes@gmail.com (Ben Manes)
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V, K1 extends K, V1 extends V>
    @NonNull com.google.common.cache.Cache<K1,V1>
    build(@NonNull Caffeine<K,V> builder)
    Returns a Caffeine cache wrapped in a Guava Cache facade.
    static <K, V, K1 extends K, V1 extends V>
    @NonNull com.google.common.cache.LoadingCache<K1,V1>
    build(@NonNull Caffeine<K,V> builder, @NonNull CacheLoader<? super K1, V1> loader)
    Returns a Caffeine cache wrapped in a Guava LoadingCache facade.
    static <K, V, K1 extends K, V1 extends V>
    @NonNull com.google.common.cache.LoadingCache<K1,V1>
    build(@NonNull Caffeine<K,V> builder, @NonNull com.google.common.cache.CacheLoader<? super K1, V1> loader)
    Returns a Caffeine cache wrapped in a Guava LoadingCache facade.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • build

      public static <K, V, K1 extends K, V1 extends V> @NonNull com.google.common.cache.Cache<K1,V1> build(@NonNull 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> @NonNull com.google.common.cache.LoadingCache<K1,V1> build(@NonNull Caffeine<K,V> builder, @NonNull com.google.common.cache.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> @NonNull com.google.common.cache.LoadingCache<K1,V1> build(@NonNull Caffeine<K,V> builder, @NonNull 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