The
redisResponse type makes it possible to define all the advanced characteristics of a response received by
RedisExecuteCommand or
RedisPipelineGet. The characteristics of this response can be known using different WLanguage properties.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see
Declaring a variable.
INTERNAL PROCEDURE DisplayResult (r is redisResponse, sIdent="")
SWITCH r.Type
CASE redisTypeInt
Trace(sIdent + "integer: " + r.Integer)
CASE redisTypeError
Trace(sIdent + "error: " + r.String)
CASE redisTypeStatus
Trace(sIdent + "status: " + r.String)
CASE redisTypeNil
Trace(sIdent + "Nil")
CASE redisTypeArray
Trace(sIdent + "array: ")
FOR EACH r2 OF r.Array
ShowResponse(r2, sIdent + TAB)
END
CASE redisTypeBuffer
Trace(sIdent + "buffer in string: " + r.String)
Trace(sIdent + "buffer in hexa: " + BufferToHexa(r.Buffer))
END
END
r1 is redisResponse = RedisExecuteCommand(gRedis, "GET keyString")
DisplayResult(r1)
Remarks
Properties specific to redisResponse variables
The following properties can be used to handle a Redis response:
| | |
Property name | Type used | Effect |
---|
Array | Array of redisResponse | If the Type property corresponds to the redisTypeArray constant, this property contains an array of redisResponse variables. |
Buffer | Buffer | Binary value if the Type property corresponds to the redisTypeBuffer constant. This property is read-only. |
Integer | Integer | Integer value if the Type property corresponds to the redisTypeInt constant. This property is read-only. |
String | Character string | - If the Type property corresponds to the redisTypeStatus constant, it contains the string corresponding to the returned state.
- If the Type property corresponds to the redisTypeError constant, it contains the error message.
- If the Type property corresponds to the redisTypeBuffer constant, it contains the buffer converted to a string using UTF-8 encoding.
This property is read-only. |
Type | Integer | Type of the result. This type can correspond to one of the following constants: - redisTypeBuffer: The result corresponds to a buffer.
- redisTypeInt: The result corresponds to an integer.
- redisTypeError: The result corresponds to an error.
- redisTypeNil: The result has no value.
- redisTypeStatus: The result corresponds to a status.
- redisTypeArray: The result corresponds to an array.
This property is read-only. |
WLanguage functions that use the redisResponse type