HRANDFIELD key [ [WITHVALUES]] */
| 1182 | |
| 1183 | /* HRANDFIELD key [<count> [WITHVALUES]] */ |
| 1184 | void hrandfieldCommand(client *c) { |
| 1185 | long l; |
| 1186 | int withvalues = 0; |
| 1187 | robj *hash; |
| 1188 | ziplistEntry ele; |
| 1189 | |
| 1190 | if (c->argc >= 3) { |
| 1191 | if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return; |
| 1192 | if (c->argc > 4 || (c->argc == 4 && strcasecmp(c->argv[3]->ptr,"withvalues"))) { |
| 1193 | addReplyErrorObject(c,shared.syntaxerr); |
| 1194 | return; |
| 1195 | } else if (c->argc == 4) |
| 1196 | withvalues = 1; |
| 1197 | hrandfieldWithCountCommand(c, l, withvalues); |
| 1198 | return; |
| 1199 | } |
| 1200 | |
| 1201 | /* Handle variant without <count> argument. Reply with simple bulk string */ |
| 1202 | if ((hash = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]))== NULL || |
| 1203 | checkType(c,hash,OBJ_HASH)) { |
| 1204 | return; |
| 1205 | } |
| 1206 | |
| 1207 | hashTypeRandomElement(hash,hashTypeLength(hash),&ele,NULL); |
| 1208 | hashReplyFromZiplistEntry(c, &ele); |
| 1209 | } |
nothing calls this directly
no test coverage detected