java.lang.Object
io.helidon.common.configurable.LruCache<K,V>
- Type Parameters:
K
- type of the keys of the mapV
- type of the values of the map
- All Implemented Interfaces:
RuntimeType.Api<LruCacheConfig<K,
,V>> LruCache<K,
V>
@Deprecated(forRemoval=true,
since="4.2.0")
public final class LruCache<K,V>
extends Object
implements LruCache<K,V>, RuntimeType.Api<LruCacheConfig<K,V>>
Deprecated, for removal: This API element is subject to removal in a future version.
Least recently used cache.
This cache has a capacity. When the capacity is reached, the oldest record is removed from the cache when a new one
is added.
-
Field Summary
Fields inherited from interface io.helidon.common.LruCache
DEFAULT_CAPACITY
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> LruCacheConfig.Builder <K, V> builder()
Deprecated, for removal: This API element is subject to removal in a future version.Create a new builder.int
capacity()
Deprecated, for removal: This API element is subject to removal in a future version.Capacity of this cache.void
clear()
Deprecated, for removal: This API element is subject to removal in a future version.Clear all records in the cache.computeValue
(K key, Supplier<Optional<V>> valueSupplier) Deprecated, for removal: This API element is subject to removal in a future version.Either return a cached value or compute it and cache it.static <K,
V> LruCache <K, V> create()
Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with default configuration.static <K,
V> LruCache <K, V> create
(LruCacheConfig<K, V> config) Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with custom configuration.static <K,
V> LruCache <K, V> create
(Consumer<LruCacheConfig.Builder<K, V>> consumer) Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with custom configuration.Deprecated, for removal: This API element is subject to removal in a future version.Get a value from the cache.Deprecated, for removal: This API element is subject to removal in a future version.The prototype as it was received when creating this runtime object instance.Deprecated, for removal: This API element is subject to removal in a future version.Put a value to the cache.Deprecated, for removal: This API element is subject to removal in a future version.Remove a value from the cache.int
size()
Deprecated, for removal: This API element is subject to removal in a future version.Current size of the map.
-
Method Details
-
builder
Deprecated, for removal: This API element is subject to removal in a future version.Create a new builder.- Type Parameters:
K
- key typeV
- value type- Returns:
- a new fluent API builder instance
-
create
Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with default configuration.- Type Parameters:
K
- key typeV
- value type- Returns:
- a new cache instance
- See Also:
-
create
Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with custom configuration.- Type Parameters:
K
- key typeV
- value type- Parameters:
config
- configuration of LRU cache- Returns:
- a new cache instance
-
create
Deprecated, for removal: This API element is subject to removal in a future version.Create an instance with custom configuration.- Type Parameters:
K
- key typeV
- value type- Parameters:
consumer
- of custom configuration builder- Returns:
- a new cache instance
-
prototype
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:RuntimeType.Api
The prototype as it was received when creating this runtime object instance.- Specified by:
prototype
in interfaceRuntimeType.Api<K>
- Returns:
- prototype object used to create this instance
-
get
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Get a value from the cache. -
remove
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Remove a value from the cache. -
put
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Put a value to the cache. -
computeValue
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Either return a cached value or compute it and cache it. In case this method is called in parallel for the same key, the value actually present in the map may be from any of the calls. This method always returns either the existing value from the map, or the value provided by the supplier. It never returns a result from another thread's supplier.- Specified by:
computeValue
in interfaceLruCache<K,
V> - Parameters:
key
- key to check/insert value forvalueSupplier
- supplier called if the value is not yet cached, or is invalid- Returns:
- current value from the cache, or computed value from the supplier
-
size
public int size()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Current size of the map. -
capacity
public int capacity()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Capacity of this cache. -
clear
public void clear()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LruCache
Clear all records in the cache.
-
LruCache
, we are removing this from the configurable module, as cache has only a single option, and we need it from modules that do not use configuration