Class EvictionConfig

java.lang.Object
com.hazelcast.config.EvictionConfig
All Implemented Interfaces:
com.hazelcast.internal.eviction.EvictionConfiguration, DataSerializable, IdentifiedDataSerializable, Serializable

public class EvictionConfig extends Object implements com.hazelcast.internal.eviction.EvictionConfiguration, IdentifiedDataSerializable, Serializable
Configuration for eviction.

You can set a limit for number of entries or total memory cost of entries.

The default values of the eviction configuration are:

See Also:
  • Field Details

    • DEFAULT_MAX_ENTRY_COUNT

      public static final int DEFAULT_MAX_ENTRY_COUNT
      Default maximum entry count.
      See Also:
    • DEFAULT_MAX_SIZE_POLICY

      public static final MaxSizePolicy DEFAULT_MAX_SIZE_POLICY
      Default Max-Size Policy.
    • DEFAULT_EVICTION_POLICY

      public static final EvictionPolicy DEFAULT_EVICTION_POLICY
      Default Eviction Policy.
    • size

      protected int size
    • maxSizePolicy

      protected MaxSizePolicy maxSizePolicy
    • evictionPolicy

      protected EvictionPolicy evictionPolicy
    • comparatorClassName

      protected String comparatorClassName
    • comparator

      protected EvictionPolicyComparator comparator
  • Constructor Details

    • EvictionConfig

      public EvictionConfig()
    • EvictionConfig

      public EvictionConfig(EvictionConfig config)
  • Method Details

    • getSize

      public int getSize()
      Returns the size which is used by the MaxSizePolicy.

      The interpretation of the value depends on the configured MaxSizePolicy.

      Returns:
      the size which is used by the MaxSizePolicy
    • setSize

      public EvictionConfig setSize(int size)
      Sets the size which is used by the MaxSizePolicy.

      The interpretation of the value depends on the configured MaxSizePolicy.

      Accepts any non-negative number. The default value is 10000.

      Parameters:
      size - the size which is used by the MaxSizePolicy
      Returns:
      this EvictionConfig instance
    • getMaxSizePolicy

      public MaxSizePolicy getMaxSizePolicy()
      Returns the MaxSizePolicy of this eviction configuration.
      Returns:
      the MaxSizePolicy of this eviction configuration
    • setMaxSizePolicy

      public EvictionConfig setMaxSizePolicy(MaxSizePolicy maxSizePolicy)
      Sets the MaxSizePolicy of this eviction configuration.
      Parameters:
      maxSizePolicy - the MaxSizePolicy of this eviction configuration
      Returns:
      this EvictionConfig instance
    • getEvictionPolicy

      public EvictionPolicy getEvictionPolicy()
      Returns the EvictionPolicy of this eviction configuration.
      Specified by:
      getEvictionPolicy in interface com.hazelcast.internal.eviction.EvictionConfiguration
      Returns:
      the EvictionPolicy of this eviction configuration
    • setEvictionPolicy

      public EvictionConfig setEvictionPolicy(EvictionPolicy evictionPolicy)
      Sets the EvictionPolicy of this eviction configuration.
      Parameters:
      evictionPolicy - the EvictionPolicy of this eviction configuration
      Returns:
      this EvictionConfig instance
    • getEvictionStrategyType

      public com.hazelcast.internal.eviction.EvictionStrategyType getEvictionStrategyType()
      Returns the EvictionStrategyType of this eviction configuration.
      Specified by:
      getEvictionStrategyType in interface com.hazelcast.internal.eviction.EvictionConfiguration
      Returns:
      the EvictionStrategyType of this eviction configuration
    • getComparatorClassName

      public String getComparatorClassName()
      Returns the class name of the configured EvictionPolicyComparator implementation.
      Specified by:
      getComparatorClassName in interface com.hazelcast.internal.eviction.EvictionConfiguration
      Returns:
      the class name of the configured EvictionPolicyComparator implementation
    • setComparatorClassName

      public EvictionConfig setComparatorClassName(@Nonnull String comparatorClassName)
      Sets the class name of the configured EvictionPolicyComparator implementation.

      Only one of the comparator class name and comparator can be configured in the eviction configuration.

      Parameters:
      comparatorClassName - the class name of the configured EvictionPolicyComparator implementation
      Returns:
      this EvictionConfig instance
    • getComparator

      public EvictionPolicyComparator getComparator()
      Returns the instance of the configured EvictionPolicyComparator implementation.
      Specified by:
      getComparator in interface com.hazelcast.internal.eviction.EvictionConfiguration
      Returns:
      the instance of the configured EvictionPolicyComparator implementation
    • setComparator

      public EvictionConfig setComparator(@Nonnull EvictionPolicyComparator comparator)
      Sets the instance of the configured EvictionPolicyComparator implementation.

      Only one of the comparator class name and comparator can be configured in the eviction configuration.

      Parameters:
      comparator - the instance of the configured EvictionPolicyComparator implementation
      Returns:
      this EvictionConfig instance
      See Also:
    • getFactoryId

      public int getFactoryId()
      Description copied from interface: IdentifiedDataSerializable
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
      getFactoryId in interface IdentifiedDataSerializable
      Returns:
      factory ID
    • getClassId

      public int getClassId()
      Description copied from interface: IdentifiedDataSerializable
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
      getClassId in interface IdentifiedDataSerializable
      Returns:
      type ID
    • writeData

      public void writeData(ObjectDataOutput out) throws IOException
      Description copied from interface: DataSerializable
      Writes object fields to output stream
      Specified by:
      writeData in interface DataSerializable
      Parameters:
      out - output
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
    • readData

      public void readData(ObjectDataInput in) throws IOException
      Description copied from interface: DataSerializable
      Reads fields from the input stream
      Specified by:
      readData in interface DataSerializable
      Parameters:
      in - input
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the input stream has been closed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object