Class FifoEvictionPolicy<K,​V>

  • All Implemented Interfaces:
    Externalizable, Serializable, EvictionPolicy<K,​V>, IgniteMBeanAware

    public class FifoEvictionPolicy<K,​V>
    extends AbstractEvictionPolicy<K,​V>
    implements IgniteMBeanAware
    Eviction policy based on First In First Out (FIFO) algorithm and supports batch eviction.

    The eviction starts in the following cases:

    • The cache size becomes batchSize elements greater than the maximum size.
    • The size of cache entries in bytes becomes greater than the maximum memory size. The size of cache entry calculates as sum of key size and value size.
    Note:Batch eviction is enabled only if maximum memory limit isn't set (maxMemSize == 0). batchSize elements will be evicted in this case. The default batchSize value is 1.

    This implementation is very efficient since it does not create any additional table-like data structures. The FIFO ordering information is maintained by attaching ordering metadata to cache entries.

    See Also:
    Serialized Form
    • Constructor Detail

      • FifoEvictionPolicy

        public FifoEvictionPolicy()
        Constructs FIFO eviction policy with all defaults.
      • FifoEvictionPolicy

        public FifoEvictionPolicy​(int max)
        Constructs FIFO eviction policy with maximum size. Empty entries are allowed.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
      • FifoEvictionPolicy

        public FifoEvictionPolicy​(int max,
                                  int batchSize)
        Constructs FIFO eviction policy with maximum size and given batch size. Empty entries are allowed.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
        batchSize - Batch size.
    • Method Detail

      • setMaxSize

        public FifoEvictionPolicy<K,​V> setMaxSize​(int max)
        Sets maximum allowed size of cache before entry will start getting evicted.
        Overrides:
        setMaxSize in class AbstractEvictionPolicy<K,​V>
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
        Returns:
        this for chaining.
      • queue

        public Collection<EvictableEntry<K,​V>> queue()
        Gets read-only view on internal FIFO queue in proper order.
        Returns:
        Read-only view ono internal 'FIFO' queue.
      • removeMeta

        protected boolean removeMeta​(Object meta)
        Specified by:
        removeMeta in class AbstractEvictionPolicy<K,​V>
        Parameters:
        meta - Meta-information shipped to an entry.
        Returns:
        True if meta was successfully removed from the container.
      • shrink0

        protected int shrink0()
        Tries to remove one item from queue.
        Specified by:
        shrink0 in class AbstractEvictionPolicy<K,​V>
        Returns:
        number of bytes that was free. -1 if queue is empty.