Authored by whb

添加缓存

... ... @@ -63,6 +63,9 @@ class HomeModel
return array();
}
$menu = array();
$key = sprintf('%s_%s_%s',CacheConfig::KEY_WEB_HOME_NAVBAR_DATA, md5(serialize($data)), $channel);
$menu = Cache::get($key);
if(empty($menu)) {
$item = array();
foreach ($data['data'] as $val) {
$item = array(
... ... @@ -112,6 +115,8 @@ class HomeModel
}
$menu[] = $item;
}
Cache::set($key, $menu, 3600);
}
return $menu;
}
... ... @@ -165,9 +170,14 @@ class HomeModel
*/
public static function getChannelResource($channel, $content_code)
{
$key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.$channel);
$data = Cache::get($key);
if(empty($data)) {
$resource = IndexData::getResourceData($content_code);
// 格式化数据
$data = ChannelProcess::getFormat($channel, $resource['data']);
Cache::set($key, $data, 3600);
}
return $data;
}
... ... @@ -213,6 +223,10 @@ class HomeModel
public static function getNewArrival($channel)
{
$result = array();
$key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
//缓存数据
$result = Cache::get($key);
if(empty($result)) {
$params = array(
'order' => 's_t_desc',
'shelve_time' => strtotime("-60 days") . ',' . time()
... ... @@ -253,6 +267,8 @@ class HomeModel
}
}
}
Cache::set($key, $result, 3600);
}
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -53,7 +53,6 @@ class BackController extends WebAction {
if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱
$email = $phoneNum;
$data = BackData::sendCodeToEmail($email);
if ($data ['code'] == 200) {
$this->setSession('email', $email);
$this->redirect ('sendemail');
... ... @@ -64,7 +63,8 @@ class BackController extends WebAction {
} else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号
$mobile = $phoneNum;
$data = BackData::sendCodeToMobile($mobile, $area);
if ($data ['code'] == 200) {
if ($data['code'] == 200) {
$this->setSession ('mobile', $mobile );
$this->setSession ('area', $area );
$this->setSession ('verifyCode', $verifyCode );
... ... @@ -208,6 +208,8 @@ class BackController extends WebAction {
$this->redirect ( SITE_MAIN . $url );
}
}
//出错直接跳到找回密码页
$this->redirect ('/passport/back/index');
}
/**
... ... @@ -224,4 +226,5 @@ class BackController extends WebAction {
}
return $info;
}
}
\ No newline at end of file
... ...