Commit 9604c3f1 by 杨树贤

修改品牌获取缓存

parent 0645735f
Showing with 18 additions and 0 deletions
......@@ -64,6 +64,24 @@ class SelfBrandModel extends Model
//先去缓存里面取
$Redis = new RedisModel;
$brandList = $Redis->hgetall('Self_Brand');
$brandList = array_map(function ($value) {
return json_decode($value, true);
}, $brandList);
//如果要有地区筛选,则需要做数据处理
if (!empty($map['brand_area']) && !empty($brandList)) {
$brandListByArea = [];
$areaIds = explode(',', $map['brand_area']);
foreach ($brandList as $key => $brand) {
if (in_array($brand['brand_area'], $areaIds)) {
$brandListByArea[] = $brand;
}
}
return $brandListByArea;
}
//没有就去数据库里面取
if (!$brandList) {
return Cache::remember('brandList_' . json_encode($map), $expireMinutes, function () use ($map) {
$field = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment