首页 > 代码库 > Yii如何使用memcache缓存
Yii如何使用memcache缓存
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缓存