| Constructor and Description |
|---|
ConcurrentSoftCache()
Creates an unbounded cache with soft-referenced values.
|
ConcurrentSoftCache(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 and Description |
|---|---|
boolean |
equals(Object other) |
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.
|
int |
hashCode() |
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.
|
String |
toString() |
public ConcurrentSoftCache()
public ConcurrentSoftCache(Function<K,V> mappingFunction)
IllegalArgumentException - if mappingFunction is nullpublic void evict(K key)
Cacheevict in interface Cache<K,V>Map.remove(Object)public void evict(K key, V value)
Cacheevict in interface Cache<K,V>Map.remove(Object, Object)public void evictAll()
CacheevictAll in interface Cache<K,V>Map.clear()public void forEach(BiConsumer<? super K,? super V> action)
CacheforEach in interface Cache<K,V>Map.forEach(BiConsumer)public Optional<V> get(K key)
Cacheget in interface Cache<K,V>Map.get(Object)public V getOrDefault(K key, V defaultValue)
CachegetOrDefault in interface Cache<K,V>Map.getOrDefault(Object, Object)public boolean isEmpty()
CacheisEmpty in interface Cache<K,V>Map.isEmpty()public void put(K key, V value)
Cacheput in interface Cache<K,V>Map.put(Object, Object)public void putIfAbsent(K key, V value)
CacheputIfAbsent in interface Cache<K,V>Map.putIfAbsent(Object, Object)public int size()
Cachesize in interface Cache<K,V>Map.size()