Class BoundedCache<K,V>
- java.lang.Object
-
- software.amazon.awssdk.utils.cache.bounded.BoundedCache<K,V>
-
@ThreadSafe public final class BoundedCache<K,V> extends Object
A thread-safe cache implementation that returns the value for a specified key, retrieving it by either getting the stored value from the cache or using a supplied function to calculate that value and add it to the cache.When the cache is full, batch eviction of unspecified values will be performed, with a default evictionBatchSize of 10.
The user can configure the maximum size of the cache, which is set to a default of 150.
Keys must not be null, otherwise an error will be thrown. Null values are not cached.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBoundedCache.Builder<K,V>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
BoundedCache.Builder<K,V>builder(Function<K,V> mappingFunction)booleancontainsKey(K key)Vget(K key)Get a value based on the key.intsize()
-
-
-
Method Detail
-
get
public V get(K key)
Get a value based on the key. The key must not be null, otherwise an error is thrown. If the value exists in the cache, it's returned. Otherwise, the value is calculated based on the supplied functionbuilder(Function).
-
size
public int size()
-
containsKey
public boolean containsKey(K key)
-
builder
public static <K,V> BoundedCache.Builder<K,V> builder(Function<K,V> mappingFunction)
-
-