Reputation: 5108
I'm using YII's Query builder for SELECT queries in my application. How to use memcached along with the same?
Regards,
Abhijit
Upvotes: 0
Views: 2436
Reputation: 879
In config:
......
'components'=>array(
......
'cache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'server1', 'port'=>11211, 'weight'=>60),
),
),
),
);
And with queries something like this:
$rows = Yii::app()->db->cache(1000, $dependency)->createCommand($sql)->queryAll();
or for ActiveRecord:
$posts = Post::model()->with('comments')->findAll();
There is a good tutorial: http://www.yiiframework.com/doc/guide/1.1/en/caching.overview
Upvotes: 2