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
| 1577 | * |
| 1578 | * The function always returns REDISMODULE_OK. */ |
| 1579 | int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { |
| 1580 | client *c = moduleGetReplyClient(ctx); |
| 1581 | AeLocker locker; |
| 1582 | |
| 1583 | if (c == NULL) return REDISMODULE_OK; |
| 1584 | std::unique_lock<fastlock> lock(c->lock); |
| 1585 | locker.arm(c); |
| 1586 | if (len == REDISMODULE_POSTPONED_ARRAY_LEN) { |
| 1587 | ctx->postponed_arrays = (void**)zrealloc(ctx->postponed_arrays,sizeof(void*)* |
| 1588 | (ctx->postponed_arrays_count+1), MALLOC_LOCAL); |
| 1589 | ctx->postponed_arrays[ctx->postponed_arrays_count] = |
| 1590 | addReplyDeferredLen(c); |
| 1591 | ctx->postponed_arrays_count++; |
| 1592 | } else { |
| 1593 | addReplyArrayLen(c,len); |
| 1594 | } |
| 1595 | return REDISMODULE_OK; |
| 1596 | } |
| 1597 | |
| 1598 | /* Reply to the client with a null array, simply null in RESP3 |
| 1599 | * null array in RESP2. |
nothing calls this directly
no test coverage detected