K - Key type.V - Value type.T - Command output type.public class Command<K,V,T> extends Object implements RedisCommand<K,V,T>
command type, arguments and an optional
output. All successfully executed commands will eventually return a CommandOutput object.| Modifier and Type | Field and Description |
|---|---|
protected CommandArgs<K,V> |
args |
protected Throwable |
exception |
protected CommandOutput<K,V,T> |
output |
protected static byte |
ST_CANCELLED |
protected static byte |
ST_COMPLETED |
protected static byte |
ST_INITIAL |
protected byte |
status |
| Constructor and Description |
|---|
Command(ProtocolKeyword type,
CommandOutput<K,V,T> output)
Create a new command with the supplied type.
|
Command(ProtocolKeyword type,
CommandOutput<K,V,T> output,
CommandArgs<K,V> args)
Create a new command with the supplied type and args.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Attempts to cancel execution of this command.
|
void |
complete()
Mark this command complete and notify all waiting threads.
|
boolean |
completeExceptionally(Throwable throwable)
Complete this command by attaching the given
exception. |
void |
encode(ByteBuf buf)
Encode and write this command to the supplied buffer using the new Unified
Request Protocol.
|
T |
get() |
CommandArgs<K,V> |
getArgs() |
String |
getError() |
CommandOutput<K,V,T> |
getOutput()
Get the object that holds this command's output.
|
ProtocolKeyword |
getType() |
boolean |
isCancelled()
Returns
true if this task was cancelled before it completed normally. |
boolean |
isDone()
Returns
true if this task completed. |
void |
setOutput(CommandOutput<K,V,T> output)
Set a new output.
|
String |
toString() |
protected static final byte ST_INITIAL
protected static final byte ST_COMPLETED
protected static final byte ST_CANCELLED
protected CommandArgs<K,V> args
protected CommandOutput<K,V,T> output
protected Throwable exception
protected volatile byte status
public Command(ProtocolKeyword type, CommandOutput<K,V,T> output)
type - Command type, must not be null.output - Command output, can be null.public Command(ProtocolKeyword type, CommandOutput<K,V,T> output, CommandArgs<K,V> args)
type - Command type, must not be null.output - Command output, can be null.args - Command args, can be nullpublic CommandOutput<K,V,T> getOutput()
getOutput in interface RedisCommand<K,V,T>public boolean completeExceptionally(Throwable throwable)
RedisCommandexception.completeExceptionally in interface RedisCommand<K,V,T>throwable - the exception.true if this invocation caused this CompletableFuture to transition to a completed state, else
false.public void complete()
complete in interface RedisCommand<K,V,T>public void cancel()
RedisCommandcancel in interface RedisCommand<K,V,T>public void encode(ByteBuf buf)
encode in interface RedisCommand<K,V,T>buf - Buffer to write to.public String getError()
public CommandArgs<K,V> getArgs()
getArgs in interface RedisCommand<K,V,T>public T get()
public void setOutput(CommandOutput<K,V,T> output)
RedisCommandsetOutput in interface RedisCommand<K,V,T>output - the new command output.public ProtocolKeyword getType()
getType in interface RedisCommand<K,V,T>SADD, HMSET, QUIT.public boolean isCancelled()
RedisCommandtrue if this task was cancelled before it completed normally.isCancelled in interface RedisCommand<K,V,T>true if the command was cancelled before it completed normally.public boolean isDone()
RedisCommandtrue if this task completed.
Completion may be due to normal termination, an exception, or cancellation. In all of these cases, this method will
return true.isDone in interface RedisCommand<K,V,T>true if this task completed.Copyright © 2021 lettuce.io. All rights reserved.