Package io.keikai.doc.collab.lib0
Class Cache<K,V>
- java.lang.Object
-
- io.keikai.doc.collab.lib0.Cache<K,V>
-
public class Cache<K,V> extends java.lang.ObjectAn 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.Objectget(Cache cache, java.lang.Object key)static java.lang.ObjectgetAsync(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()longgetTimeout()static voidrefreshTimeout(Cache cache, java.lang.Object key)static java.lang.Objectremove(Cache cache, java.lang.Object key)static voidset(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)
-
-
-
Method Detail
-
getTimeout
public long getTimeout()
-
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)
-
-