reply cache
This commit is contained in:
parent
ca4d6cbcd8
commit
5986d89cc5
@ -93,23 +93,27 @@ class Index extends BaseController
|
|||||||
//回帖榜
|
//回帖榜
|
||||||
public function reply()
|
public function reply()
|
||||||
{
|
{
|
||||||
$user = User::withCount('comments')->order(['comments_count'=>'desc','last_login_time'=>'desc'])->limit(20)->select();
|
$res = Cache::get('reply');
|
||||||
if($user)
|
if(!$res){
|
||||||
{
|
$user = User::withCount('comments')->order(['comments_count'=>'desc','last_login_time'=>'desc'])->limit(20)->select();
|
||||||
$res['status'] = 0;
|
if($user)
|
||||||
$res['data'] = array();
|
{
|
||||||
foreach ($user as $key=>$v) {
|
$res['status'] = 0;
|
||||||
|
$res['data'] = array();
|
||||||
|
foreach ($user as $key=>$v) {
|
||||||
|
|
||||||
$u['uid'] = (string) url('user/home',['id'=>$v['id']]);
|
$u['uid'] = (string) url('user/home',['id'=>$v['id']]);
|
||||||
$u['count(*)'] = $v['comments_count'];
|
$u['count(*)'] = $v['comments_count'];
|
||||||
if($v['nickname'])
|
if($v['nickname'])
|
||||||
{
|
{
|
||||||
$u['user'] = ['username'=>$v['nickname'],'avatar'=>$v['user_img']];
|
$u['user'] = ['username'=>$v['nickname'],'avatar'=>$v['user_img']];
|
||||||
} else {
|
} else {
|
||||||
$u['user'] = ['username'=>$v['name'],'avatar'=>$v['user_img']];
|
$u['user'] = ['username'=>$v['name'],'avatar'=>$v['user_img']];
|
||||||
|
}
|
||||||
|
$res['data'][] = $u;
|
||||||
}
|
}
|
||||||
$res['data'][] = $u;
|
}
|
||||||
}
|
Cache::set('reply',$res,3600);
|
||||||
}
|
}
|
||||||
return json($res);
|
return json($res);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user