Class ConcurrentLruCache<K,V> 
java.lang.Object
io.github.kaktushose.proteus.internal.ConcurrentLruCache<K,V> 
- Type Parameters:
- K- the source of the key used for cache retrieval
- V- the source of the cached values, does not allow null values
Simple LRU (Least Recently Used) cache, bounded by a specified cache capacity.
This is a simplified, opinionated implementation of an LRU cache for internal use in Spring Framework. It is inspired from ConcurrentLinkedHashMap.
Read and write operations are internally recorded in dedicated buffers, then drained at chosen times to avoid contention.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConcurrentLruCache(int capacity, @NotNull Function<@NotNull K, @NotNull V> generator) Create a new cache instance with the given capacity and generator function.
- 
Method SummaryModifier and TypeMethodDescriptionintcapacity()Return the maximum number of entries in the cache.voidclear()Immediately remove all entries from this cache.booleanDetermine whether the given key is present in this cache.Retrieve an entry from the cache, potentially triggering generation of the value.booleanImmediately remove the given key and any associated value.
- 
Constructor Details- 
ConcurrentLruCachepublic ConcurrentLruCache(int capacity, @NotNull @NotNull Function<@NotNull K, @NotNull V> generator) Create a new cache instance with the given capacity and generator function.- Parameters:
- capacity- the maximum number of entries in the cache (0 indicates no caching, always generating a new value)
- generator- a function to generate a new value for a given key
 
 
- 
- 
Method Details- 
get
- 
capacitypublic int capacity()Return the maximum number of entries in the cache.
- 
clearpublic void clear()Immediately remove all entries from this cache.
- 
containsDetermine whether the given key is present in this cache.- Parameters:
- key- the key to check for
- Returns:
- trueif the key is present,- falseif there was no matching key
 
- 
removeImmediately remove the given key and any associated value.- Parameters:
- key- the key to evict the entry for
- Returns:
- trueif the key was present before,- falseif there was no matching key
 
 
-