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
9 years ago
Commit
0a43c6a62912f081d72b17c6369fbfdcc7fa7fde
1 parent
693f8a66
地址树数据加上缓存
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
library/Configs/CacheConfig.php
yohobuy/m.yohobuy.com/application/models/Index/User.php
library/Configs/CacheConfig.php
View file @
0a43c6a
...
...
@@ -45,4 +45,6 @@ class CacheConfig
const
KEY_ACTION_GUANG_DETAIL_DATA
=
'key_action_guang_detail_data'
;
// 逛内容详情
const
KEY_ACTION_GUANG_RSS_DATA
=
'key_action_guang_detail_data'
;
// 逛订阅内容
const
KEY_ACTION_ADDRESS_LIST_DATA
=
'key_action_address_list_data'
;
// 地址树数据
}
...
...
yohobuy/m.yohobuy.com/application/models/Index/User.php
View file @
0a43c6a
...
...
@@ -307,6 +307,15 @@ class UserModel
{
$result
=
array
();
if
(
USE_CACHE
)
{
$key
=
CacheConfig
::
KEY_ACTION_ADDRESS_LIST_DATA
;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
// 调用接口获取地址列表数据
$address
=
UserData
::
addressListData
(
$uid
);
...
...
@@ -315,6 +324,17 @@ class UserModel
$result
=
$address
[
'data'
];
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
$key
,
$result
,
1800
);
// 缓存30分钟
}
}
return
$result
;
}
...
...
Please
register
or
login
to post a comment