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

Function moduleReplicateMultiIfNeeded

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

Helper function to replicate MULTI the first time we replicate something * in the context of a command execution. EXEC will be handled by the * RedisModuleCommandDispatcher() function. */

Source from the content-addressed store, hash-verified

1741 * in the context of a command execution. EXEC will be handled by the
1742 * RedisModuleCommandDispatcher() function. */
1743void moduleReplicateMultiIfNeeded(RedisModuleCtx *ctx) {
1744 /* Skip this if client explicitly wrap the command with MULTI, or if
1745 * the module command was called by a script. */
1746 if (server.in_eval || server.in_exec) return;
1747 /* If we already emitted MULTI return ASAP. */
1748 if (server.propagate_in_transaction) return;
1749 /* If this is a thread safe context, we do not want to wrap commands
1750 * executed into MULTI/EXEC, they are executed as single commands
1751 * from an external client in essence. */
1752 if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) return;
1753 /* If this is a callback context, and not a module command execution
1754 * context, we have to setup the op array for the "also propagate" API
1755 * so that RM_Replicate() will work. */
1756 if (!(ctx->flags & REDISMODULE_CTX_MODULE_COMMAND_CALL)) {
1757 serverAssert(ctx->saved_oparray.ops == NULL);
1758 ctx->saved_oparray = server.also_propagate;
1759 redisOpArrayInit(&server.also_propagate);
1760 }
1761 execCommandPropagateMulti(ctx->client->db->id);
1762 ctx->flags |= REDISMODULE_CTX_MULTI_EMITTED;
1763}
1764
1765/* Replicate the specified command and arguments to slaves and AOF, as effect
1766 * of execution of the calling command implementation.

Callers 2

RM_ReplicateFunction · 0.85
RM_CallFunction · 0.85

Calls 2

redisOpArrayInitFunction · 0.85

Tested by

no test coverage detected