Class LruCache<K,V>
java.lang.Object
software.amazon.awssdk.utils.cache.lru.LruCache<K,V>
A thread-safe LRU (Least Recently Used) 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, a new value will push out the least recently used value. When the cache is queried for an already stored value (cache hit), this value is moved to the back of the queue before it's returned so that the order of most recently used to least recently used can be maintained.
The user can configure the maximum size of the cache, which is set to a default of 100.
Null values are accepted.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> LruCache.Builder <K, V> builder()
static <K,
V> LruCache.Builder <K, V> Get a value based on the key.int
size()
-
Method Details
-
get
Get a value based on the key. If the value exists in the cache, it's returned, and it's position in the cache is updated. Otherwise, the value is calculated based on the supplied functionbuilder(Function)
. -
size
public int size() -
builder
-
builder
-