
com.lambdaworks.redis.protocol.RedisCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lettuce Show documentation
Show all versions of lettuce Show documentation
Advanced and thread-safe Java Redis client for synchronous, asynchronous, and
reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs
and much more.
The newest version!
/*
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lambdaworks.redis.protocol;
import com.lambdaworks.redis.output.CommandOutput;
import io.netty.buffer.ByteBuf;
/**
* 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.
*
* @author Mark Paluch
* @param Key type.
* @param Value type.
* @param Output type.
* @since 3.0
*/
public interface RedisCommand {
/**
* The command output. Can be null.
*
* @return the command output.
*/
CommandOutput getOutput();
/**
* Complete a command.
*/
void complete();
/**
* Cancel a command.
*/
void cancel();
/**
*
* @return the current command args
*/
CommandArgs getArgs();
/**
*
* @param throwable the exception
* @return {@code true} if this invocation caused this CompletableFuture to transition to a completed state, else
* {@code false}
*/
boolean completeExceptionally(Throwable throwable);
/**
*
* @return the redis command type like {@literal SADD}, {@literal HMSET}, {@literal QUIT}.
*/
ProtocolKeyword getType();
/**
* Encode the command.
*
* @param buf byte buffer to operate on.
*/
void encode(ByteBuf buf);
/**
*
* @return true if the command is cancelled.
*/
boolean isCancelled();
/**
*
* @return true if the command is completed.
*/
boolean isDone();
/**
* Set a new output. Only possible as long as the command is not completed/cancelled.
*
* @param output the new command output
* @throws IllegalStateException if the command is cancelled/completed
*/
void setOutput(CommandOutput output);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy