Class Cache<K,V>

java.lang.Object
io.keikai.doc.collab.lib0.Cache<K,V>

public class Cache<K,V> extends Object
An implementation of a map which has keys that expire.
  • Constructor Details

    • Cache

      public Cache(long timeout)
  • Method Details

    • getTimeout

      public long getTimeout()
    • getQueue

      public NodeList<io.keikai.doc.collab.lib0.Cache.Entry<K,V>> getQueue()
    • getMap

      public Map<K,io.keikai.doc.collab.lib0.Cache.Entry<K,V>> getMap()
    • set

      public static void set(Cache cache, Object key, Object value)
    • get

      public static Object get(Cache cache, Object key)
    • refreshTimeout

      public static void refreshTimeout(Cache cache, Object key)
    • getAsync

      public static Object getAsync(Cache cache, Object key)
      Works well in conjunktion with setIfUndefined which has an async init function. Using getAsync and setIfUndefined ensures that the init function is only called once.
      Parameters:
      cache -
      key -
      Returns:
      V | Future | undefined
    • remove

      public static Object remove(Cache cache, Object key)
    • setIfUndefined

      public static CompletableFuture<?> setIfUndefined(Cache cache, Object key, Supplier<CompletableFuture<?>> init)
    • setIfUndefined

      public static CompletableFuture<?> setIfUndefined(Cache cache, Object key, Supplier<CompletableFuture<?>> init, boolean removeNull)
    • create

      public static <K, V> Cache<K,V> create(long timeout)