Package io.keikai.doc.collab.lib0
Class Cache<K,V>
java.lang.Object
io.keikai.doc.collab.lib0.Cache<K,V>
An implementation of a map which has keys that expire.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> Cache<K, V> create(long timeout) static Objectstatic ObjectWorks well in conjunktion with setIfUndefined which has an async init function.getMap()getQueue()longstatic voidrefreshTimeout(Cache cache, Object key) static Objectstatic voidstatic CompletableFuture<?>setIfUndefined(Cache cache, Object key, Supplier<CompletableFuture<?>> init) static CompletableFuture<?>setIfUndefined(Cache cache, Object key, Supplier<CompletableFuture<?>> init, boolean removeNull)
-
Constructor Details
-
Cache
public Cache(long timeout)
-
-
Method Details
-
getTimeout
public long getTimeout() -
getQueue
-
getMap
-
set
-
get
-
refreshTimeout
-
getAsync
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
-
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
-