To reduce contention, entry allocation and eviction execute in a sampling fashion (entry hits modulo N). Eviction follows an LRU approach (oldest sampled entries are removed first) when the cache is out of capacity.
This cache can also be configured to run in FIFO mode, rather than LRU.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentDirectDeque | |
| private final ConcurrentMap | |
| private final boolean | |
| private final int | maxAge
How long an item can stay in the cache in milliseconds |
| private final int | maxEntries
Max active entries that are present in the cache. |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void | |
| public void | |
| public V | |
| public V |
| accessQueue | back to summary |
|---|---|
| private final ConcurrentDirectDeque<LRUCache. | |
| cache | back to summary |
|---|---|
| private final ConcurrentMap<K, LRUCache. | |
| fifo | back to summary |
|---|---|
| private final boolean fifo | |
| maxAge | back to summary |
|---|---|
| private final int maxAge How long an item can stay in the cache in milliseconds | |
| maxEntries | back to summary |
|---|---|
| private final int maxEntries Max active entries that are present in the cache. | |
| SAMPLE_INTERVAL | back to summary |
|---|---|
| private static final int SAMPLE_INTERVAL | |
| LRUCache | back to summary |
|---|---|
| public LRUCache(int maxEntries, final int maxAge) | |
| LRUCache | back to summary |
|---|---|
| public LRUCache(int maxEntries, final int maxAge, boolean fifo) | |
| add | back to summary |
|---|---|
| public void add(K key, V newValue) | |
| bumpAccess | back to summary |
|---|---|
| private void bumpAccess(LRUCache. | |
| clear | back to summary |
|---|---|
| public void clear() | |
| get | back to summary |
|---|---|
| public V get(K key) | |
| remove | back to summary |
|---|---|
| public V remove(K key) | |
| Modifier and Type | Field and Description |
|---|---|
| private volatile Object | |
| private static final Object | |
| private final long | |
| private volatile int | |
| private static final AtomicIntegerFieldUpdater | |
| private final K | |
| private static final AtomicReferenceFieldUpdater | |
| private volatile V |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object | |
| pack-priv Object | |
| public long | |
| public V | |
| public int | |
| public K | |
| pack-priv boolean | |
| public void |
| accessToken | back to summary |
|---|---|
| private volatile Object accessToken | |
| CLAIM_TOKEN | back to summary |
|---|---|
| private static final Object CLAIM_TOKEN | |
| expires | back to summary |
|---|---|
| private final long expires | |
| hits | back to summary |
|---|---|
| private volatile int hits | |
| hitsUpdater | back to summary |
|---|---|
| private static final AtomicIntegerFieldUpdater<LRUCache. | |
| key | back to summary |
|---|---|
| private final K key | |
| tokenUpdator | back to summary |
|---|---|
| private static final AtomicReferenceFieldUpdater<LRUCache. | |
| value | back to summary |
|---|---|
| private volatile V value | |
| CacheEntry | back to summary |
|---|---|
| private CacheEntry(K key, V value, final long expires) | |
| claimToken | back to summary |
|---|---|
| pack-priv Object claimToken() | |
| clearToken | back to summary |
|---|---|
| pack-priv Object clearToken() | |
| getExpires | back to summary |
|---|---|
| public long getExpires() | |
| getValue | back to summary |
|---|---|
| public V getValue() | |
| hit | back to summary |
|---|---|
| public int hit() | |
| key | back to summary |
|---|---|
| public K key() | |
| setToken | back to summary |
|---|---|
| pack-priv boolean setToken(Object token) | |
| setValue | back to summary |
|---|---|
| public void setValue(final V value) | |