XREAD [BLOCK ] [COUNT ] [GROUP ] * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */
| 2417 | /* XREAD [BLOCK <milliseconds>] [COUNT <count>] [GROUP <groupname> <ttl>] |
| 2418 | * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */ |
| 2419 | int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 2420 | int i, num = 0, *keys; |
| 2421 | UNUSED(cmd); |
| 2422 | |
| 2423 | /* We need to parse the options of the command in order to seek the first |
| 2424 | * "STREAMS" string which is actually the option. This is needed because |
| 2425 | * "STREAMS" could also be the name of the consumer group and even the |
| 2426 | * name of the stream key. */ |
| 2427 | int streams_pos = -1; |
| 2428 | for (i = 1; i < argc; i++) { |
| 2429 | char *arg = szFromObj(argv[i]); |
| 2430 | if (!strcasecmp(arg, "block")) { |
| 2431 | i++; /* Skip option argument. */ |
| 2432 | } else if (!strcasecmp(arg, "count")) { |
| 2433 | i++; /* Skip option argument. */ |
| 2434 | } else if (!strcasecmp(arg, "group")) { |
| 2435 | i += 2; /* Skip option argument. */ |
| 2436 | } else if (!strcasecmp(arg, "noack")) { |
| 2437 | /* Nothing to do. */ |
| 2438 | } else if (!strcasecmp(arg, "streams")) { |
| 2439 | streams_pos = i; |
| 2440 | break; |
| 2441 | } else { |
| 2442 | break; /* Syntax error. */ |
| 2443 | } |
| 2444 | } |
| 2445 | if (streams_pos != -1) num = argc - streams_pos - 1; |
| 2446 | |
| 2447 | /* Syntax error. */ |
| 2448 | if (streams_pos == -1 || num == 0 || num % 2 != 0) { |
| 2449 | result->numkeys = 0; |
| 2450 | return 0; |
| 2451 | } |
| 2452 | num /= 2; /* We have half the keys as there are arguments because |
| 2453 | there are also the IDs, one per key. */ |
| 2454 | |
| 2455 | keys = getKeysPrepareResult(result, num); |
| 2456 | for (i = streams_pos+1; i < argc-num; i++) keys[i-streams_pos-1] = i; |
| 2457 | result->numkeys = num; |
| 2458 | return num; |
| 2459 | } |
| 2460 | |
| 2461 | /* Slot to Key API. This is used by Redis Cluster in order to obtain in |
| 2462 | * a fast way a key that belongs to a specified hash slot. This is useful |
nothing calls this directly
no test coverage detected