Authored by whb

添加缓存

@@ -63,6 +63,9 @@ class HomeModel @@ -63,6 +63,9 @@ class HomeModel
63 return array(); 63 return array();
64 } 64 }
65 $menu = array(); 65 $menu = array();
  66 + $key = sprintf('%s_%s_%s',CacheConfig::KEY_WEB_HOME_NAVBAR_DATA, md5(serialize($data)), $channel);
  67 + $menu = Cache::get($key);
  68 + if(empty($menu)) {
66 $item = array(); 69 $item = array();
67 foreach ($data['data'] as $val) { 70 foreach ($data['data'] as $val) {
68 $item = array( 71 $item = array(
@@ -112,6 +115,8 @@ class HomeModel @@ -112,6 +115,8 @@ class HomeModel
112 } 115 }
113 $menu[] = $item; 116 $menu[] = $item;
114 } 117 }
  118 + Cache::set($key, $menu, 3600);
  119 + }
115 return $menu; 120 return $menu;
116 } 121 }
117 122
@@ -165,9 +170,14 @@ class HomeModel @@ -165,9 +170,14 @@ class HomeModel
165 */ 170 */
166 public static function getChannelResource($channel, $content_code) 171 public static function getChannelResource($channel, $content_code)
167 { 172 {
  173 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.$channel);
  174 + $data = Cache::get($key);
  175 + if(empty($data)) {
168 $resource = IndexData::getResourceData($content_code); 176 $resource = IndexData::getResourceData($content_code);
169 // 格式化数据 177 // 格式化数据
170 $data = ChannelProcess::getFormat($channel, $resource['data']); 178 $data = ChannelProcess::getFormat($channel, $resource['data']);
  179 + Cache::set($key, $data, 3600);
  180 + }
171 return $data; 181 return $data;
172 } 182 }
173 183
@@ -213,6 +223,10 @@ class HomeModel @@ -213,6 +223,10 @@ class HomeModel
213 public static function getNewArrival($channel) 223 public static function getNewArrival($channel)
214 { 224 {
215 $result = array(); 225 $result = array();
  226 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
  227 + //缓存数据
  228 + $result = Cache::get($key);
  229 + if(empty($result)) {
216 $params = array( 230 $params = array(
217 'order' => 's_t_desc', 231 'order' => 's_t_desc',
218 'shelve_time' => strtotime("-60 days") . ',' . time() 232 'shelve_time' => strtotime("-60 days") . ',' . time()
@@ -253,6 +267,8 @@ class HomeModel @@ -253,6 +267,8 @@ class HomeModel
253 } 267 }
254 } 268 }
255 } 269 }
  270 + Cache::set($key, $result, 3600);
  271 + }
256 return $result; 272 return $result;
257 } 273 }
258 } 274 }
@@ -53,7 +53,6 @@ class BackController extends WebAction { @@ -53,7 +53,6 @@ class BackController extends WebAction {
53 if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱 53 if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱
54 $email = $phoneNum; 54 $email = $phoneNum;
55 $data = BackData::sendCodeToEmail($email); 55 $data = BackData::sendCodeToEmail($email);
56 -  
57 if ($data ['code'] == 200) { 56 if ($data ['code'] == 200) {
58 $this->setSession('email', $email); 57 $this->setSession('email', $email);
59 $this->redirect ('sendemail'); 58 $this->redirect ('sendemail');
@@ -64,7 +63,8 @@ class BackController extends WebAction { @@ -64,7 +63,8 @@ class BackController extends WebAction {
64 } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号 63 } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号
65 $mobile = $phoneNum; 64 $mobile = $phoneNum;
66 $data = BackData::sendCodeToMobile($mobile, $area); 65 $data = BackData::sendCodeToMobile($mobile, $area);
67 - if ($data ['code'] == 200) { 66 +
  67 + if ($data['code'] == 200) {
68 $this->setSession ('mobile', $mobile ); 68 $this->setSession ('mobile', $mobile );
69 $this->setSession ('area', $area ); 69 $this->setSession ('area', $area );
70 $this->setSession ('verifyCode', $verifyCode ); 70 $this->setSession ('verifyCode', $verifyCode );
@@ -208,6 +208,8 @@ class BackController extends WebAction { @@ -208,6 +208,8 @@ class BackController extends WebAction {
208 $this->redirect ( SITE_MAIN . $url ); 208 $this->redirect ( SITE_MAIN . $url );
209 } 209 }
210 } 210 }
  211 + //出错直接跳到找回密码页
  212 + $this->redirect ('/passport/back/index');
211 } 213 }
212 214
213 /** 215 /**
@@ -224,4 +226,5 @@ class BackController extends WebAction { @@ -224,4 +226,5 @@ class BackController extends WebAction {
224 } 226 }
225 return $info; 227 return $info;
226 } 228 }
  229 +
227 } 230 }