MCPcopy Create free account
hub / github.com/F-Stack/f-stack / georadiusGetKeys

Function georadiusGetKeys

app/redis-6.2.6/src/db.c:1794–1826  ·  view source on GitHub ↗

Helper function to extract keys from following commands: * GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC] * [COUNT count] [STORE key] [STOREDIST key] * GEORADIUSBYMEMBER key member radius unit ... options ... */

Source from the content-addressed store, hash-verified

1792 * [COUNT count] [STORE key] [STOREDIST key]
1793 * GEORADIUSBYMEMBER key member radius unit ... options ... */
1794int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
1795 int i, num, *keys;
1796 UNUSED(cmd);
1797
1798 /* Check for the presence of the stored key in the command */
1799 int stored_key = -1;
1800 for (i = 5; i < argc; i++) {
1801 char *arg = argv[i]->ptr;
1802 /* For the case when user specifies both "store" and "storedist" options, the
1803 * second key specified would override the first key. This behavior is kept
1804 * the same as in georadiusCommand method.
1805 */
1806 if ((!strcasecmp(arg, "store") || !strcasecmp(arg, "storedist")) && ((i+1) < argc)) {
1807 stored_key = i+1;
1808 i++;
1809 }
1810 }
1811 num = 1 + (stored_key == -1 ? 0 : 1);
1812
1813 /* Keys in the command come from two places:
1814 * argv[1] = key,
1815 * argv[5...n] = stored key if present
1816 */
1817 keys = getKeysPrepareResult(result, num);
1818
1819 /* Add all key positions to keys[] */
1820 keys[0] = 1;
1821 if(num > 1) {
1822 keys[1] = stored_key;
1823 }
1824 result->numkeys = num;
1825 return num;
1826}
1827
1828/* LCS ... [KEYS <key1> <key2>] ... */
1829int lcsGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {

Callers

nothing calls this directly

Calls 2

strcasecmpFunction · 0.85
getKeysPrepareResultFunction · 0.85

Tested by

no test coverage detected