标签:check sch val err cache 商品 als div logger
//检查两个多维数组 是否一直
public function foo($arr, &$rt , $key=‘‘ ,$i=0) { if (is_array($arr)) { foreach ($arr as $k=>$v) { if (is_array($v)) { $this->foo($v ,$rt ,$k ,$i); } else { $rt[$key.‘->‘.$k.$i] = $v; } $i++; } } return $rt; }
/**
* 商品信息缓存一致性检查
* @param $productId
* @return bool
*/
public function checkProductAttach($productId)
{
$getAttach = $this->productService->getAttach($productId);
$getProductAttach = $this->productService->getProductAttach($productId);
if($getProductAttach == false){
Yii::$app->dataCache->getRedis()->del([‘PRODUCT_ATTACH‘, $productId]);
return true;
}
$isSame = $this->isSame($getAttach ,$getProductAttach );
$arr = [];
$arrCache = $this->foo($getAttach,$arr);
$arrService = $this->foo($getProductAttach,$arr);
$result = [‘isSame‘=>$isSame,‘diff‘=>array_diff($arrService, $arrCache)];
if($isSame==false){
Yii::getLogger()->log([‘errorkey‘ => ‘RedisCheckError:‘.$productId , ‘errorvalue‘ => json_encode($result[‘diff‘])], Logger::LEVEL_ERROR);
}
return $result;
}
标签:check sch val err cache 商品 als div logger
原文地址:http://www.cnblogs.com/-mrl/p/6438889.html