2012-10-10 49 views
-1

我已經安裝在我的電腦的memcached 1.4,下面的PHP代碼運行的罰款:Magento的memcached的

<?php 
    $memcache = new Memcache; 
    $memcache->connect("localhost",11211); # You might need to set "localhost" to "127.0.0.1" 

    echo "Server's version: " . $memcache->getVersion() . "<br />\n"; 

    $tmp_object = new stdClass; 
    $tmp_object->str_attr = "test"; 
    $tmp_object->int_attr = 123; 

    $memcache->set("key",$tmp_object,false,10); 
    echo "Store data in the cache (data will expire in 10 seconds)<br />\n"; 

    echo "Data from the cache:<br />\n"; 
    var_dump($memcache->get("key")); 
?> 

現在我想的memcache添加到Magento的。我改變了馬本地XML從

<?xml version="1.0"?> 
<!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject 
    to the Academic Free License (AFL 3.0) * that is bundled with this package 
    in the file LICENSE_AFL.txt. * It is also available through the world-wide-web 
    at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not 
    receive a copy of the license and are unable to * obtain it through the world-wide-web, 
    please send an email * to [email protected] so we can send you 
    a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if 
    you wish to upgrade Magento to newer * versions in the future. If you wish 
    to customize Magento for your * needs please refer to http://www.magentocommerce.com 
    for more information. * * @category Mage * @package Mage_Core * @copyright 
    Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License 
    (AFL 3.0) */ --> 
<config> 
    <global> 

     <install> 
      <date><![CDATA[Tue, 09 Oct 2012 15:36:30 +0000]]></date> 
     </install> 
     <crypt> 
      <key><![CDATA[]]>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</key> 
     </crypt> 
     <disable_local_modules>false</disable_local_modules> 
     <resources> 
      <db> 
       <table_prefix><![CDATA[]]> 
       </table_prefix> 
      </db> 
      <default_setup> 
       <connection> 
        <host><![CDATA[localhost]]></host> 
        <username><![CDATA[root]]></username> 
        <password><![CDATA[]]> 
        </password> 
        <dbname><![CDATA[magento]]></dbname> 
        <initStatements><![CDATA[SET NAMES utf8]]></initStatements> 
        <model><![CDATA[mysql4]]></model> 
        <type><![CDATA[pdo_mysql]]></type> 
        <pdoType><![CDATA[]]> 
        </pdoType> 
        <active>1</active> 
       </connection> 
      </default_setup> 
     </resources> 
     <session_save><![CDATA[db]]></session_save> 
    </global> 
    <admin> 
     <routers> 
      <adminhtml> 
       <args> 
        <frontName><![CDATA[admin]]></frontName> 
       </args> 
      </adminhtml> 
     </routers> 
    </admin> 
</config> 

<?xml version="1.0"?> 
<!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject 
    to the Academic Free License (AFL 3.0) * that is bundled with this package 
    in the file LICENSE_AFL.txt. * It is also available through the world-wide-web 
    at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not 
    receive a copy of the license and are unable to * obtain it through the world-wide-web, 
    please send an email * to [email protected] so we can send you 
    a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if 
    you wish to upgrade Magento to newer * versions in the future. If you wish 
    to customize Magento for your * needs please refer to http://www.magentocommerce.com 
    for more information. * * @category Mage * @package Mage_Core * @copyright 
    Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License 
    (AFL 3.0) */ --> 
<config> 
    <global> 

     <install> 
      <date><![CDATA[Tue, 09 Oct 2012 15:36:30 +0000]]></date> 
     </install> 
     <crypt> 
      <key><![CDATA[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]]></key> 
     </crypt> 
     <disable_local_modules>false</disable_local_modules> 
     <resources> 
      <db> 
       <table_prefix><![CDATA[]]> 
       </table_prefix> 
      </db> 
      <default_setup> 
       <connection> 
        <host><![CDATA[localhost]]></host> 
        <username><![CDATA[root]]></username> 
        <password><![CDATA[]]> 
        </password> 
        <dbname><![CDATA[magento]]></dbname> 
        <initStatements><![CDATA[SET NAMES utf8]]></initStatements> 
        <model><![CDATA[mysql4]]></model> 
        <type><![CDATA[pdo_mysql]]></type> 
        <pdoType><![CDATA[]]> 
        </pdoType> 
        <active>1</active> 
       </connection> 
      </default_setup> 
     </resources> 
     <session_save><![CDATA[db]]></session_save> 
     <cache> 
      <backend>memcached</backend><!-- apc/memcached/empty=file --> 
      <memcached><!-- memcached cache backend related config --> 
       <servers><!-- any number of server nodes can be included --> 
        <server> 
         <host><![CDATA[127.0.0.1]]></host> 
         <port><![CDATA[11211]]></port> 
         <persistent><![CDATA[1]]></persistent> 
        </server> 
       </servers> 
       <compression><![CDATA[0]]></compression> 
       <cache_dir><![CDATA[]]> 
       </cache_dir> 
       <hashed_directory_level><![CDATA[]]> 
       </hashed_directory_level> 
       <hashed_directory_umask><![CDATA[]]> 
       </hashed_directory_umask> 
       <file_name_prefix><![CDATA[]]> 
       </file_name_prefix> 
      </memcached> 
     </cache> 
    </global> 
    <admin> 
     <routers> 
      <adminhtml> 
       <args> 
        <frontName><![CDATA[admin]]></frontName> 
       </args> 
      </adminhtml> 
     </routers> 
    </admin> 
</config> 

,但現在我得到的錯誤

a:5:{i:0;s:86:"SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)";i:1;s:1653:"#0 \lib\Zend\Db\Adapter\Pdo\Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() 

當我刪除店運行良好再次標籤。 什麼錯了?

+0

您運行的是什麼版本的Magento和什麼樣的堆棧?這也許有所幫助:http://blog.nexcess.net/2010/03/22/enabling-memcached-in-magento/ – B00MER

回答

1

您有數據庫連接問題。你有local.xml中 奇怪的格式,你確定你有

<password><![CDATA[]]> 
        </password> 

因爲默認情況下它應該是

<password><![CDATA[]]></password> 

XML解析器讀取節點與線路中斷,沒有行中斷2個不同的字符串。您可以通過添加

var_dump($this->_config['password']); 

到Zend_Db_Adapter_Pdo_Abstract :: _連接檢查()

+0

問題是我在Eclipse中打自動格式 – wutzebaer