Class LoomBatch
java.lang.Object
com.loomcache.client.LoomBatch
Fluent builder for batching multiple data-structure operations into a single
server-side execution.
Three execution levels:
- Fast batch (default) — operations execute sequentially on the server; a failure midway leaves earlier operations applied.
- Atomic (
atomic()) — all-or-nothing on this node; a failure rolls back every operation in the batch. - 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for map operations within a batch.static final classFluent builder for queue operations within a batch.static final classFluent builder for set operations within a batch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionatomic()Enable atomic (all-or-nothing) execution.voidexecute()Send all accumulated operations to the server for execution.Select a map to operate on.Select a queue to operate on.Enable Raft-committed execution.Select a set to operate on.intsize()Returns the number of operations in this batch.
-
Constructor Details
-
LoomBatch
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
Enable atomic (all-or-nothing) execution. If any operation fails, all changes are rolled back.- Returns:
- this batch for chaining
-
replicated
-
map
Select a map to operate on.- Parameters:
mapName- the map name- Returns:
- a map operation builder
-
set
Select a set to operate on.- Parameters:
setName- the set name- Returns:
- a set operation builder
-
queue
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 emptyTimeoutException- on server timeoutRuntimeException- 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
-