public class BoundedSegmentedDataContainer<K,V> extends DefaultSegmentedDataContainer<K,V>
Note this implementation supports both temporary non owned segments and not (L1). This map only utilizes heap based (ie. ConcurrentHashMap) maps internally
AbstractInternalDataContainer.EntryIteratorDataContainer.ComputeAction<K,V>| Modifier and Type | Field and Description |
|---|---|
protected PeekableTouchableMap<K,V> |
entries |
protected com.github.benmanes.caffeine.cache.Cache<K,InternalCacheEntry<K,V>> |
evictionCache |
maps, mapSupplier, notExpiredPredicate, shouldStopSegmentsconfiguration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, orderer, passivator, timeService| Constructor and Description |
|---|
BoundedSegmentedDataContainer(int numSegments,
long thresholdSize,
EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator) |
BoundedSegmentedDataContainer(int numSegments,
long thresholdSize,
EvictionType thresholdPolicy) |
| Modifier and Type | Method and Description |
|---|---|
long |
capacity()
Returns the capacity of the underlying container.
|
void |
cleanUp()
Method used to cleanup any pending data, such as evictions
|
void |
clear()
Removes all entries in the container
|
void |
clear(IntSet segments)
Removes entries from the container whose key maps to one of the provided segments
|
protected void |
computeEntryRemoved(K key,
InternalCacheEntry<K,V> value)
This method is invoked every time an entry is removed inside a compute block
|
protected void |
computeEntryWritten(K key,
InternalCacheEntry<K,V> value)
This method is invoked every time an entry is written inside a compute block
|
long |
evictionSize()
Returns how large the eviction size is currently.
|
PeekableTouchableMap<K,V> |
getMapForSegment(int segment) |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired()
Same as
DataContainer.iterator() except that is also returns expired entries. |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired(IntSet segments)
Same as
DataContainer.iteratorIncludingExpired() except that only entries that map to the provided
segments are returned via the iterator. |
InternalCacheEntry<K,V> |
peek(Object k)
Retrieves a cache entry in the same way as
DataContainer.get(Object)} except that it does not update or reorder any of
the internal constructs. |
void |
removeSegments(IntSet segments)
Removes and un-associates the given segments.
|
void |
resize(long newSize)
Resizes the capacity of the underlying container.
|
int |
sizeIncludingExpired() |
Spliterator<InternalCacheEntry<K,V>> |
spliteratorIncludingExpired()
Same as
DataContainer.spliterator() except that is also returns expired entries. |
Spliterator<InternalCacheEntry<K,V>> |
spliteratorIncludingExpired(IntSet segments)
Same as
DataContainer.spliteratorIncludingExpired() except that only entries that map to the provided
segments are returned via this spliterator. |
addSegments, forEach, getSegmentForKey, iterator, iterator, publisher, sizeIncludingExpired, spliterator, spliterator, start, stopaddRemovalListener, applyListener, compute, compute, containsKey, containsKey, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, handleEviction, peek, put, put, remove, remove, removeRemovalListener, touchclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsizesizeprotected final com.github.benmanes.caffeine.cache.Cache<K,InternalCacheEntry<K,V>> evictionCache
protected final PeekableTouchableMap<K,V> entries
public BoundedSegmentedDataContainer(int numSegments,
long thresholdSize,
EvictionType thresholdPolicy)
public BoundedSegmentedDataContainer(int numSegments,
long thresholdSize,
EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator)
protected void computeEntryWritten(K key, InternalCacheEntry<K,V> value)
AbstractInternalDataContainercomputeEntryWritten in class AbstractInternalDataContainer<K,V>key - key passed to compute methodvalue - the new valueprotected void computeEntryRemoved(K key, InternalCacheEntry<K,V> value)
AbstractInternalDataContainercomputeEntryRemoved in class AbstractInternalDataContainer<K,V>key - key passed to compute methodvalue - the old valuepublic PeekableTouchableMap<K,V> getMapForSegment(int segment)
getMapForSegment in class DefaultSegmentedDataContainer<K,V>public InternalCacheEntry<K,V> peek(Object k)
DataContainerDataContainer.get(Object)} except that it does not update or reorder any of
the internal constructs. I.e., expiration does not happen, and in the case of the LRU container, the entry is not
moved to the end of the chain.
This method should be used instead of DataContainer.get(Object)} when called while iterating through the data container
using methods like DataContainer.iterator() to avoid changing the underlying collection's order.peek in interface DataContainer<K,V>peek in class AbstractInternalDataContainer<K,V>k - key under which entry is storedpublic void clear()
DataContainerclear in interface DataContainer<K,V>clear in class DefaultSegmentedDataContainer<K,V>public void clear(IntSet segments)
InternalDataContainerclear in interface InternalDataContainer<K,V>clear in class AbstractInternalDataContainer<K,V>segments - segments of entries to removepublic Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
DataContainerDataContainer.iterator() except that is also returns expired entries.iteratorIncludingExpired in interface DataContainer<K,V>iteratorIncludingExpired in class DefaultSegmentedDataContainer<K,V>public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired(IntSet segments)
InternalDataContainerDataContainer.iteratorIncludingExpired() except that only entries that map to the provided
segments are returned via the iterator. The iterator can return expired entries.iteratorIncludingExpired in interface InternalDataContainer<K,V>iteratorIncludingExpired in class DefaultSegmentedDataContainer<K,V>segments - segments of entries to usepublic Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
DataContainerDataContainer.spliterator() except that is also returns expired entries.spliteratorIncludingExpired in interface DataContainer<K,V>spliteratorIncludingExpired in class DefaultSegmentedDataContainer<K,V>public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired(IntSet segments)
InternalDataContainerDataContainer.spliteratorIncludingExpired() except that only entries that map to the provided
segments are returned via this spliterator. The spliterator will return expired entries as well.spliteratorIncludingExpired in interface InternalDataContainer<K,V>spliteratorIncludingExpired in class DefaultSegmentedDataContainer<K,V>segments - segments of entries to usepublic int sizeIncludingExpired()
sizeIncludingExpired in interface DataContainer<K,V>sizeIncludingExpired in class DefaultSegmentedDataContainer<K,V>public void removeSegments(IntSet segments)
InternalDataContainerInternalDataContainer.addRemovalListener(Consumer) of entries that were removed due to no longer being associated with this
container. There is no guarantee if the consumer is invoked once or multiple times for a given group of segments
and could be in any order.
When this method is invoked an implementation is free to remove any entries that don't map to segments currently
associated with this container. Note that entries that were removed due to their segments never being associated
with this container do not notify listeners registered via InternalDataContainer.addRemovalListener(Consumer).
removeSegments in interface InternalDataContainer<K,V>removeSegments in class DefaultSegmentedDataContainer<K,V>segments - segments that should no longer be associated with this containerpublic long capacity()
DataContainerUnsupportedOperationException is thrown
otherwise.public void resize(long newSize)
DataContainerUnsupportedOperationException is thrown otherwise.newSize - the new sizepublic long evictionSize()
DataContainerUnsupportedOperationException is thrown otherwise. This value will always be lower than the value returned
from DataContainer.capacity()public void cleanUp()
InternalDataContainerCopyright © 2022 JBoss by Red Hat. All rights reserved.