Annotation Type BatchSize
-
@Retention(RUNTIME) @Target(TYPE) @Documented public @interface BatchSize
Redis command method annotation declaring a command interface to use batching with a specifiedbatchSize
.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 aRedisFuture
. 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 overBatchSize
and can be used to enqueue commands or force batch flushing of commands.Alternatively, a command interface can implement
BatchExecutor
toBatchExecutor.flush()
commands before the batch size is reached. Commands remain in a batch queue until the batch size is reached or the queue isflushed
. 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 int
value
Declares the batch size for the command method.
-