java.lang.Object
io.lettuce.core.dynamic.batch.CommandBatching
public abstract class CommandBatching extends Object
Programmatic command batching API.
CommandBatching is used to queue commands in a batch queue and flush the command queue on command invocation. Usage:
public interface MyCommands extends Commands {
public void set(String key, String value, CommandBatching batching);
public RedisFuture<String> get(String key, CommandBatching batching)
}
MyCommands commands = …
commands.set("key", "value", CommandBatching.queue());
commands.get("key", CommandBatching.flush());
Using CommandBatching in a method signature turns the command method into a batched command method.
Command batching executes commands in a deferred nature. This also means that at the time of invocation no result is
available. Batching can be only used with synchronous methods without a return value (void) or asynchronous methods
returning a RedisFuture. Reactive command batching is not supported because reactive executed
commands maintain an own subscription lifecycle that is decoupled from command method batching.
- Since:
- 5.0
- Author:
- Mark Paluch
- See Also:
BatchSize
-
Constructor Summary
Constructors Constructor Description CommandBatching() -
Method Summary
Modifier and Type Method Description static CommandBatchingflush()Flush the command batch queue after adding a command to the batch queue.static CommandBatchingqueue()Enqueue the command to the batch queue.
-
Constructor Details
-
CommandBatching
public CommandBatching()
-
-
Method Details
-
flush
Flush the command batch queue after adding a command to the batch queue.- Returns:
CommandBatchingto flush the command batch queue after adding a command to the batch queue.
-
queue
Enqueue the command to the batch queue.- Returns:
CommandBatchingto enqueue the command to the batch queue.
-