code review by fei.hong: do format guang plusstar codes
Showing
1 changed file
with
12 additions
and
15 deletions
@@ -51,25 +51,22 @@ class PlusstarModel | @@ -51,25 +51,22 @@ class PlusstarModel | ||
51 | } | 51 | } |
52 | 52 | ||
53 | $result = array(); | 53 | $result = array(); |
54 | + | ||
54 | $brandList = PlusstarData::firstBrandList($gender, $channel); | 55 | $brandList = PlusstarData::firstBrandList($gender, $channel); |
55 | - if (!empty($brandList['recom']['data']['list'][0]['data'])) { | ||
56 | - $result['ps']['star'] = self::formatData($brandList['recom']['data']['list'][0]['data'], $gender, true); | ||
57 | - //$result['ps']['sName'] = isset($brandList['recom']['data']['brand_type_name']) ? $brandList['recom']['data']['brand_type_name'] : ''; | ||
58 | - } | ||
59 | - if (!empty($brandList['all']['data']['list'][0]['data'])) { | ||
60 | - $result['ps']['plus'] = self::formatData($brandList['all']['data']['list'][0]['data'], $gender, true); | ||
61 | - //$result['ps']['pName'] = isset($brandList['all']['data']['brand_type_name']) ? $brandList['all']['data']['brand_type_name'] : ''; | 56 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. |
57 | + if (empty($brandList['recom']['data']['list'][0]['data']) || empty($brandList['all']['data']['list'][0]['data'])) { | ||
58 | + if (USE_CACHE) { | ||
59 | + $result = Cache::get($key, 'slave'); | ||
60 | + } | ||
61 | + return $result; | ||
62 | } | 62 | } |
63 | + | ||
64 | + $result['ps']['star'] = self::formatData($brandList['recom']['data']['list'][0]['data'], $gender, true); | ||
65 | + $result['ps']['plus'] = self::formatData($brandList['all']['data']['list'][0]['data'], $gender, true); | ||
63 | 66 | ||
67 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
64 | if (USE_CACHE) { | 68 | if (USE_CACHE) { |
65 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
66 | - if (empty($result)) { | ||
67 | - $result = Cache::get($key, 'slave'); | ||
68 | - } | ||
69 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
70 | - else { | ||
71 | - Cache::set($key, $result); | ||
72 | - } | 69 | + Cache::set($key, $result); |
73 | } | 70 | } |
74 | 71 | ||
75 | return $result; | 72 | return $result; |
-
Please register or login to post a comment