A sample movable keys command that returns a list of all * arguments that follow a KEY argument, i.e. */
| 12 | * arguments that follow a KEY argument, i.e. |
| 13 | */ |
| 14 | int 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 | |
| 48 | int getkeys_fixed(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) |
| 49 | { |
nothing calls this directly
no test coverage detected