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

Function getkeys_command

app/redis-6.2.6/tests/modules/getkeys.c:14–46  ·  view source on GitHub ↗

A sample movable keys command that returns a list of all * arguments that follow a KEY argument, i.e. */

Source from the content-addressed store, hash-verified

12 * arguments that follow a KEY argument, i.e.
13 */
14int getkeys_command(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
15{
16 int i;
17 int count = 0;
18
19 /* Handle getkeys-api introspection */
20 if (RedisModule_IsKeysPositionRequest(ctx)) {
21 for (i = 0; i < argc; i++) {
22 size_t len;
23 const char *str = RedisModule_StringPtrLen(argv[i], &len);
24
25 if (len == 3 && !strncasecmp(str, "key", 3) && i + 1 < argc)
26 RedisModule_KeyAtPos(ctx, i + 1);
27 }
28
29 return REDISMODULE_OK;
30 }
31
32 /* Handle real command invocation */
33 RedisModule_ReplyWithArray(ctx, REDISMODULE_POSTPONED_ARRAY_LEN);
34 for (i = 0; i < argc; i++) {
35 size_t len;
36 const char *str = RedisModule_StringPtrLen(argv[i], &len);
37
38 if (len == 3 && !strncasecmp(str, "key", 3) && i + 1 < argc) {
39 RedisModule_ReplyWithString(ctx, argv[i+1]);
40 count++;
41 }
42 }
43 RedisModule_ReplySetArrayLength(ctx, count);
44
45 return REDISMODULE_OK;
46}
47
48int getkeys_fixed(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
49{

Callers

nothing calls this directly

Calls 1

strncasecmpFunction · 0.85

Tested by

no test coverage detected