Record Class DistributedMapConfig

java.lang.Object
java.lang.Record
com.loomcache.server.datastructures.DistributedMapConfig

public record DistributedMapConfig(int maxSize, DistributedMapConfig.EvictionPolicy evictionPolicy, boolean metricsEnabled, long maxIdleMillis) extends Record
Per-map configuration for a DistributedMap instance.

Uses a builder so operators can tune per-map behavior before deployment:

var config = DistributedMapConfig.builder()
    .maxSize(10_000)
    .evictionPolicy(EvictionPolicy.LRU)
    .build();
var map = new DistributedMap<>("sessions", 1, config);

Immutable after construction — safe to share across threads.

  • Field Details

    • DEFAULT

      public static final DistributedMapConfig DEFAULT
      Default config: unbounded, no eviction, metrics enabled, no max-idle expiry.
  • Constructor Details

    • DistributedMapConfig

      public DistributedMapConfig(int maxSize, DistributedMapConfig.EvictionPolicy evictionPolicy, boolean metricsEnabled, long maxIdleMillis)
      Creates an instance of a DistributedMapConfig record class.
      Parameters:
      maxSize - the value for the maxSize record component
      evictionPolicy - the value for the evictionPolicy record component
      metricsEnabled - the value for the metricsEnabled record component
      maxIdleMillis - the value for the maxIdleMillis record component
    • DistributedMapConfig

      public DistributedMapConfig(int maxSize, DistributedMapConfig.EvictionPolicy evictionPolicy, boolean metricsEnabled)
  • Method Details

    • hasSizeLimit

      public boolean hasSizeLimit()
      True if this config enforces a size limit.
    • hasMaxIdle

      public boolean hasMaxIdle()
      True if this config expires entries that have not been accessed recently.
    • builder

      public static DistributedMapConfig.Builder builder()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxSize

      public int maxSize()
      Returns the value of the maxSize record component.
      Returns:
      the value of the maxSize record component
    • evictionPolicy

      public DistributedMapConfig.EvictionPolicy evictionPolicy()
      Returns the value of the evictionPolicy record component.
      Returns:
      the value of the evictionPolicy record component
    • metricsEnabled

      public boolean metricsEnabled()
      Returns the value of the metricsEnabled record component.
      Returns:
      the value of the metricsEnabled record component
    • maxIdleMillis

      public long maxIdleMillis()
      Returns the value of the maxIdleMillis record component.
      Returns:
      the value of the maxIdleMillis record component