@ThreadSafe public final class LruCache<K,V> extends Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
LruCache.Builder<K,V> |
Modifier and Type | Method and Description |
---|---|
static <K,V> LruCache.Builder<K,V> |
builder(Function<K,V> supplier) |
V |
get(K key)
Get a value based on the key.
|
int |
size() |
public V get(K key)
builder(Function)
.public int size()
public static <K,V> LruCache.Builder<K,V> builder(Function<K,V> supplier)
Copyright © 2023. All rights reserved.