Skip to content

Commit 16438cb

Browse files
Better MUTLI EXEC explanation
1 parent 432bb95 commit 16438cb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cluster.markdown

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ Consider the following example:
8383
// Cluster is put into MULTI state locally
8484
$obj_cluster->multi();
8585

86-
for ($i = 0; $i < 10; $i++) {
87-
// MULTI will be delivered only once per node
88-
$obj_cluster->get("key:$i");
89-
}
86+
// The cluster will issue MULTI on this node first (and only once)
87+
$obj_cluster->get("mykey");
88+
$obj_cluster->set("mykey", "new_value");
89+
90+
// If 'myotherkey' maps to a different node, MULTI will be issued there
91+
// before requesting the key
92+
$obj_cluster->get("myotherkey");
9093

91-
// This always returns an array of 10 elements, of which some could be false
92-
// (for example if a slot had been migrated)
94+
// This will always return an array, even in the event of a failed transaction
95+
// on one of the nodes, in which case that element will be FALSE
9396
print_r($obj_cluster->exec());
9497
</pre>
9598

0 commit comments

Comments
 (0)