XREAD [BLOCK ] [COUNT ] [GROUP ] * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */
| 1868 | /* XREAD [BLOCK <milliseconds>] [COUNT <count>] [GROUP <groupname> <ttl>] |
| 1869 | * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */ |
| 1870 | int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 1871 | int i, num = 0, *keys; |
| 1872 | UNUSED(cmd); |
| 1873 | |
| 1874 | /* We need to parse the options of the command in order to seek the first |
| 1875 | * "STREAMS" string which is actually the option. This is needed because |
| 1876 | * "STREAMS" could also be the name of the consumer group and even the |
| 1877 | * name of the stream key. */ |
| 1878 | int streams_pos = -1; |
| 1879 | for (i = 1; i < argc; i++) { |
| 1880 | char *arg = argv[i]->ptr; |
| 1881 | if (!strcasecmp(arg, "block")) { |
| 1882 | i++; /* Skip option argument. */ |
| 1883 | } else if (!strcasecmp(arg, "count")) { |
| 1884 | i++; /* Skip option argument. */ |
| 1885 | } else if (!strcasecmp(arg, "group")) { |
| 1886 | i += 2; /* Skip option argument. */ |
| 1887 | } else if (!strcasecmp(arg, "noack")) { |
| 1888 | /* Nothing to do. */ |
| 1889 | } else if (!strcasecmp(arg, "streams")) { |
| 1890 | streams_pos = i; |
| 1891 | break; |
| 1892 | } else { |
| 1893 | break; /* Syntax error. */ |
| 1894 | } |
| 1895 | } |
| 1896 | if (streams_pos != -1) num = argc - streams_pos - 1; |
| 1897 | |
| 1898 | /* Syntax error. */ |
| 1899 | if (streams_pos == -1 || num == 0 || num % 2 != 0) { |
| 1900 | result->numkeys = 0; |
| 1901 | return 0; |
| 1902 | } |
| 1903 | num /= 2; /* We have half the keys as there are arguments because |
| 1904 | there are also the IDs, one per key. */ |
| 1905 | |
| 1906 | keys = getKeysPrepareResult(result, num); |
| 1907 | for (i = streams_pos+1; i < argc-num; i++) keys[i-streams_pos-1] = i; |
| 1908 | result->numkeys = num; |
| 1909 | return num; |
| 1910 | } |
| 1911 | |
| 1912 | /* Slot to Key API. This is used by Redis Cluster in order to obtain in |
| 1913 | * a fast way a key that belongs to a specified hash slot. This is useful |
nothing calls this directly
no test coverage detected