Can I use zrank to determine whether the key exists after the REDIS-pipeline pipe is turned on?

<?php 
$redis->pipeline();
            if(count($productIds) > 1){
                foreach($productIds as $key=>$productId)
                {
                    foreach($productIds as $k => $memberId){
                        if($productId == $memberId){
                            continue;
                        }
                        //, 
                        if($redis->ZRANK(SELF::PRODUCT_RALATION_KEY_PREFIX.$productId,$memberId) !== FALSE){
                            //,  +1
                            $redis->ZINCRBY(SELF::PRODUCT_RALATION_KEY_PREFIX.$productId,1,$memberId);
                        }else{
                            //,  member
                            $redis->ZADD(SELF::PRODUCT_RALATION_KEY_PREFIX.$productId,1,$memberId);
                        }
                    }
                }
            }
$redis->exec();

put the code first, and now we are doing a commodity correlation data to be saved to redis. When two items appear in the order at the same time, create a zset for each item, and then the two items in the subsequent order appear at the same time. Is this logic feasible with pipeline? I haven"t found the relevant information for a long time. Ask for an explanation

.
Apr.01,2022

pipeline reduces network overhead by sending multiple redis operation commands in one network request. You can send the final command to be executed in your business code and then send it to pipeline to execute


No. In redis pipeline mode (actually multi mode), the return value is fixed, the redis object, not the actual execution result of the command.
therefore, conditional branching logic cannot be implemented in pipeline and multi.

Menu