Class SimpleCache<K,V>

java.lang.Object
org.incendo.cloud.processors.cache.SimpleCache<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 SimpleCache<K,V> extends Object implements CloudCache<K,V>
Implementation of CloudCache backed by a WeakHashMap. It is not recommended to use this implementation, and it should only be used if CaffeineCache or GuavaCache may not be used.

This will not enforce any size constraints.

Since:
1.0.0
  • Constructor Details

    • SimpleCache

      public SimpleCache()
  • Method Details

    • of

      public static <K, V> @NonNull CloudCache<K,V> of()
      Creates a new SimpleCache instance.
      Type Parameters:
      K - key type
      V - value type
      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
    • popIfPresent

      public @Nullable V popIfPresent(@NonNull K key)
      Description copied from interface: CloudCache
      Deletes the value identified by the given key and returns the value.
      Specified by:
      popIfPresent in interface CloudCache<K,V>
      Parameters:
      key - the key
      Returns:
      the value, or null