@Retention(RUNTIME) @Target(TYPE) @Documented public @interface BatchSize
batchSize.
Usage:
@BatchSize(50)
public interface MyCommands extends Commands {
public void set(String key, String value);
public RedisFuture<String> get(String key)
}
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.
Command methods participating in batching share a single batch queue. All method invocations are queued until reaching the
batch size. Command batching can be also specified using dynamic batching by providing a CommandBatching parameter on
each command invocation. CommandBatching parameters have precedence over BatchSize and can be used to enqueue
commands or force batch flushing of commands.
Alternatively, a command interface can implement BatchExecutor to BatchExecutor.flush() commands before the
batch size is reached. Commands remain in a batch queue until the batch size is reached or the queue is
flushed. If the batch size is not reached, commands remain not executed.
Batching command interfaces are thread-safe and can be shared amongst multiple threads.
- Since:
- 5.0
- Author:
- Mark Paluch
- See Also:
CommandBatching,BatchExecutor
-
Required Element Summary
Required Elements Modifier and Type Required Element Description intvalueDeclares the batch size for the command method.
-
Element Details
-
value
int valueDeclares the batch size for the command method.- Returns:
- a positive, non-zero number of commands.
-