以下是thinkphp缓存实例写法
$newslist = “”;
if(C(‘CATCH’)) {
$newslist = S(‘newslist’);
}
if(!$newslist){
$news = M(‘news’);
$news_data[‘cat_id’] = array(‘eq’,1);
$newslist = $news->where($news_data)->limit(10)->select();
unset($news,$news_data);
S(‘newslist’,$newslist,C(‘CATCH_TIME’)*24*60*60);
}
注意:
C(‘CATCH’)和C(‘CATCH_TIME’)是缓存开启的状态和缓存时间