<?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
.