Showing
4 changed files
with
23 additions
and
23 deletions
@@ -18,6 +18,7 @@ class CacheConfig | @@ -18,6 +18,7 @@ class CacheConfig | ||
18 | const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页 | 18 | const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页 |
19 | const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页 | 19 | const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页 |
20 | const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页 | 20 | const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页 |
21 | + const KEY_ACTION_CHANNEL_INDEX = 'key_action_channel_index';//日韩馆 | ||
21 | 22 | ||
22 | const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置 | 23 | const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置 |
23 | 24 |
@@ -14,12 +14,11 @@ use Api\Sign; | @@ -14,12 +14,11 @@ use Api\Sign; | ||
14 | 14 | ||
15 | class ChannelData | 15 | class ChannelData |
16 | { | 16 | { |
17 | - //日韩馆资源位 | ||
18 | - public static function getJCshopData($contentCode) | 17 | + //日韩馆调取资源位 |
18 | + public static function getChannelData($contentCode) | ||
19 | { | 19 | { |
20 | $param = Yohobuy::param(); | 20 | $param = Yohobuy::param(); |
21 | $param['content_code'] = $contentCode; | 21 | $param['content_code'] = $contentCode; |
22 | - | ||
23 | $param['client_secret'] = Sign::getSign($param); | 22 | $param['client_secret'] = Sign::getSign($param); |
24 | 23 | ||
25 | return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param); | 24 | return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param); |
@@ -15,7 +15,7 @@ class ChannelController extends AbstractAction | @@ -15,7 +15,7 @@ class ChannelController extends AbstractAction | ||
15 | $this->setTitle('日韩馆'); // 需求是标题可以自定义 | 15 | $this->setTitle('日韩馆'); // 需求是标题可以自定义 |
16 | $this->setNavHeader('日韩馆', true, false); // 需求是标题可以自定义 | 16 | $this->setNavHeader('日韩馆', true, false); // 需求是标题可以自定义 |
17 | 17 | ||
18 | - $content = ChannelModel::getJcShopFloor(); | 18 | + $content = ChannelModel::getChannelFloor(); |
19 | 19 | ||
20 | // 渲染模板并输出 | 20 | // 渲染模板并输出 |
21 | $this->_view->display('index', array( | 21 | $this->_view->display('index', array( |
@@ -26,20 +26,20 @@ class ChannelModel | @@ -26,20 +26,20 @@ class ChannelModel | ||
26 | * | 26 | * |
27 | * @return array | false | 27 | * @return array | false |
28 | */ | 28 | */ |
29 | - public static function getJcShopFloor() | 29 | + public static function getChannelFloor() |
30 | { | 30 | { |
31 | $result = array(); | 31 | $result = array(); |
32 | 32 | ||
33 | -// if (USE_CACHE) { | ||
34 | -// // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
35 | -// $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'master'); | ||
36 | -// if (!empty($result)) { | ||
37 | -// return $result; | ||
38 | -// } | ||
39 | -// } | 33 | + if (USE_CACHE) { |
34 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
35 | + $result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'master'); | ||
36 | + if (!empty($result)) { | ||
37 | + return $result; | ||
38 | + } | ||
39 | + } | ||
40 | 40 | ||
41 | // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | 41 | // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 |
42 | - $channelData = ChannelData::getJCshopData(self::CODE_FLOOR_JCSHOP); | 42 | + $channelData = ChannelData::getChannelData(self::CODE_FLOOR_JCSHOP); |
43 | 43 | ||
44 | if (isset($channelData['code']) && $channelData['code'] == 200) { | 44 | if (isset($channelData['code']) && $channelData['code'] == 200) { |
45 | $channelData = array( | 45 | $channelData = array( |
@@ -48,16 +48,16 @@ class ChannelModel | @@ -48,16 +48,16 @@ class ChannelModel | ||
48 | $result = FloorProcess::getContent($channelData); | 48 | $result = FloorProcess::getContent($channelData); |
49 | } | 49 | } |
50 | 50 | ||
51 | -// if (USE_CACHE) { | ||
52 | -// // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
53 | -// if (empty($result)) { | ||
54 | -// $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'slave'); | ||
55 | -// } | ||
56 | -// // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
57 | -// else { | ||
58 | -// Cache::set(CacheConfig::KEY_ACTION_BOYS_INDEX, $result); | ||
59 | -// } | ||
60 | -// } | 51 | + if (USE_CACHE) { |
52 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
53 | + if (empty($result)) { | ||
54 | + $result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'slave'); | ||
55 | + } | ||
56 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
57 | + else { | ||
58 | + Cache::set(CacheConfig::KEY_ACTION_CHANNEL_INDEX, $result); | ||
59 | + } | ||
60 | + } | ||
61 | 61 | ||
62 | return $result; | 62 | return $result; |
63 | } | 63 | } |
-
Please register or login to post a comment