我在我的应用程序中使用 YII 的查询生成器进行 SELECT 查询。如何与 memcached 一起使用?
问候,
阿比吉特
在配置中:
......
'components'=>array(
......
'cache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'server1', 'port'=>11211, 'weight'=>60),
),
),
),
);
并有这样的查询:
$rows = Yii::app()->db->cache(1000, $dependency)->createCommand($sql)->queryAll();
或者对于 ActiveRecord:
$posts = Post::model()->with('comments')->findAll();
有一个很好的教程:http ://www.yiiframework.com/doc/guide/1.1/en/caching.overview