首页 > 其他 > 详细

[Yii Framework] Share the session with memcache in Yii

时间:2014-02-11 09:00:57      阅读:385      评论:0      收藏:0      [点我收藏+]

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: 

bubuko.com,布布扣
bubuko.com,布布扣
         ‘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
        ),
bubuko.com,布布扣
bubuko.com,布布扣

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

[Yii Framework] Share the session with memcache in Yii

原文:http://www.cnblogs.com/Alight/p/3543759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!