zoukankan      html  css  js  c++  java
  • [Yii Framework] Share the session with memcache in Yii

    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! 

  • 相关阅读:
    最小生成树(模板)
    排序
    kmp模板
    图书管理系统
    顺序表的创建
    洛谷p1090合并果子(优先队列或堆)
    洛谷P1464Function(逆向递推递归+记忆化)
    ueditor设置
    php isset()和 in_array()
    php 判断空
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/2781903.html
Copyright © 2011-2022 走看看