Class SortedEvictionPolicy<K,​V>

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

    public class SortedEvictionPolicy<K,​V>
    extends AbstractEvictionPolicy<K,​V>
    implements IgniteMBeanAware
    Cache eviction policy which will select the minimum cache entry for 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.

    Entries comparison based on Comparator instance if provided. Default Comparator behaviour is use cache entries keys for comparison that imposes a requirement for keys to implement Comparable interface.

    User defined comparator should implement Serializable interface.

    See Also:
    Serialized Form
    • Constructor Detail

      • SortedEvictionPolicy

        public SortedEvictionPolicy()
        Constructs sorted eviction policy with all defaults.
      • SortedEvictionPolicy

        public SortedEvictionPolicy​(int max)
        Constructs sorted eviction policy with maximum size.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
      • SortedEvictionPolicy

        public SortedEvictionPolicy​(int max,
                                    @Nullable
                                    @Nullable Comparator<EvictableEntry<K,​V>> comp)
        Constructs sorted eviction policy with given maximum size and given entry comparator.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
        comp - Entries comparator.
      • SortedEvictionPolicy

        public SortedEvictionPolicy​(int max,
                                    int batchSize,
                                    @Nullable
                                    @Nullable Comparator<EvictableEntry<K,​V>> comp)
        Constructs sorted eviction policy with given maximum size, eviction batch size and entries comparator.
        Parameters:
        max - Maximum allowed size of cache before entry will start getting evicted.
        batchSize - Batch size.
        comp - Entries comparator.
      • SortedEvictionPolicy

        public SortedEvictionPolicy​(@Nullable
                                    @Nullable Comparator<EvictableEntry<K,​V>> comp)
        Constructs sorted eviction policy with given maximum size and given entry comparator.
        Parameters:
        comp - Entries comparator.