You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `redisCommand()` and `redisCommandArgv()` functions return
113
+
a pointer to a `redisReply` object. This type supports all
114
+
reply formats defined in the
115
+
[RESP2 and RESP3]({{< relref "/develop/reference/protocol-spec#resp-protocol-description" >}})
116
+
protocols, so its content varies greatly between calls.
117
+
118
+
You can find the reply format for a command at the end of its
119
+
reference page in the RESP2/RESP3 Reply section (for example, the
120
+
[`INCRBY`]({{< relref "/commands/incrby" >}}) page shows that the
121
+
command has an integer result). You can also determine the format
122
+
using the `type` field of the reply object. This contains a
123
+
different integer value for each type, and `hiredis.h` defines
124
+
constants for each type (for example `REDIS_REPLY_STRING`).
125
+
126
+
The `redisReply` struct has several fields to contain different
127
+
types of replies, with different fields being set depending on
128
+
the value of the `type` field. The table below shows the type
129
+
constants, the corresponding reply type, and the fields you can
130
+
use to access the reply value:
131
+
132
+
| Constant | Type | Relevant fields of `redisReply`| RESP protocol |
133
+
| :- | :- |:- | :- |
134
+
|`REDIS_REPLY_STATUS`|[Simple string]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) |`reply->str`: the string value (`char*`)<br/> `reply->len`: the string length (`size_t`) | 2 |
135
+
|`REDIS_REPLY_ERROR`|[Simple string]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) |`reply->str`: the string value (`char*`)<br/> `reply->len`: the string length (`size_t`) | 2 |
136
+
|`REDIS_REPLY_INTEGER`|[Integer]({{< relref "/develop/reference/protocol-spec#integers" >}}) |`reply->integer`: the integer value (`long long`)| 2 |
137
+
|`REDIS_REPLY_NIL`|[Null]({{< relref "/develop/reference/protocol-spec#nulls" >}}) | No data | 2 |
138
+
|`REDIS_REPLY_STRING`|[Bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) |`reply->str`: the string value (`char*`)<br/> `reply->len`: the string length (`size_t`) | 2 |
139
+
|`REDIS_REPLY_ARRAY`|[Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) |`reply->elements`: number of elements (`size_t`)<br/> `reply->element`: array elements (`redisReply`) | 2 |
0 commit comments