Authored by htoooth

dispose cache

... ... @@ -6,12 +6,10 @@
const api = global.yoho.API;
const getProductBannerAsync = (pid, clientType) => {
clientType = clientType || 'web';
const getProductBannerAsync = (pid) => {
return api.get('', {
method: 'web.productBanner.data',
product_id: pid,
client_type: clientType
product_id: pid
});
};
... ...
... ... @@ -42,7 +42,7 @@ const _getProductAdditionInfoAsync = (data) => {
// 获取相关数据
let promiseData = [
productAPI.getProductBannerAsync(productId, 'web'),
productAPI.getProductBannerAsync(productId),
productAPI.sizeInfoAsync(skn),
productAPI.getProductComfortAsync(productId),
productAPI.getProductModelCardAsync(productId),
... ... @@ -178,7 +178,7 @@ const _getVipDataByProductBaseInfo = (data, vipLevel, uid) => {
const _getProductActivityBanner = () => {
let data = _getCacheDataByName('ItemData::getProductBanner');
if (_.get(data, 'code', 400) !== 200 || !_.get(data, 'data.bannerImg')) {
if (_.isElement(data) || _.get(data, 'code', 400) !== 200 || !_.get(data, 'data.bannerImg')) {
return {};
}
... ... @@ -251,7 +251,7 @@ const _getBrandDataByProductBaseInfo = (data) => {
let bannerInfo = null;
let result = _getCacheDataByName('BrandData::getBannerInfo');
if (!result) {
if (_.isEmpty(result)) {
return {};
}
... ... @@ -755,23 +755,23 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
if (domainBrand.type && domainBrand.shopId) {
switch (parseInt(domainBrand.type, 10)) {
case 1:
{
{
// 多品店不显示
banner = [];
break;
}
banner = [];
break;
}
case 2:
{
{
// 单品店显示新版的店铺banner
let basisData = yield shopService.basisTemplateAsync(domainBrand.shopId);
let basisData = yield shopService.basisTemplateAsync(domainBrand.shopId);
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
break;
}
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
break;
}
default:
{
break;
}
{
break;
}
}
}
}
... ... @@ -797,7 +797,7 @@ const _getProductComfort = () => {
let result = [];
let comfort = _getCacheDataByName('ItemData::getProductComfort');
if (!comfort || !comfort.data) {
if (_.isEmpty(comfort) || !comfort || !comfort.data) {
return result;
}
... ... @@ -1024,7 +1024,7 @@ const _getSizeData = (sizeInfo) => {
const _getProductModelCard = () => {
let data = _getCacheDataByName('ItemData::getProductModelCard');
if (!data || _.get(data, 'code', 400) !== 200) {
if (_.isEmpty(data) || !data || _.get(data, 'code', 400) !== 200) {
return [];
}
... ... @@ -1329,6 +1329,16 @@ const _getSeoByGoodsInfo = function(goodsInfo, navs) {
};
};
// 清除缓存
const _dispose = () => {
cachedRequestData['ItemData::getProductBanner'] = {};
cachedRequestData['ItemData::sizeInfo'] = {};
cachedRequestData['ItemData::getProductComfort'] = {};
cachedRequestData['ItemData::getProductModelCard'] = {};
cachedRequestData['ItemData::getProductModelTry'] = {};
cachedRequestData['BrandData::getBannerInfo'] = {};
};
/**
* 获取某一个商品详情主页面
*/
... ... @@ -1380,11 +1390,11 @@ const showMainAsync = (data) => {
);
result.detail.latestWalk = 5;
return result;
})();
})().finally(_dispose);
};
module.exports = {
indexCommentAsync: commentService.indexAsync, // 获取评论列表
getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表
... ...