Class Command<K,​V,​T>

  • Type Parameters:
    K - Key type.
    V - Value type.
    T - Command output type.
    All Implemented Interfaces:
    RedisCommand<K,​V,​T>

    public class Command<K,​V,​T>
    extends Object
    implements RedisCommand<K,​V,​T>
    A Redis command with a command type, arguments and an optional output. All successfully executed commands will eventually return a CommandOutput object.
    Author:
    Will Glozer, Mark Paluch
    • Constructor Detail

      • Command

        public Command​(ProtocolKeyword type,
                       CommandOutput<K,​V,​T> output)
        Create a new command with the supplied type.
        Parameters:
        type - Command type, must not be null.
        output - Command output, can be null.
      • Command

        public Command​(ProtocolKeyword type,
                       CommandOutput<K,​V,​T> output,
                       CommandArgs<K,​V> args)
        Create a new command with the supplied type and args.
        Parameters:
        type - Command type, must not be null.
        output - Command output, can be null.
        args - Command args, can be null
    • Method Detail

      • getOutput

        public CommandOutput<K,​V,​T> getOutput()
        Get the object that holds this command's output.
        Specified by:
        getOutput in interface RedisCommand<K,​V,​T>
        Returns:
        The command output object.
      • completeExceptionally

        public boolean completeExceptionally​(Throwable throwable)
        Description copied from interface: RedisCommand
        Complete this command by attaching the given exception.
        Specified by:
        completeExceptionally in interface RedisCommand<K,​V,​T>
        Parameters:
        throwable - the exception
        Returns:
        true if this invocation caused this CompletableFuture to transition to a completed state, else false
      • complete

        public void complete()
        Mark this command complete and notify all waiting threads.
        Specified by:
        complete in interface RedisCommand<K,​V,​T>
      • cancel

        public void cancel()
        Description copied from interface: RedisCommand
        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.
        Specified by:
        cancel in interface RedisCommand<K,​V,​T>
      • getError

        public String getError()
      • get

        public T get()
        Returns:
        the resut from the output.
      • setOutput

        public void setOutput​(CommandOutput<K,​V,​T> output)
        Description copied from interface: RedisCommand
        Set a new output. Only possible as long as the command is not completed/cancelled.
        Specified by:
        setOutput in interface RedisCommand<K,​V,​T>
        Parameters:
        output - the new command output
      • isCancelled

        public boolean isCancelled()
        Description copied from interface: RedisCommand
        Returns true if this task was cancelled before it completed normally.
        Specified by:
        isCancelled in interface RedisCommand<K,​V,​T>
        Returns:
        true if the command was cancelled before it completed normally.
      • isDone

        public boolean isDone()
        Description copied from interface: RedisCommand
        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.
        Specified by:
        isDone in interface RedisCommand<K,​V,​T>
        Returns:
        true if this task completed.