Interface Response
- simple string - C string
- integer - 64bit integer value
- bulk - byte array
- multi - list
Due to the dynamic nature the response object will try to cast the received response to the desired type. A special case should be noted that multi responses are also handled by the response object as it implements the iterable interface. So in this case constructs like for loops on the response will give you access to the underlying elements.
- Author:
- Paulo Lopes
-
Method Summary
Modifier and TypeMethodDescriptionRESP3 responses may include attributesdefault booleancontainsKey(Buffer key) Check if this Multi response contains a binary key.default booleancontainsKey(String key) Does this multi response contains a string key.default Stringformat()RESP3 Verbatim Bulk message include a 3 character format.default Responseget(int index) Get this multi response value at a numerical index.default ResponseGet this Multi response value at a binary key.default ResponseGet this multi response value at a string key.Get binary keys of this multi response.getKeys()Get this multi response keys from a hash.default booleanisArray()Returns whether this multi response is an array and henceget(int)can be called.default booleanisMap()Returns whether this multi response is a map and henceget(String),containsKey(String)andgetKeys()may be called.iterator()Return an iterator so it can be iterated using the foreach construct.default intsize()Get the size of this multi response, which is the number of elements in the array.stream()Return a stream of responses based on the iterable of this object.default BigIntegerGet this response as a BigInteger.default BooleanGet this response as a Boolean.default BuffertoBuffer()Get this response as Buffer.default BytetoByte()Get this response as a Byte.default byte[]toBytes()Get this response as a byte[].default DoubletoDouble()Get this response as a Double.default FloattoFloat()Get this response as a Float.default IntegerGet this response as a Integer.default LongtoLong()Get this response as a Long.default NumbertoNumber()Get this response as a Number.default ShorttoShort()Get this response as a Short.toString()Get this response as a String.default StringGet this response as a String encoded with the given charset.type()The response return type.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
type
-
attributes
-
toString
-
format
RESP3 Verbatim Bulk message include a 3 character format. -
toNumber
Get this response as a Number. In contrast to other numeric getters, this will not perform any conversion if the underlying type is not numeric.- Returns:
- number value
-
toDouble
-
toFloat
-
toBigInteger
-
toLong
-
toInteger
-
toShort
-
toByte
-
toBoolean
-
toString
-
toBuffer
-
toBytes
default byte[] toBytes()Get this response as a byte[].- Returns:
- byte[] value.
-
get
Get this multi response value at a numerical index.- Parameters:
index- the required index.- Returns:
- Response value.
-
get
-
containsKey
Does this multi response contains a string key. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.- Parameters:
key- the required key.- Returns:
- Response value.
-
getKeys
-
get
Get this Multi response value at a binary key.This is a variant of
get(String)that accepts binary keys. Use this method when the map contains binary keys that may not be interpreted as valid UTF-8 chars. For example, redis HASH with binary field names like UUIDs, IPs in binary form, hashes of some data, etc.- Parameters:
key- the required key.- Returns:
- Response value.
-
containsKey
Check if this Multi response contains a binary key.This is a variant of
containsKey(String)that accepts binary keys. Use this method when the map contains binary keys that may not be interpreted as valid UTF-8 chars. For example, redis HASH with binary field names like UUIDs, IPs in binary form, hashes of some data, etc.- Parameters:
key- the required key.- Returns:
- whether the response contains the key.
-
getBinaryKeys
Get binary keys of this multi response.This is a variant of
getKeys()that returns binary keys. Use this method when the map contains binary keys that may not be interpreted as valid UTF-8 chars. For example, redis HASH with binary field names like UUIDs, IPs in binary form, hashes of some data, etc.- Returns:
- the set of binary keys.
-
size
default int size()Get the size of this multi response, which is the number of elements in the array. In case of a map, it is the number of keys plus the number of values, or in other words twice the number of key/value mappings.- Returns:
- the size of the multi.
-
isArray
default boolean isArray()Returns whether this multi response is an array and henceget(int)can be called.Returns
truealso forResponseType.PUSHandResponseType.ATTRIBUTE.- Returns:
- whether this multi response is an array
-
isMap
default boolean isMap()Returns whether this multi response is a map and henceget(String),containsKey(String)andgetKeys()may be called.Returns
truealso forResponseType.ATTRIBUTE.- Returns:
- whether this multi response is a map
-
iterator
-
stream
-