| Constructor | Description |
|---|---|
SoftCache() |
Creates an unbounded cache with soft-referenced values.
|
SoftCache(java.util.function.Function<K,V> mappingFunction) |
Creates an unbounded cache with soft-referenced values that uses the given mapping function to create values from keys.
|
| Modifier and Type | Method | 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(java.util.function.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.
|
java.util.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.
|
java.lang.String |
toString() |
public SoftCache()
public void evict(K key)
Cachepublic void evict(K key, V value)
Cachepublic void evictAll()
Cachepublic void forEach(java.util.function.BiConsumer<? super K,? super V> action)
Cachepublic java.util.Optional<V> get(K key)
Cachepublic V getOrDefault(K key, V defaultValue)
CachegetOrDefault in interface Cache<K,V>Map.getOrDefault(Object, Object)public boolean isEmpty()
Cachepublic void put(K key, V value)
Cachepublic void putIfAbsent(K key, V value)
CacheputIfAbsent in interface Cache<K,V>Map.putIfAbsent(Object, Object)public int size()
Cachepublic java.lang.String toString()
toString in class java.lang.Object