java.lang.Object
io.lettuce.core.output.CommandOutput<K,V,T>
- Type Parameters:
K- Key type.V- Value type.T- Output type.
- Direct Known Subclasses:
BooleanListOutput,BooleanOutput,ByteArrayOutput,ClaimedMessagesOutput,DateOutput,DoubleListOutput,DoubleOutput,EnumSetOutput,GenericMapOutput,GeoCoordinatesListOutput,GeoCoordinatesValueListOutput,GeoWithinListOutput,IntegerListOutput,IntegerOutput,KeyListOutput,KeyOutput,KeyStreamingOutput,KeyValueListOutput,KeyValueOutput,KeyValueScoredValueOutput,KeyValueStreamingOutput,ListOfGenericMapsOutput,ListOfMapsOutput,MapOutput,MultiOutput,NestedMultiOutput,PendingMessageListOutput,PendingMessagesOutput,PubSubOutput,ReplayOutput,ScanOutput,ScoredValueListOutput,ScoredValueOutput,ScoredValueStreamingOutput,SocketAddressOutput,StatusOutput,StreamMessageListOutput,StreamReadOutput,StringListOutput,StringMatchResultOutput,StringValueListOutput,ValueListOutput,ValueOutput,ValueSetOutput,ValueStreamingOutput,ValueValueListOutput,VoidOutput
public abstract class CommandOutput<K,V,T> extends Object
Base class for Redis command outputs.
Provides common decode methods and parsing functionality for output handling. Template methods that accept response values
throw UnsupportedOperationException unless overridden by the concrete implementation.
Command outputs may accumulate their state until a command is finished or emit partial results during the decode process.
Output implementations that wish to emit partial results can implement StreamingOutput push individual output
elements to a StreamingOutput.Subscriber.
- Author:
- Will Glozer, Mark Paluch
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CommandOutput(RedisCodec<K,V> codec, T output)Initialize a new instance that encodes and decodes keys and values using the supplied codec. -
Method Summary
Modifier and Type Method Description voidcomplete(int depth)Mark the command output complete.protected StringdecodeAscii(ByteBuffer bytes)Tget()Get the command output.StringgetError()Get the error that occurred.booleanhasError()Check if the command resulted in an error.voidmulti(int count)Mark the beginning of a multi sequence (array).voidmultiArray(int count)Mark the beginning of a multi sequence (array).voidmultiMap(int count)Mark the beginning of a multi sequence (map).voidmultiPush(int count)Mark the beginning of a multi sequence (push-array).voidmultiSet(int count)Mark the beginning of a set.voidset(boolean value)Update the command output with a boolean.voidset(double number)Update the command output with a floating-point number.voidset(long integer)Update the command output with a 64-bit signed integer.voidset(ByteBuffer bytes)Update the command output with a sequence of bytes, ornull.voidsetBigNumber(ByteBuffer bytes)Update the command output with a big number.voidsetError(String error)Set command output to an error message from the client.voidsetError(ByteBuffer error)Set command output to an error message from the server.voidsetSingle(ByteBuffer bytes)Update the command output with a sequence of bytes, ornullrepresenting a simple string.StringtoString()
-
Field Details
-
codec
-
output
-
error
-
-
Constructor Details
-
CommandOutput
Initialize a new instance that encodes and decodes keys and values using the supplied codec.- Parameters:
codec- Codec used to encode/decode keys and values, must not benull.output- Initial value of output.
-
-
Method Details
-
get
Get the command output.- Returns:
- The command output.
-
set
Update the command output with a sequence of bytes, ornull. ConcreteCommandOutputimplementations must override this method to decodebulk/bytes response values.- Parameters:
bytes- The command output, or null.
-
setSingle
Update the command output with a sequence of bytes, ornullrepresenting a simple string. ConcreteCommandOutputimplementations must override this method to decodesingle/bytes response values.- Parameters:
bytes- The command output, or null.
-
setBigNumber
Update the command output with a big number. ConcreteCommandOutputimplementations must override this method to decodebig numberresponse values.- Parameters:
bytes- The command output, or null.- Since:
- 6.0/RESP 3
-
set
public void set(long integer)Update the command output with a 64-bit signed integer. ConcreteCommandOutputimplementations must override this method to decodenumber(integer) response values.- Parameters:
integer- The command output.
-
set
public void set(double number)Update the command output with a floating-point number. ConcreteCommandOutputimplementations must override this method to decodedoubleresponse values.- Parameters:
number- The command output.- Since:
- 6.0/RESP 3
-
set
public void set(boolean value)Update the command output with a boolean. ConcreteCommandOutputimplementations must override this method to decodebooleanresponse values.- Parameters:
value- The command output.- Since:
- 6.0/RESP 3
-
setError
Set command output to an error message from the server.- Parameters:
error- Error message.
-
setError
Set command output to an error message from the client.- Parameters:
error- Error message.
-
hasError
public boolean hasError()Check if the command resulted in an error.- Returns:
- true if command resulted in an error.
-
getError
Get the error that occurred.- Returns:
- The error.
-
complete
public void complete(int depth)Mark the command output complete.- Parameters:
depth- Remaining depth of output queue.
-
decodeAscii
-
toString
-
multi
public void multi(int count)Mark the beginning of a multi sequence (array).- Parameters:
count- expected number of elements in this multi sequence.
-
multiArray
public void multiArray(int count)Mark the beginning of a multi sequence (array).- Parameters:
count- expected number of elements in this multi sequence.- Since:
- 6.0/RESP 3
-
multiPush
public void multiPush(int count)Mark the beginning of a multi sequence (push-array).- Parameters:
count- expected number of elements in this multi sequence.- Since:
- 6.0/RESP 3
-
multiMap
public void multiMap(int count)Mark the beginning of a multi sequence (map).- Parameters:
count- expected number of elements in this multi sequence.- Since:
- 6.0/RESP 3
-
multiSet
public void multiSet(int count)Mark the beginning of a set.- Parameters:
count- expected number of elements in this multi sequence.- Since:
- 6.0/RESP 3
-