We have a web application which is based on Yii 1.1 . I want to cache some data so I found Yii documentation about data caching and I did it step by step but set method always return false when I debug it.
First I configured cache components (and then enabled memcache extension on my host):
'cache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'server1', 'port'=>11211, 'weight'=>60),
array('host'=>'server2', 'port'=>11211, 'weight'=>40),
),
),
And here is my sample code for caching but get method always returns false so when I debugged it with an if condition I found set method doesn’t set cache data and returns false value .Note that $merchant_id is a unique number.
public static function getMerchantLogo($merchant_id='',$logo='')
{
//my codes to get $merchant_logo by their merchant_id
$cache=Yii::app()->cache->set($merchant_id, $merchant_logo);
if($cache){
return $merchant_logo;
}else{
//set $merchant_logo a default value
return $merchant_logo;
}
}