2011-11-01 37 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