Class CaffeineCache<K,V>

java.lang.Object
org.incendo.cloud.processors.cache.CaffeineCache<K,V>
Type Parameters:
K - key type
V - value type
All Implemented Interfaces:
CloudCache<K,V>

@API(status=STABLE, since="1.0.0") public final class CaffeineCache<K,V> extends Object implements CloudCache<K,V>
An implementation of CloudCache backed by a Caffeine Cache.
Since:
1.0.0
  • Method Details

    • of

      public static <K, V> @NonNull CloudCache<K,V> of(@NonNull com.github.benmanes.caffeine.cache.Cache<K,V> cache)
      Creates a new CaffeineCache backed by the given Guava cache.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      cache - backing cache
      Returns:
      the created cache instance
    • delete

      public void delete(@NonNull K key)
      Description copied from interface: CloudCache
      Deletes the entry identified by the given key.
      Specified by:
      delete in interface CloudCache<K,V>
      Parameters:
      key - the key
    • put

      public void put(@NonNull K key, @NonNull V value)
      Description copied from interface: CloudCache
      Stores the given value identified by the given key.
      Specified by:
      put in interface CloudCache<K,V>
      Parameters:
      key - the key
      value - the value
    • getIfPresent

      public @Nullable V getIfPresent(@NonNull K key)
      Description copied from interface: CloudCache
      Returns the value identified by the given key, if it exists.
      Specified by:
      getIfPresent in interface CloudCache<K,V>
      Parameters:
      key - the key
      Returns:
      the value, or null