Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
10 years ago
Commit
5a57c913dde8debfbe9a1b4ce18e07556a8379f5
1 parent
a5bb21b7
修复新品到着,折扣专区缓存问题
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
59 deletions
library/Configs/CacheConfig.php
yohobuy/m.yohobuy.com/application/models/Category/Class.php
yohobuy/m.yohobuy.com/application/models/Product/Newsale.php
library/Configs/CacheConfig.php
View file @
5a57c91
...
...
@@ -21,7 +21,10 @@ class CacheConfig
const
KEY_ACTION_PRODUCT_NEWSALE_INDEX_GIRLS
=
'key_action_product_newsale_index_girls'
;
// 女生新品到着
const
KEY_ACTION_PRODUCT_NEWSALE_INDEX_KIDS
=
'key_action_product_newsale_index_kids'
;
// 潮童新品到着
const
KEY_ACTION_PRODUCT_NEWSALE_INDEX_LIFESTYLE
=
'key_action_product_newsale_index_lifestyle'
;
// 创意生活新品到着
const
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT
=
'key_action_product_newsale_discount'
;
// 折扣专区
const
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_BOYS
=
'key_action_product_newsale_discount_boys'
;
// 男生折扣专区
const
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_GIRLS
=
'key_action_product_newsale_discount_girls'
;
// 女生折扣专区
const
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_KIDS
=
'key_action_product_newsale_discount_kids'
;
// 潮童折扣专区
const
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_LIFESTYLE
=
'key_action_product_newsale_discount_lifestyle'
;
// 创意生活折扣专区
// 品类数据
...
...
yohobuy/m.yohobuy.com/application/models/Category/Class.php
View file @
5a57c91
...
...
@@ -81,11 +81,11 @@ class ClassModel
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$classes
))
{
$classes
=
Cache
::
get
(
CacheConfig
::
KEY_
ACTION_INDEX_INDEX
,
'slave'
);
$classes
=
Cache
::
get
(
CacheConfig
::
KEY_
CATEGORY_CLASSES_DATA
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
CacheConfig
::
KEY_
ACTION_INDEX_INDEX
,
$classes
);
Cache
::
set
(
CacheConfig
::
KEY_
CATEGORY_CLASSES_DATA
,
$classes
);
}
}
...
...
yohobuy/m.yohobuy.com/application/models/Product/Newsale.php
View file @
5a57c91
...
...
@@ -40,46 +40,23 @@ class NewsaleModel
{
$result
=
array
();
if
(
USE_CACHE
)
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
/* 根据频道调用接口 */
switch
(
intval
(
$channel
))
{
case
1
:
// 男生
$newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_NEW_BOYS
);
$result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
self
::
CODE_TOP_NEW_BOYS
);
break
;
case
2
:
// 女生
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_NEW_GIRLS
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_GIRLS
,
self
::
CODE_TOP_NEW_GIRLS
);
break
;
case
3
:
// 潮童
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_NEW_KIDS
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_KIDS
,
self
::
CODE_TOP_NEW_KIDS
);
break
;
case
4
:
// 创意生活
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_NEW_LIFESTYLE
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_LIFESTYLE
,
self
::
CODE_TOP_NEW_LIFESTYLE
);
break
;
}
// 调用接口获取数据并封装
if
(
isset
(
$newsale
[
'code'
])
&&
isset
(
$newsale
[
'data'
][
0
][
'data'
][
0
]))
{
$result
=
Helpers
::
formatBanner
(
$newsale
[
'data'
][
0
][
'data'
][
0
],
640
,
240
);
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
$result
);
}
}
return
$result
;
}
...
...
@@ -92,46 +69,22 @@ class NewsaleModel
{
$result
=
array
();
if
(
USE_CACHE
)
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
/* 根据频道调用接口 */
switch
(
intval
(
$channel
))
{
case
1
:
// 男生
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_SALE_BOYS
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_BOYS
,
self
::
CODE_TOP_SALE_BOYS
);
break
;
case
2
:
// 女生
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_SALE_GIRLS
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_GIRLS
,
self
::
CODE_TOP_SALE_GIRLS
);
break
;
case
3
:
// 潮童
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_SALE_KIDS
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_KIDS
,
self
::
CODE_TOP_SALE_KIDS
);
break
;
case
4
:
// 创意生活
$
newsale
=
NewsaleData
::
getNewsaleFocus
(
self
::
CODE_TOP_SALE_LIFESTYLE
);
$
result
=
self
::
cacheControl
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_LIFESTYLE
,
self
::
CODE_TOP_SALE_LIFESTYLE
);
break
;
}
// 调用接口获取数据并封装
if
(
isset
(
$newsale
[
'code'
])
&&
isset
(
$newsale
[
'data'
][
0
][
'data'
][
0
]))
{
$result
=
Helpers
::
formatBanner
(
$newsale
[
'data'
][
0
][
'data'
][
0
],
640
,
240
);
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT
,
$result
);
}
}
return
$result
;
}
...
...
@@ -207,4 +160,41 @@ class NewsaleModel
return
$result
;
}
/**
* 顶部焦点图缓存控制
* @param const $cacheKey 缓存常量值
* @param const $codeKey 顶部焦点图位置码
* @return array 焦点图数据
*/
private
static
function
cacheControl
(
$cacheKey
,
$codeKey
)
{
if
(
USE_CACHE
)
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$cacheKey
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
$newsale
=
NewsaleData
::
getNewsaleFocus
(
$codeKey
);
// 调用接口获取数据并封装
if
(
isset
(
$newsale
[
'code'
])
&&
isset
(
$newsale
[
'data'
][
0
][
'data'
][
0
]))
{
$result
=
Helpers
::
formatBanner
(
$newsale
[
'data'
][
0
][
'data'
][
0
],
640
,
240
);
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
CacheConfig
::
KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS
,
$result
);
}
}
return
$result
;
}
}
...
...
Please
register
or
login
to post a comment