Authored by hf

code review by hf: do format channel code add exception handle

... ... @@ -374,7 +374,7 @@ class HomeModel
}
$result['channelList'][] = $build;
}
}
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
... ... @@ -386,6 +386,34 @@ class HomeModel
Cache::set($key, $result);
}
}
// 当接口和缓存都挂了时候,返回静态的数据
if (empty($result)) {
$result = array(
'channelList' => array(
array(
'href' => '/boys',
'title' => '男生',
'entitle' => 'BOYS',
),
array(
'href' => '/girls',
'title' => '女生',
'entitle' => 'GIRLS',
),
array(
'href' => '/kids',
'title' => '潮童',
'entitle' => 'KIDS',
),
array(
'href' => '/lifestyle',
'title' => '创意生活',
'entitle' => 'LIFESTYLE',
),
)
);
}
return $result;
}
... ...