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

Function RM_ReplyWithArray

app/redis-6.2.6/src/module.c:1549–1562  ·  view source on GitHub ↗

Reply with an array type of 'len' elements. However 'len' other calls * to `ReplyWith*` style functions must follow in order to emit the elements * of the array. * * When producing arrays with a number of element that is not known beforehand * the function can be called with the special count * REDISMODULE_POSTPONED_ARRAY_LEN, and the actual number of elements can be * later set with RedisM

Source from the content-addressed store, hash-verified

1547 *
1548 * The function always returns REDISMODULE_OK. */
1549int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) {
1550 client *c = moduleGetReplyClient(ctx);
1551 if (c == NULL) return REDISMODULE_OK;
1552 if (len == REDISMODULE_POSTPONED_ARRAY_LEN) {
1553 ctx->postponed_arrays = zrealloc(ctx->postponed_arrays,sizeof(void*)*
1554 (ctx->postponed_arrays_count+1));
1555 ctx->postponed_arrays[ctx->postponed_arrays_count] =
1556 addReplyDeferredLen(c);
1557 ctx->postponed_arrays_count++;
1558 } else {
1559 addReplyArrayLen(c,len);
1560 }
1561 return REDISMODULE_OK;
1562}
1563
1564/* Reply to the client with a null array, simply null in RESP3
1565 * null array in RESP2.

Callers

nothing calls this directly

Calls 4

moduleGetReplyClientFunction · 0.85
zreallocFunction · 0.85
addReplyDeferredLenFunction · 0.85
addReplyArrayLenFunction · 0.85

Tested by

no test coverage detected