How Yii uses the Memcache cache
Add in File/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);
Analyze source Code Order
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);
}
This article is from the "PHP Chiu" blog, be sure to keep this source http://asuper.blog.51cto.com/1622151/1591155
How Yii uses the Memcache cache