com.hazelcast.config

## Class EvictionConfig

- java.lang.Object
- - com.hazelcast.config.EvictionConfig

- All Implemented Interfaces:
    com.hazelcast.internal.eviction.EvictionConfiguration, DataSerializable, Serializable
  Direct Known Subclasses:
    CacheEvictionConfig, EvictionConfigReadOnly

      public class EvictionConfig
      extends Object
      implements com.hazelcast.internal.eviction.EvictionConfiguration, DataSerializable, 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

  - `EvictionPolicy.LRU` as eviction policy
  - `EvictionConfig.MaxSizePolicy.ENTRY_COUNT` as max size policy
  - 2147483647 as maximum size for on-heap `IMap`
  - 10000 as maximum size for all other data structures and configurations
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `EvictionConfig.MaxSizePolicy` Maximum Size Policy

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected com.hazelcast.internal.eviction.EvictionPolicyComparator` | `comparator`
    `protected String` | `comparatorClassName`
    `static EvictionPolicy` | `DEFAULT_EVICTION_POLICY` Default Eviction Policy.
    `static int` | `DEFAULT_MAX_ENTRY_COUNT` Default maximum entry count.
    `static int` | `DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP` Default maximum entry count for Map on-heap Near Caches.
    `static EvictionConfig.MaxSizePolicy` | `DEFAULT_MAX_SIZE_POLICY` Default Max-Size Policy.
    `protected EvictionPolicy` | `evictionPolicy`
    `protected EvictionConfig.MaxSizePolicy` | `maxSizePolicy`
    `protected EvictionConfig` | `readOnly`
    `protected int` | `size`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EvictionConfig()`
    `EvictionConfig(EvictionConfig config)`
    `EvictionConfig(int size, EvictionConfig.MaxSizePolicy maxSizePolicy, EvictionPolicy evictionPolicy)`
    `EvictionConfig(int size, EvictionConfig.MaxSizePolicy maxSizePolicy, com.hazelcast.internal.eviction.EvictionPolicyComparator comparator)`
    `EvictionConfig(int size, EvictionConfig.MaxSizePolicy maxSizePolicy, String comparatorClassName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `EvictionConfig` | `getAsReadOnly()` Deprecated. this method will be removed in 4.0; it is meant for internal usage only
    `com.hazelcast.internal.eviction.EvictionPolicyComparator` | `getComparator()` Returns the instance of the configured `EvictionPolicyComparator` implementation.
    `String` | `getComparatorClassName()` Returns the class name of the configured `EvictionPolicyComparator` implementation.
    `EvictionPolicy` | `getEvictionPolicy()` Returns the `EvictionPolicy` of this eviction configuration.
    `com.hazelcast.internal.eviction.EvictionPolicyType` | `getEvictionPolicyType()` Deprecated. since 3.9, please use `getEvictionPolicy()`
    `com.hazelcast.internal.eviction.EvictionStrategyType` | `getEvictionStrategyType()` Returns the `EvictionStrategyType` of this eviction configuration.
    `EvictionConfig.MaxSizePolicy` | `getMaximumSizePolicy()` Returns the `EvictionConfig.MaxSizePolicy` of this eviction configuration.
    `int` | `getSize()` Returns the size which is used by the `EvictionConfig.MaxSizePolicy`.
    `int` | `hashCode()`
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `EvictionConfig` | `setComparator(com.hazelcast.internal.eviction.EvictionPolicyComparator comparator)` Sets the instance of the configured `EvictionPolicyComparator` implementation.
    `EvictionConfig` | `setComparatorClassName(String comparatorClassName)` Sets the class name of the configured `EvictionPolicyComparator` implementation.
    `EvictionConfig` | `setEvictionPolicy(EvictionPolicy evictionPolicy)` Sets the `EvictionPolicy` of this eviction configuration.
    `EvictionConfig` | `setMaximumSizePolicy(EvictionConfig.MaxSizePolicy maxSizePolicy)` Sets the `EvictionConfig.MaxSizePolicy` of this eviction configuration.
    `EvictionConfig` | `setSize(int size)` Sets the size which is used by the `EvictionConfig.MaxSizePolicy`.
    `String` | `toString()`
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_MAX_ENTRY_COUNT

          public static final int DEFAULT_MAX_ENTRY_COUNT

      Default maximum entry count.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP

          public static final int DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP

      Default maximum entry count for Map on-heap Near Caches.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_SIZE_POLICY

          public static final EvictionConfig.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 EvictionConfig.MaxSizePolicy maxSizePolicy

    - #### evictionPolicy

          protected EvictionPolicy evictionPolicy

    - #### comparatorClassName

          protected String comparatorClassName

    - #### comparator

          protected com.hazelcast.internal.eviction.EvictionPolicyComparator comparator

    - #### readOnly

          protected EvictionConfig readOnly

  - ### Constructor Detail

    - #### EvictionConfig

          public EvictionConfig()

    - #### EvictionConfig

          public EvictionConfig(int size,
                                EvictionConfig.MaxSizePolicy maxSizePolicy,
                                EvictionPolicy evictionPolicy)

    - #### EvictionConfig

          public EvictionConfig(int size,
                                EvictionConfig.MaxSizePolicy maxSizePolicy,
                                String comparatorClassName)

    - #### EvictionConfig

          public EvictionConfig(int size,
                                EvictionConfig.MaxSizePolicy maxSizePolicy,
                                com.hazelcast.internal.eviction.EvictionPolicyComparator comparator)

    - #### EvictionConfig

          public EvictionConfig(EvictionConfig config)

  - ### Method Detail

    - #### getAsReadOnly

          public EvictionConfig getAsReadOnly()

      Deprecated. this method will be removed in 4.0; it is meant for internal usage only
      Gets immutable version of this configuration.
      Returns:
        immutable version of this configuration

    - #### getSize

          public int getSize()

      Returns the size which is used by the `EvictionConfig.MaxSizePolicy`.

      The interpretation of the value depends on the configured `EvictionConfig.MaxSizePolicy`.

      Returns:
        the size which is used by the `EvictionConfig.MaxSizePolicy`

    - #### setSize

          public EvictionConfig setSize(int size)

      Sets the size which is used by the `EvictionConfig.MaxSizePolicy`.

      The interpretation of the value depends on the configured `EvictionConfig.MaxSizePolicy`.

      Accepts any positive number. The default value is 10000.

      Parameters:
        `size` - the size which is used by the `EvictionConfig.MaxSizePolicy`
      Returns:
        this EvictionConfig instance

    - #### getMaximumSizePolicy

          public EvictionConfig.MaxSizePolicy getMaximumSizePolicy()

      Returns the `EvictionConfig.MaxSizePolicy` of this eviction configuration.
      Returns:
        the `EvictionConfig.MaxSizePolicy` of this eviction configuration

    - #### setMaximumSizePolicy

          public EvictionConfig setMaximumSizePolicy(EvictionConfig.MaxSizePolicy maxSizePolicy)

      Sets the `EvictionConfig.MaxSizePolicy` of this eviction configuration.
      Parameters:
        `maxSizePolicy` - the `EvictionConfig.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

    - #### getEvictionPolicyType

          @Deprecated
          public com.hazelcast.internal.eviction.EvictionPolicyType getEvictionPolicyType()

      Deprecated. since 3.9, please use `getEvictionPolicy()`
      Returns the `EvictionPolicyType` of this eviction configuration.
      Specified by:
        `getEvictionPolicyType` in interface `com.hazelcast.internal.eviction.EvictionConfiguration`
      Returns:
        the `EvictionPolicyType` 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(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 com.hazelcast.internal.eviction.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(com.hazelcast.internal.eviction.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

    - #### 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`

Copyright © 2019. All rights reserved.