Package io.lettuce.core.output
Class CommandOutput<K,V,T>
- 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
,KeyValueListScoredValueOutput
,KeyValueOfScoredValueOutput
,KeyValueOutput
,KeyValueScoredValueOutput
,KeyValueStreamingOutput
,KeyValueValueListOutput
,ListOfGenericMapsOutput
,ListOfMapsOutput
,MapOutput
,MultiOutput
,NestedMultiOutput
,ObjectOutput
,PendingMessageListOutput
,PendingMessagesOutput
,PubSubOutput
,ReplayOutput
,ScanOutput
,ScoredValueListOutput
,ScoredValueOutput
,ScoredValueStreamingOutput
,SocketAddressOutput
,StatusOutput
,StreamMessageListOutput
,StreamReadOutput
,StringListOutput
,StringMatchResultOutput
,StringValueListOutput
,TransformingOutput
,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 aStreamingOutput.Subscriber
.- Author:
- Will Glozer, Mark Paluch
-
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete(int depth)
Mark the command output complete.protected String
decodeAscii(ByteBuffer bytes)
T
get()
Get the command output.String
getError()
Get the error that occurred.boolean
hasError()
Check if the command resulted in an error.void
multi(int count)
Mark the beginning of a multi sequence (array).void
multiArray(int count)
Mark the beginning of a multi sequence (array).void
multiMap(int count)
Mark the beginning of a multi sequence (map).void
multiPush(int count)
Mark the beginning of a multi sequence (push-array).void
multiSet(int count)
Mark the beginning of a set.void
set(boolean value)
Update the command output with a boolean.void
set(double number)
Update the command output with a floating-point number.void
set(long integer)
Update the command output with a 64-bit signed integer.void
set(ByteBuffer bytes)
Update the command output with a sequence of bytes, ornull
.void
setBigNumber(ByteBuffer bytes)
Update the command output with a big number.void
setError(String error)
Set command output to an error message from the client.void
setError(ByteBuffer error)
Set command output to an error message from the server.void
setSingle(ByteBuffer bytes)
Update the command output with a sequence of bytes, ornull
representing a simple string.String
toString()
-
-
-
Field Detail
-
codec
protected final RedisCodec<K,V> codec
-
output
protected T output
-
error
protected String error
-
-
Constructor Detail
-
CommandOutput
public CommandOutput(RedisCodec<K,V> codec, T output)
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 Detail
-
get
public T get()
Get the command output.- Returns:
- The command output.
-
set
public void set(ByteBuffer bytes)
Update the command output with a sequence of bytes, ornull
. ConcreteCommandOutput
implementations must override this method to decodebulk
/bytes response values.- Parameters:
bytes
- The command output, or null.
-
setSingle
public void setSingle(ByteBuffer bytes)
Update the command output with a sequence of bytes, ornull
representing a simple string. ConcreteCommandOutput
implementations must override this method to decodesingle
/bytes response values.- Parameters:
bytes
- The command output, or null.
-
setBigNumber
public void setBigNumber(ByteBuffer bytes)
Update the command output with a big number. ConcreteCommandOutput
implementations must override this method to decodebig number
response 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. ConcreteCommandOutput
implementations 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. ConcreteCommandOutput
implementations must override this method to decodedouble
response values.- Parameters:
number
- The command output.- Since:
- 6.0/RESP 3
-
set
public void set(boolean value)
Update the command output with a boolean. ConcreteCommandOutput
implementations must override this method to decodeboolean
response values.- Parameters:
value
- The command output.- Since:
- 6.0/RESP 3
-
setError
public void setError(ByteBuffer error)
Set command output to an error message from the server.- Parameters:
error
- Error message.
-
setError
public void setError(String error)
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
public String 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
protected String decodeAscii(ByteBuffer bytes)
-
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
-
-