Skip to content

Commit 9eaf147

Browse files
Don't attempt MGET on nodes where no keys resolve
The MGET call in RedisArray was failing under circumstances where none of the passed keys hashed into any given node in the ring. What was happening is that RedisArray was passing through to the phpredis MGET command an empty array, which was returning false. This in turn caused RedisArray to abort the process and return false as well. This change updates RedisArray MGET such that if a given node doesn't have any keys, we skip the call to it all together. Addresses phpredis#435 Addresses phpredis#436
1 parent 43b35a4 commit 9eaf147

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

redis_array.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,10 @@ PHP_METHOD(RedisArray, mget)
876876

877877
/* calls */
878878
for(n = 0; n < ra->count; ++n) { /* for each node */
879-
/* copy args for MGET call on node. */
879+
/* We don't even need to make a call to this node if no keys go there */
880+
if(!argc_each[n]) continue;
881+
882+
/* copy args for MGET call on node. */
880883
MAKE_STD_ZVAL(z_argarray);
881884
array_init(z_argarray);
882885

0 commit comments

Comments
 (0)