...
|
...
|
@@ -183,20 +183,6 @@ class SearchModel |
|
|
public static function getListData($customCondition = array(), $customOptions = array())
|
|
|
{
|
|
|
$searchCondition = self::searchCondition($customCondition, $customOptions);
|
|
|
if (USE_CACHE) {
|
|
|
$key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_SALE;
|
|
|
if (!empty($searchCondition['userInput'])) {
|
|
|
$key .= http_build_query($searchCondition['userInput'], null, '&');
|
|
|
}
|
|
|
$channel = HomeModel::getSwitchChannel();
|
|
|
//key加上性别参数
|
|
|
$key .= $channel;
|
|
|
// 先尝试获取一级缓存(master), 有数据则直接返回.
|
|
|
$result = Cache::get($key, 'master');
|
|
|
if (!empty($result)) {
|
|
|
return $result;
|
|
|
}
|
|
|
}
|
|
|
// 组合搜索商品url
|
|
|
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
|
|
|
// 组合搜索分类url
|
...
|
...
|
@@ -210,16 +196,6 @@ class SearchModel |
|
|
$data = Yohobuy::getMulti($urlList);
|
|
|
// 组织模板数据
|
|
|
$result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
}
|
|
|
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
|
|
|
elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
|
|
|
Cache::set($key, $result, 1800); // 缓存30分钟
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 清空不使用的变量
|
|
|
$searchCondition = array();
|
...
|
...
|
@@ -242,17 +218,6 @@ class SearchModel |
|
|
public static function searchData($customCondition, $customOptions)
|
|
|
{
|
|
|
$searchCondition = self::searchCondition($customCondition, $customOptions);
|
|
|
if (USE_CACHE) {
|
|
|
$key = WebCacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA;
|
|
|
if (!empty($searchCondition['userInput'])) {
|
|
|
$key .= http_build_query($searchCondition['userInput'], null, '&');
|
|
|
}
|
|
|
// 先尝试获取一级缓存(master), 有数据则直接返回.
|
|
|
$result = Cache::get($key, 'master');
|
|
|
if (!empty($result)) {
|
|
|
return $result;
|
|
|
}
|
|
|
}
|
|
|
$urlList = array();
|
|
|
// 组合搜索商品url
|
|
|
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
|
...
|
...
|
@@ -274,16 +239,6 @@ class SearchModel |
|
|
}
|
|
|
// 组织模板数据
|
|
|
$result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
}
|
|
|
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
|
|
|
elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
|
|
|
Cache::set($key, $result, 600); // 缓存10分钟
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 清空不使用的变量
|
|
|
$searchCondition = array();
|
...
|
...
|
|