Class LoomBatch

java.lang.Object
com.loomcache.client.LoomBatch

public class LoomBatch extends Object
Fluent builder for batching multiple data-structure operations into a single server-side execution.

Three execution levels:

  1. Fast batch (default) — operations execute sequentially on the server; a failure midway leaves earlier operations applied.
  2. Atomic (atomic()) — all-or-nothing on this node; a failure rolls back every operation in the batch.
  3. Replicated atomic (atomic().replicated()) — the batch is committed as a single Raft log entry and applied atomically on all replicas.

Wire text: Batch queue values must be UTF-8 text. Map keys/values and set members are framed with ClientSerializer, matching the regular LoomMap and LoomSet proxies.

Usage:

loomClient.batch()
    .map("users").put("user:1", "{\"name\":\"Ada\"}")
    .map("orders").put("order:123", "{\"status\":\"created\"}")
    .set("active-users").add("user:1")
    .execute();
Since:
1.3
  • Constructor Details

    • LoomBatch

      public LoomBatch(LoomClient client)
      Create a new batch builder.
      Parameters:
      client - the LoomClient to use for batch execution (must not be null)
      Throws:
      NullPointerException - if client is null
  • Method Details

    • atomic

      public LoomBatch atomic()
      Enable atomic (all-or-nothing) execution. If any operation fails, all changes are rolled back.
      Returns:
      this batch for chaining
    • replicated

      public LoomBatch replicated()
      Enable Raft-committed execution. The entire batch is serialized as a single Raft log entry and applied atomically on all replicas. Implies atomic().
      Returns:
      this batch for chaining
    • map

      public LoomBatch.MapOps map(String mapName)
      Select a map to operate on.
      Parameters:
      mapName - the map name
      Returns:
      a map operation builder
    • set

      public LoomBatch.SetOps set(String setName)
      Select a set to operate on.
      Parameters:
      setName - the set name
      Returns:
      a set operation builder
    • queue

      public LoomBatch.QueueOps queue(String queueName)
      Select a queue to operate on.
      Parameters:
      queueName - the queue name
      Returns:
      a queue operation builder
    • execute

      public void execute()
      Send all accumulated operations to the server for execution.
      Throws:
      IllegalStateException - if the batch is empty
      TimeoutException - on server timeout
      RuntimeException - if the server returns an error (atomic batches report the first failed operation in the exception message)
    • size

      public int size()
      Returns the number of operations in this batch.
      Returns:
      the number of operations