U
- type parameter indicating the type of the cache keysV
- type parameter indicating the type of the data that is cachedpublic interface CacheMap<U,V>
The default implementation used by the data loader is based on a LinkedHashMap
. Note that the
implementation could also have used a regular Map
instead of this CacheMap
, but
this aligns better to the reference data loader implementation provided by Facebook
Also it doesn't require you to implement the full set of map overloads, just the required methods.
Modifier and Type | Method and Description |
---|---|
CacheMap<U,V> |
clear()
Clears all entries of the cache map
|
boolean |
containsKey(U key)
Checks whether the specified key is contained in the cach map.
|
CacheMap<U,V> |
delete(U key)
Deletes the entry with the specified key from the cache map, if it exists.
|
V |
get(U key)
Gets the specified key from the cache map.
|
CacheMap<U,V> |
set(U key,
V value)
Creates a new cache map entry with the specified key and value, or updates the value if the key already exists.
|
static <U,V> CacheMap<U,java.util.concurrent.CompletableFuture<V>> |
simpleMap()
Creates a new cache map, using the default implementation that is based on a
LinkedHashMap . |
static <U,V> CacheMap<U,java.util.concurrent.CompletableFuture<V>> simpleMap()
LinkedHashMap
.U
- type parameter indicating the type of the cache keysV
- type parameter indicating the type of the data that is cachedboolean containsKey(U key)
key
- the key to checktrue
if the cache contains the key, false
otherwiseV get(U key)
May throw an exception if the key does not exists, depending on the cache map implementation that is used,
so be sure to check containsKey(Object)
first.
key
- the key to retrievenull
if not found (depends on cache implementation)CacheMap<U,V> set(U key, V value)
key
- the key to cachevalue
- the value to cacheCacheMap<U,V> delete(U key)
key
- the key to delete