2011-11-01 35 views
1

我对cakephp非常陌生,我很难将它配置为在我的活动服务器上工作。它在我的本地机器上正常工作。cakephp - 为会话使用memcache

我认为问题在于我的实时服务器配置为使用Memcache。当我访问活动网站获取:

Warning (2): session_start() [function.session-start]: open(=1&retry;_interval=15/sess_mt8tpui04vorqojg7s945e5sf5, O_RDWR) failed: No such file or directory (2) [CORE/Cake/Model/Datasource/CakeSession.php, line 615] 
Warning (2): session_write_close() [function.session-write-close]: open(=1&retry;_interval=15/sess_mt8tpui04vorqojg7s945e5sf5, O_RDWR) failed: No such file or directory (2) [CORE/Cake/Controller/Controller.php, line 712] 
Warning (2): session_write_close() [function.session-write-close]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (tcp://127.0.0.1:11211?persistent=1&weight;=1&timeout;=1&retry;_interval=15) [CORE/Cake/Controller/Controller.php, line 712] 

所以我试图使蛋糕中加入以下到应用程序/配置/ core.php中使用的内存缓存:

Cache::config('default', array(
    'engine' => 'Memcache' 
)); 

但我仍然得到同样的错误。

php.ini被配置为正确使用memcache。

任何想法?

谢谢

回答

4

您的缓存::配置看起来不完整!

它应该看起来像这个和这个代码块会在应用程序/配置/ bootstrap.php中

Cache::config('default', array(
      'engine' => 'Memcache', //[required] 
      'duration' => 3600, //[optional] 
      'probability' => 100, //[optional] 
      'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string 
      'servers' => array(
        '127.0.0.1:11211' // localhost, default port 11211 
     ), //[optional] 
      'persistent' => true, // [optional] set this to false for non-persistent connections 
      'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory) 
)); 

还需要设置一个会话处理程序http://book.cakephp.org/2.0/en/development/sessions.html#cache-sessions

矿看起来像这样,注意我已经被称为 “sessiones” &这个代码块会在应用程序/配置/ core.php中

Configure::write('Session', array(
     'defaults' => 'cache', 
      'handler' => array(
       'config' => 'sessiones' 
      ), 
     'cookie' => 'PHPSESSID', 
     'timeout' => 3600, 
     'cookieTimeout' => 0, 
     'autoRegenerate' => false, 
     'checkAgent' => true, 
     'ini' => array(
      'session.cookie_secure' => false, 
      'session.cookie_httponly' => true, 
     ) 
    )); 

然后设置缓存:配置为处理“sessiones” 和该代码块将在应用程序/配置/ bootstrap.php中

Cache::config('sessiones', array('engine' => 'Memcache','duration'=> 3600,/*'prefix' =>'es',*/ 'servers' => array(array('127.0.0.1:11211'), 'compress' => false)); 
+0

感谢它的工作原理完全。 – Alok