Module lettuce.core

Interface RedisCommand<K,​V,​T>

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 Details

    • getOutput

      CommandOutput<K,​V,​T> getOutput()
      The command output. Can be null.
      Returns:
      the command output.
    • complete

      void complete()
      Complete a command.
    • completeExceptionally

      boolean completeExceptionally​(Throwable throwable)
      Complete this command by attaching the given exception.
      Parameters:
      throwable - the exception
      Returns:
      true if this invocation caused this CompletableFuture to transition to a completed state, else false
    • 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

      void encode​(ByteBuf buf)
      Encode the command.
      Parameters:
      buf - byte buffer to operate on.
    • isCancelled

      boolean isCancelled()
      Returns true if this task was cancelled before it completed normally.
      Returns:
      true if the command was cancelled before it completed normally.
    • isDone

      boolean isDone()
      Returns true 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.
      Returns:
      true if this task completed.
    • setOutput

      void setOutput​(CommandOutput<K,​V,​T> output)
      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