memcache怎么在Yii框架中使用

memcache怎么在Yii框架中使用?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

。代码如下:

复制代码 代码如下:

public function getChargeRank3()
{
        $startime='2014-04-10 00:00:00';
        $endtime='2014-04-30 23:59:59';
        $sql="select top 3 user_id, sum (point) as total from  table where state=5 and cp_id>=11 and cp_id<=19 and pay_time >='$startime' and pay_time<='$endtime'
group by user_id order by total desc";
        $result=  Yii::app()->controller>createCommand($sql)->queryAll();
        $cache = yii::app()->cache->get($key);
        if($cache!=false)
        {
            foreach ($result as $key=>$val)
            {
  //这里为内部赠送礼物代码,不便透漏
            }
        }
        YII::app()->cache->set($key, $result, strtotime($endtime));//把前三名写入缓存
}

看完上述内容,你们掌握memcache怎么在Yii框架中使用的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!