Class Cache<K,​V>


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

      Constructors 
      Constructor Description
      Cache​(long timeout)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      Cache<K,​V>
      create​(long timeout)  
      static java.lang.Object get​(Cache cache, java.lang.Object key)  
      static java.lang.Object getAsync​(Cache cache, java.lang.Object key)
      Works well in conjunktion with setIfUndefined which has an async init function.
      java.util.Map<K,​io.keikai.doc.collab.lib0.Cache.Entry<K,​V>> getMap()  
      NodeList<io.keikai.doc.collab.lib0.Cache.Entry<K,​V>> getQueue()  
      long getTimeout()  
      static void refreshTimeout​(Cache cache, java.lang.Object key)  
      static java.lang.Object remove​(Cache cache, java.lang.Object key)  
      static void set​(Cache cache, java.lang.Object key, java.lang.Object value)  
      static java.util.concurrent.CompletableFuture<?> setIfUndefined​(Cache cache, java.lang.Object key, java.util.function.Supplier<java.util.concurrent.CompletableFuture<?>> init)  
      static java.util.concurrent.CompletableFuture<?> setIfUndefined​(Cache cache, java.lang.Object key, java.util.function.Supplier<java.util.concurrent.CompletableFuture<?>> init, boolean removeNull)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Cache

        public Cache​(long timeout)
    • Method Detail

      • getTimeout

        public long getTimeout()
      • getQueue

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

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

        public static void set​(Cache cache,
                               java.lang.Object key,
                               java.lang.Object value)
      • get

        public static java.lang.Object get​(Cache cache,
                                           java.lang.Object key)
      • refreshTimeout

        public static void refreshTimeout​(Cache cache,
                                          java.lang.Object key)
      • getAsync

        public static java.lang.Object getAsync​(Cache cache,
                                                java.lang.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 java.lang.Object remove​(Cache cache,
                                              java.lang.Object key)
      • setIfUndefined

        public static java.util.concurrent.CompletableFuture<?> setIfUndefined​(Cache cache,
                                                                               java.lang.Object key,
                                                                               java.util.function.Supplier<java.util.concurrent.CompletableFuture<?>> init)
      • setIfUndefined

        public static java.util.concurrent.CompletableFuture<?> setIfUndefined​(Cache cache,
                                                                               java.lang.Object key,
                                                                               java.util.function.Supplier<java.util.concurrent.CompletableFuture<?>> init,
                                                                               boolean removeNull)
      • create

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