Record Class MapStoreConfig

java.lang.Object
java.lang.Record
com.loomcache.server.datastructures.mapstore.MapStoreConfig
Record Components:
writeThrough - when true, every write synchronously invokes MapStore.store(Object, Object) / MapStore.delete(Object) in the critical path (deferred-side-effect style: after the transaction lock releases, but before the caller is notified)
writeBehind - when true, writes are coalesced into a bounded queue and flushed periodically on a virtual-thread scheduler; same-key updates collapse
writeBatchSize - maximum batch size per flush cycle (write-behind only); must be > 0
writeDelay - time between flush cycles (write-behind only); must be > Duration.ZERO
loadMode - controls whether MapStore.loadAllKeys() is invoked at wire-up time (EAGER) or only on get-miss (LAZY)

public record MapStoreConfig(boolean writeThrough, boolean writeBehind, int writeBatchSize, Duration writeDelay, MapStoreConfig.LoadMode loadMode) extends Record
Configuration for wiring a MapStore into a DistributedMap.

Exactly one of writeThrough and writeBehind may be true (enabling both is nonsensical and rejected at construction).

  • Constructor Details

    • MapStoreConfig

      public MapStoreConfig(boolean writeThrough, boolean writeBehind, int writeBatchSize, Duration writeDelay, MapStoreConfig.LoadMode loadMode)
      Compact-constructor validation.
  • Method Details

    • defaults

      public static MapStoreConfig defaults()
      Sensible defaults: write-through, LAZY load, 100-entry batches, 1-second flush interval.
      Returns:
      the default configuration
    • writeBehindConfig

      public static MapStoreConfig writeBehindConfig(int batchSize, Duration delay)
      Convenience factory for write-behind mode.
      Parameters:
      batchSize - maximum entries per flush batch
      delay - flush interval
      Returns:
      a write-behind configuration
    • writeThroughConfig

      public static MapStoreConfig writeThroughConfig()
      Convenience factory for write-through mode.
      Returns:
      a write-through configuration
    • writeThroughNoLoadConfig

      public static MapStoreConfig writeThroughNoLoadConfig()
      Convenience factory for write-through persistence without read-through loading.
      Returns:
      a write-through configuration with backing-store reads disabled
    • 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.
    • writeThrough

      public boolean writeThrough()
      Returns the value of the writeThrough record component.
      Returns:
      the value of the writeThrough record component
    • writeBehind

      public boolean writeBehind()
      Returns the value of the writeBehind record component.
      Returns:
      the value of the writeBehind record component
    • writeBatchSize

      public int writeBatchSize()
      Returns the value of the writeBatchSize record component.
      Returns:
      the value of the writeBatchSize record component
    • writeDelay

      public Duration writeDelay()
      Returns the value of the writeDelay record component.
      Returns:
      the value of the writeDelay record component
    • loadMode

      public MapStoreConfig.LoadMode loadMode()
      Returns the value of the loadMode record component.
      Returns:
      the value of the loadMode record component