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.
get(Object)
| Modifier and Type | Class and Description |
|---|---|
| private class | ConcurrentLruCache.AddTask
Write operation recorded when a new entry is added to the cache. |
| private static record | |
| private static enum | |
| private static enum | |
| private static class | |
| private static class | |
| private static class | |
| private class | ConcurrentLruCache.RemovalTask
Write operation recorded when an entry is removed to the cache. |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentMap | |
| private final int | |
| private final AtomicInteger | |
| private final AtomicReference | |
| private final Lock | |
| private final ConcurrentLruCache. | |
| private final Function | |
| private final ConcurrentLruCache. | |
| private final ConcurrentLruCache. |
| Access | Constructor and Description |
|---|---|
| public | ConcurrentLruCache(int
the maximum number of entries in the cache
(0 indicates no caching, always generating a new value) capacity, Function<K, V> a function to generate a new value for a given key generator)Create a new cache instance with the given capacity and generator function. |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public void | |
| public boolean | Returns: true if the key is present, false if there was no matching keythe key to check for key)Determine whether the given key is present in this cache. |
| private void | |
| public V | Returns: the cached or newly generated valuethe key to retrieve the entry for key)Retrieve an entry from the cache, potentially triggering generation of the value. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| public boolean | Returns: true if the key was present before,
false if there was no matching keythe key to evict the entry for key)Immediately remove the given key and any associated value. |
| public int | |
| public int | sizeLimit()
Deprecated
since 6.0. in favor of
Return the maximum number of entries in the cache.
capacity() as of 6.0.
|