Class EmbeddedLoomCacheBuilder

java.lang.Object
com.loomcache.server.embedded.EmbeddedLoomCacheBuilder

public class EmbeddedLoomCacheBuilder extends Object
Builder for EmbeddedLoomCache instances.

Provides fluent configuration with sensible defaults: - Standalone mode by default (no clustering) - Hazelcast-compatible cluster name, member port, and unbounded map defaults - REST API disabled by default - In-process data structures - Thread-safe access

Example usage:

EmbeddedLoomCache cache = EmbeddedLoomCache.builder()
    .port(5701)
    .dataDir("./data")
    .enableRest(8080)
    .build();
  • Constructor Details

    • EmbeddedLoomCacheBuilder

      public EmbeddedLoomCacheBuilder()
  • Method Details

    • nodeId

      public EmbeddedLoomCacheBuilder nodeId(String nodeId)
      Set the node ID.
    • dataDir

      public EmbeddedLoomCacheBuilder dataDir(String path)
      Set the data directory for persistence (default: persistence).
    • dataDir

      public EmbeddedLoomCacheBuilder dataDir(Path path)
      Set the data directory for persistence (default: persistence).
    • clusterName

      public EmbeddedLoomCacheBuilder clusterName(String name)
      Set the cluster name (default: dev).
    • port

      public EmbeddedLoomCacheBuilder port(int port)
      Set the TCP port for cluster communication (default: 5701).
    • host

      public EmbeddedLoomCacheBuilder host(@Nullable String host)
      Set the advertised host address for cluster communication. When omitted, standalone mode uses loopback and clustered mode resolves a non-loopback local address automatically.
    • enableRest

      public EmbeddedLoomCacheBuilder enableRest(int port)
      Enable the REST API on the specified port.
      Parameters:
      port - the port for the REST API (or -1 to disable)
    • standalone

      public EmbeddedLoomCacheBuilder standalone()
      Configure standalone mode (single-node, no clustering). This is the default.
    • joinCluster

      public EmbeddedLoomCacheBuilder joinCluster(String... seeds)
      Join a cluster with the specified seed nodes.
      Parameters:
      seeds - comma-separated seed node addresses (e.g., "localhost:5701,localhost:5702")
    • enablePersistence

      public EmbeddedLoomCacheBuilder enablePersistence(boolean enable)
      Enable persistence (default: false).
    • maxMapEntries

      public EmbeddedLoomCacheBuilder maxMapEntries(int max)
      Set maximum number of map entries (default: 0 = unbounded).
    • evictionPolicy

      public EmbeddedLoomCacheBuilder evictionPolicy(String policy)
      Set the map eviction policy (default: NONE).
    • maxMemoryBytes

      public EmbeddedLoomCacheBuilder maxMemoryBytes(long bytes)
      Set maximum memory in bytes (default: unbounded).
    • readBackupData

      public EmbeddedLoomCacheBuilder readBackupData(boolean enabled)
      Enable local backup reads for embedded/member-local read operations. Reads may be stale while replication or leader failover is in progress.
    • build

      public EmbeddedLoomCache build()
      Build the EmbeddedLoomCache instance.