首页 > 系统服务 > 详细

Yii如何使用memcache缓存

时间:2014-12-17 18:44:47      阅读:192      评论:0      收藏:0      [点我收藏+]

Yii如何使用memcache缓存

在文件/protected/main.php里添加


‘components‘ => array(

        ‘CMemCache‘=>array(

              ‘class‘=>‘CMemCache‘,

              ‘servers‘=>array(

                  array(

                      ‘host‘=>‘127.0.0.1‘,

                      ‘port‘=>11211,

                      ‘weight‘=>60,

                  ),

                  array(

                      ‘host‘=>‘127.0.0.1‘,

                     ‘port‘=>11211,

                      ‘weight‘=>40,

                  ),

              ),

          ),

)

$cache  = Yii::app()->CMemCache;

$cache->set("aa", 111);

分析源代码执顺序

YiiBase.php

public static function app()

{

return self::$_app;

}


CApplication.php

public function __construct($config=null)

{

Yii::setApplication($this);


CModule.php

public function __get($name)

{

if($this->hasComponent($name))

return $this->getComponent($name);

else

return parent::__get($name);

}


本文出自 “php阿超” 博客,请务必保留此出处http://asuper.blog.51cto.com/1622151/1591155

Yii如何使用memcache缓存

原文:http://asuper.blog.51cto.com/1622151/1591155

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!