article cache
This commit is contained in:
parent
e5d73a372e
commit
b270bda273
@ -95,7 +95,7 @@ class Article extends BaseController
|
|||||||
//文章详情页
|
//文章详情页
|
||||||
public function detail($id)
|
public function detail($id)
|
||||||
{
|
{
|
||||||
$article = Cache::get('article');
|
$article = Cache::get('article_'.$id);
|
||||||
if(!$article){
|
if(!$article){
|
||||||
//查询文章
|
//查询文章
|
||||||
$article = ArticleModel::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,tags,create_time')->where('status',1)->with([
|
$article = ArticleModel::field('id,title,content,status,cate_id,user_id,is_top,is_hot,is_reply,pv,jie,tags,create_time')->where('status',1)->with([
|
||||||
@ -106,7 +106,7 @@ class Article extends BaseController
|
|||||||
$query->field('id,name,nickname,user_img,area_id');
|
$query->field('id,name,nickname,user_img,area_id');
|
||||||
}
|
}
|
||||||
])->find($id);
|
])->find($id);
|
||||||
Cache::set('article',$article,3600);
|
Cache::set('article_'.$id,$article,3600);
|
||||||
}
|
}
|
||||||
$comments = $article->comments()->where('status',1)->select();
|
$comments = $article->comments()->where('status',1)->select();
|
||||||
$article->inc('pv')->update();
|
$article->inc('pv')->update();
|
||||||
|
Loading…
Reference in New Issue
Block a user