public interface Cache<K,V>
| Modifier and Type | Method and Description |
|---|---|
void |
evict(K key)
Evicts the entry with the given key from this cache.
|
void |
evict(K key,
V value)
Evicts the entry with the given key and value from this cache.
|
void |
evictAll()
Evicts all entries from this cache.
|
void |
forEach(BiConsumer<? super K,? super V> action)
Performs the given action for each entry in this cache until all entries have been processed or the action throws an exception.
|
Optional<V> |
get(K key)
Returns the value associated with the given key in this cache.
|
V |
getOrDefault(K key,
V defaultValue)
Returns the value associated with the given key in this cache.
|
boolean |
isEmpty()
Checks whether this cache is empty.
|
void |
put(K key,
V value)
Creates an entry with the given key and value in this cache.
|
void |
putIfAbsent(K key,
V value)
Creates an entry with the given key and value in this cache only if no entry with the same key already exists.
|
int |
size()
Returns the number of entries in this cache.
|
void evict(K key)
IllegalArgumentException - if key is nullMap.remove(Object)void evict(K key, V value)
IllegalArgumentException - if key is nullIllegalArgumentException - if value is nullMap.remove(Object, Object)void evictAll()
Map.clear()void forEach(BiConsumer<? super K,? super V> action)
IllegalArgumentException - if action is nullMap.forEach(BiConsumer)Optional<V> get(K key)
IllegalArgumentException - if key is nullMap.get(Object)V getOrDefault(K key, V defaultValue)
IllegalArgumentException - if key is nullMap.getOrDefault(Object, Object)boolean isEmpty()
Map.isEmpty()void put(K key, V value)
IllegalArgumentException - if key is nullIllegalArgumentException - if value is nullMap.put(Object, Object)void putIfAbsent(K key, V value)
IllegalArgumentException - if key is nullIllegalArgumentException - if value is nullMap.putIfAbsent(Object, Object)int size()
Map.size()