- Type Parameters:
K- Key type.V- Value type.T- Output type.
- All Known Implementing Classes:
AsyncCommand,Command,CommandWrapper,TracedCommand,TransactionalCommand
public interface RedisCommand<K,V,T>
A redis command that holds an output, arguments and a state, whether it is completed or not.
Commands can be wrapped. Outer commands have to notify inner commands but inner commands do not communicate with outer
commands.
- Since:
- 3.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidcancel()Attempts to cancel execution of this command.voidcomplete()Complete a command.booleancompleteExceptionally(Throwable throwable)Complete this command by attaching the givenexception.voidencode(ByteBuf buf)Encode the command.CommandArgs<K,V>getArgs()CommandOutput<K,V,T>getOutput()The command output.ProtocolKeywordgetType()booleanisCancelled()Returnstrueif this task was cancelled before it completed normally.booleanisDone()Returnstrueif this task completed.voidsetOutput(CommandOutput<K,V,T> output)Set a new output.
-
Method Details
-
getOutput
CommandOutput<K,V,T> getOutput()The command output. Can be null.- Returns:
- the command output.
-
complete
void complete()Complete a command. -
completeExceptionally
Complete this command by attaching the givenexception.- Parameters:
throwable- the exception- Returns:
trueif this invocation caused this CompletableFuture to transition to a completed state, elsefalse
-
cancel
void cancel()Attempts to cancel execution of this command. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. -
getArgs
CommandArgs<K,V> getArgs()- Returns:
- the current command args.
-
getType
ProtocolKeyword getType()- Returns:
- the Redis command type like
SADD,HMSET,QUIT.
-
encode
Encode the command.- Parameters:
buf- byte buffer to operate on.
-
isCancelled
boolean isCancelled()Returnstrueif this task was cancelled before it completed normally.- Returns:
trueif the command was cancelled before it completed normally.
-
isDone
boolean isDone()Returnstrueif this task completed. Completion may be due to normal termination, an exception, or cancellation. In all of these cases, this method will returntrue.- Returns:
trueif this task completed.
-
setOutput
Set a new output. Only possible as long as the command is not completed/cancelled.- Parameters:
output- the new command output- Throws:
IllegalStateException- if the command is cancelled/completed
-