Class SharedBoundedContainer<K,V>

Type Parameters:
K - The key type
V - The value type
All Implemented Interfaces:
Iterable<InternalCacheEntry<K,V>>, Consumer<Iterable<InternalCacheEntry<K,V>>>, DataContainer<K,V>, EvictionListener<K,V>, InternalDataContainer<K,V>

public class SharedBoundedContainer<K,V> extends DefaultSegmentedDataContainer<K,V> implements EvictionListener<K,V>, Consumer<Iterable<InternalCacheEntry<K,V>>>
A shared container where all of the entries are stored in the caffeine map, but they are indexed in the map segment container of the DefaultsegmentedDataContainer. The onEntryChosenForEviction(boolean, Object, InternalCacheEntry) must be invoked externally whenever an entry is evicted from the provided caffeineMap.

To guarantee consistency any write operations must be done while in the lock for the corresponding key of the provided caffeineMap. This means any writes to any of the maps per segment must only be done while in this secured region.

This class is implemented so that every single key read and write operation are constant time and iteration is O(N) where N is the size of the entries in the individual container and not the shared. However, due to this the clear() and clear(IntSet) methods are not O(1) as in many other implementations but rather are O(N). Please see them respectively for more details.