K - The type of the key.V - The type of the value.public class InMemoryCache<K,V> extends Object implements Cache<K,V>
WeakHashMap.| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(K key)
Returns
True if the cache contains a entry with the key,
or False if there is none. |
static <expectedK,expectedV> |
create()
Create a new instance for a cache in memory.
|
Optional<V> |
get(K key)
Returns the value associated with
key in this cache,
or empty if there is no cached value for key. |
boolean |
isEmpty()
Returns
True if the cache is empty, or False
if there's at least a entry stored in cache. |
void |
put(K key,
V value)
Associates value with key in this cache.
|
void |
remove(K key)
Discards any cached value for this key.
|
void |
removeAll()
Discards all entries in the cache.
|
long |
size()
Returns the number of entries in this cache.
|
public static <expectedK,expectedV> InMemoryCache<expectedK,expectedV> create()
expectedK - The expected type for the key.expectedV - The expected type for the value.InMemoryCache.public void put(K key, V value)
Cachepublic Optional<V> get(K key)
Cachekey in this cache,
or empty if there is no cached value for key.public void remove(K key)
Cachepublic void removeAll()
Cachepublic boolean contains(K key)
CacheTrue if the cache contains a entry with the key,
or False if there is none.public long size()
CacheCopyright © 2007–2023. All rights reserved.