CMemCache not working from Console App

So before I found out about Command I had some login in a controller that a cron job would just wget to /dev/null.

After learning the proper way to do this I rewrote it as a ConsoleCommand and was in business but for some reason app caching isnt work.

Mostly the same code, and same config settings, it can talk to the db, just not the cache.

Any idea?

Code, error messages? Any hints?

Script doesnt fail / no errors.

I have a KronCommand class that extends CConsoleCommand class and inside


$a = 100;


$r->val = $r->val + $a;

$r->save(); //this works

//but i also want to cache this number so im not calling the db over an over.

Yii::app()->cache->set("data", $r->val);//this does not work.


my console.php






			array('host'=>'localhost', 'port'=>'11211', 'weight'=>'100'),






			'connectionString' => 'mysql:host=localhost;dbname=xxx',

			'emulatePrepare' => true,

			'username' => 'xxx',

			'password' => 'xxx',

			'charset' => 'utf8',

			'tablePrefix' => 'tbl_'



Now the very same code worked when i had the logic in a controller and called it via wget from cron. But trying the proper way, with console commands isnt working.

The code to retrieve the data from cache is missing?

No, its not retrieve from the cache value because it might not actually be in cache, i store the actual value in the db (which works), but its not setting the cache to that value.

Yes but how do you know that? That’s why I was wondering that the get-code is missing.

You were right, its this problem you answered a while ago.

Double Thanks :)