您的位置:首页 > 数据库 > Memcache

[Yii Framework] Share the session with memcache in Yii

2014-02-11 02:21 363 查看
When developing distributed applications with Yii, naturally, we will face that we have to

share the session in different machine. So here we will use memcache to do it.

here is the example to store the session with memcache in Yii, in the main.php file:

'cache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array(
'host'=>'192.168.1.1',
'port'=>11211,
),
),
),
'sessionCache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array(
'host'=>'192.168.1.2',
'port'=>11211,
),
),
),
'session' => array (
'class'=> 'CCacheHttpSession',
'autoStart' => true,
'cacheID' => 'sessionCache', //we only use the sessionCache to store the session
'cookieMode' => 'only',
'timeout' => 1400
),

For the details, pls refer to http://www.yiiframework.com/doc/api/1.1/CCacheHttpSession#cacheID-detail

Have fun with Yii!

转于:http://www.cnblogs.com/davidhhuan/archive/2012/11/22/2781903.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: