Search code examples
yiiapc

Yii: APC Cache throwing error of Servers not being configured


I have configured APC Cache for YII application but when I put a variable in cache, I get the following error for line 222:

APC Cache Error

https://i.sstatic.net/qu2tI.jpg

Following is my config/main.php entry for APC Cache:

        'cache'=>array(
            'class'=>'system.caching.CApcCache',
            'servers'=>array(
                    array('host'=>'localhost','port'=>11211,'weight'=>60),
                    array('host'=>'localhost','port'=>11212,'weight'=>40),
                ),
    ),

Following is the code that I use to put data in cache:

    public function getReligion(){
    $lstofvals=Yii::app()->cache->get('RELIGION');
    if ($lstofvals===false){
        Yii::log('Loading Religion Data from List of Values.');
        $lstofvals=$this->PopulateLSTValsData('RELIGION');
        Yii::app()->cache->set('RELIGION', $lstofvals);
    }
    return $lstofvals;
}

I can see the output of apc.php in form of graphs and all other details.

Any help would much appreciated.

Please also confirm if my strategy to store the base data in cache is correct. I am new to Yii and found out about MemCache and APC Cache to be good candidates for such requirements.

Many thanks, Faisal


Solution

  • Remove the entire servers array from your config file. APC isnt distributed. Servers are used for memcache as far as I know