缓存无法提供?

时间:2014-06-19 22:58:23

标签: magento caching

我最近更新到magento 1.9但发现我的类别非常慢。我无法找到问题所以猜测这与magento 1.9有关,并决定降级为magento 1.8。一切都工作正常,但过了一段时间后,magento再次变慢了。由于其他一些错误,我做了一些更改,因为我略微更改了/etc/local.xml。显然,我再次解开它,尽管它本来不应该是原因。不幸的是,这并没有解决我的问题。

我当前的local.xml:

<cache>
        <backend>Cm_Cache_Backend_File</backend>
        <prefix>SH24_</prefix>
</cache>

Cm Cache Backend绝对有效。使用标准缓存时结果相同。

我打开了探查器,在不同的开发页面上,文件的传递方式看起来完全不同。 http://i.imgur.com/fnLRheX.png (慢页)

这是在另一个测试开发网站上的样子: http://i.imgur.com/5lwHxH2.png (快速页面)

生成差异是6秒。

正如您所知,在慢速站点中,所有内容都嵌套在layout / db_updates下,但在慢速站点上,它不是。

最耗时的电话是

CONFIGURABLE:Mage_Catalog_Model_Product_Type_Configurable::getConfigurableAttributes

在快速网站上没有调用。相反,它只是:

__EAV_LOAD_MODEL__ 

出现var / cache文件。错误日志不记录任何内容。

有谁知道,我怎么解决这个问题? 非常感谢你!

编辑: 到目前为止我发现了什么。 /Mage/Core/Model/Layout/update.php

 public function fetchDbLayoutUpdates($handle)
    {
        $_profilerKey = 'layout/db_update: '.$handle;
        Varien_Profiler::start($_profilerKey);
        Mage::log($_profilerKey, null, 'mylogfile.log');
        $updateStr = $this->_getUpdateString($handle);
        if (!$updateStr) {
            return false;
        }
        $updateStr = '<update_xml>' . $updateStr . '</update_xml>';
        $updateStr = str_replace($this->_subst['from'], $this->_subst['to'], $updateStr);
        $updateXml = simplexml_load_string($updateStr, $this->getElementClass());
        $this->fetchRecursiveUpdates($updateXml);
        $this->addUpdate($updateXml->innerXml());
        Varien_Profiler::stop($_profilerKey);
        return true;

    }

正如预期的那样,$updateStr为空,并且调用返回。

所以我仔细研究了$this->_getUpdateString($handle)

return Mage::getResourceModel('core/layout')->fetchUpdatesByHandle($handle);

我在fetchUpdatesByHandle($handle);中找到了/Mage/Core/Model/Resource/Layout.php

public function fetchUpdatesByHandle($handle, $params = array())
    {
        $bind = array(
            'store_id'  => Mage::app()->getStore()->getId(),
            'area'      => Mage::getSingleton('core/design_package')->getArea(),
            'package'   => Mage::getSingleton('core/design_package')->getPackageName(),
            'theme'     => Mage::getSingleton('core/design_package')->getTheme('layout')
        );
        foreach ($params as $key => $value) {
            if (isset($bind[$key])) {
                $bind[$key] = $value;
            }
        }
        $bind['layout_update_handle'] = $handle;
        $result = '';

        $readAdapter = $this->_getReadAdapter();
        if ($readAdapter) {
            $select = $readAdapter->select()
                ->from(array('layout_update' => $this->getMainTable()), array('xml'))
                ->join(array('link'=>$this->getTable('core/layout_link')), 
                        'link.layout_update_id=layout_update.layout_update_id',
                        '')
                ->where('link.store_id IN (0, :store_id)')
                ->where('link.area = :area')
                ->where('link.package = :package')
                ->where('link.theme = :theme')
                ->where('layout_update.handle = :layout_update_handle')
                ->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC);

            $result = join('', $readAdapter->fetchCol($select, $bind));
        }
    return $result;
}

$ result预计为空字符串。 $ select看起来像这样:

2014-06-22T13:52:12+00:00 DEBUG (7): handle CATEGORY_56
query 
object(Varien_Db_Select)#295 (4) {
  ["_bind":protected]=>
  array(0) {
  }
  ["_adapter":protected]=>
  object(Magento_Db_Adapter_Pdo_Mysql)#80 (31) {
    ["_defaultStmtClass":protected]=>
    string(29) "Varien_Db_Statement_Pdo_Mysql"
    ["_transactionLevel":protected]=>
    int(0)
    ["_connectionFlagsSet":protected]=>
    bool(true)
    ["_ddlCache":protected]=>
    array(1) {
      [1]=>
      array(2) {
        ["catalog_product_flat_1"]=>
        array(56) {
          ["entity_id"]=>
          array(14) {
            ["SCHEMA_NAME"]=>
            NULL
            ["TABLE_NAME"]=>
            string(22) "catalog_product_flat_1"
            ["COLUMN_NAME"]=>
            string(9) "entity_id"
            ["COLUMN_POSITION"]=>
            int(1)
            ["DATA_TYPE"]=>
            string(3) "int"
            ["DEFAULT"]=>
            NULL
            ["NULLABLE"]=>
            bool(false)
            ["LENGTH"]=>
            NULL
            ["SCALE"]=>
            NULL
            ["PRECISION"]=>
            NULL
            ["UNSIGNED"]=>
            bool(true)
            ["PRIMARY"]=>
            bool(true)
            ["PRIMARY_POSITION"]=>
            int(1)
            ["IDENTITY"]=>
            bool(false)
          }
          ["attribute_set_id"]=>
          array(14) {
            ["SCHEMA_NAME"]=>
            NULL
            ["TABLE_NAME"]=>
            string(22) "catalog_product_flat_1"
            ["COLUMN_NAME"]=>
            string(16) "attribute_set_id"
            ["COLUMN_POSITION"]=>
            int(2)
            ["DATA_TYPE"]=>
            string(8) "smallint"
            ["DEFAULT"]=>
            string(1) "0"
            ["NULLABLE"]=>
            bool(false)
            ["LENGTH"]=>
            NULL
            ["SCALE"]=>
            NULL
            ["PRECISION"]=>
            NULL
            ["UNSIGNED"]=>
            bool(true)
            ["PRIMARY"]=>
            bool(false)
            ["PRIMARY_POSITION"]=>
            NULL
            ["IDENTITY"]=>
            bool(false)
          }
          ["type_id"]=>
          array(14) {
            ["SCHEMA_NAME"]=>
            NULL
            ["TABLE_NAME"]=>
            string(22) "catalog_product_flat_1"
            ["COLUMN_NAME"]=>
            string(7) "type_id"
            ["COLUMN_POSITION"]=>
            int(3)
            ["DATA_TYPE"]=>
            string(7) "varchar"
            ["DEFAULT"]=>
            string(6) "simple"
            ["NULLABLE"]=>
            bool(false)
            ["LENGTH"]=>
            string(2) "32"
            ["SCALE"]=>
            NULL
            ["PRECISION"]=>
            NULL
            ["UNSIGNED"]=>
            NULL
            ["PRIMARY"]=>
            bool(false)
            ["PRIMARY_POSITION"]=>
            NULL
            ["IDENTITY"]=>
            bool(false)
          }
          ["cost"]=>
          array(14) {
            ["SCHEMA_NAME"]=>
            NULL
            ["TABLE_NAME"]=>
            string(22) "catalog_product_flat_1"
            ["COLUMN_NAME"]=>
            string(4) "cost"
            ["COLUMN_POSITION"]=>
            int(4)
            ["DATA_TYPE"]=>
            string(7) "decimal"
            ["DEFAULT"]=>
            NULL
            ["NULLABLE"]=>
            bool(true)
            ["LENGTH"]=>
            NULL
            ["SCALE"]=>
            string(1) "4"
            ["PRECISION"]=>
            string(2) "12"
            ["UNSIGNED"]=>
            NULL
            ["PRIMARY"]=>
            bool(false)
            ["PRIMARY_POSITION"]=>
            NULL
            ["IDENTITY"]=>
            bool(false)
          }
          ["created_at"]=>
          array(14) {
            ["SCHEMA_NAME"]=>
            NULL
            ["TABLE_NAME"]=>
            string(22) "catalog_product_flat_1"
            ["COLUMN_NAME"]=>
            string(10) "created_at"
            ["COLUMN_POSITION"]=>
            int(5)
            ["DATA_TYPE"]=>
            string(9) "timestamp"
            ["DEFAULT"]=>
            NULL
            ["NULLABLE"]=>
            bool(true)
            ["LENGTH"]=>
            NULL
            ["SCALE"]=>
            NULL
            ["PRECISION"]=>
            NULL
            ["UNSIGNED"]=>
            NULL
            ["PRIMARY"]=>
            bool(false)
            ["PRIMARY_POSITION"]=>
            NULL
            ["IDENTITY"]=>
            bool(false)
          }
          [MORE ATTRIBUTES]
        }
      }
    }
    ["_bindParams":protected]=>
    array(0) {
    }
    ["_bindIncrement":protected]=>
    int(0)
    ["_debug":protected]=>
    bool(false)
    ["_logQueryTime":protected]=>
    float(0.05)
    ["_logAllQueries":protected]=>
    bool(false)
    ["_logCallStack":protected]=>
    bool(false)
    ["_debugFile":protected]=>
    string(23) "var/debug/pdo_mysql.log"
    ["_debugIoAdapter":protected]=>
    NULL
    ["_debugTimer":protected]=>
    int(0)
    ["_cacheAdapter":protected]=>
    object(Varien_Cache_Core)#18 (6) {
      ["_specificOptions":protected]=>
      array(1) {
        ["slab_size"]=>
        int(0)
      }
      ["_backend":protected]=>
      object(Cm_Cache_Backend_File)#10 (4) {
        ["_options":protected]=>
        array(11) {
          ["cache_dir"]=>
          string(41) "/home/www/xxxx/magento/var/cache/"
          ["file_name_prefix"]=>
          string(2) "cm"
          ["file_locking"]=>
          bool(true)
          ["read_control"]=>
          bool(false)
          ["read_control_type"]=>
          string(5) "crc32"
          ["hashed_directory_level"]=>
          int(2)
          ["use_chmod"]=>
          bool(false)
          ["directory_mode"]=>
          int(504)
          ["file_mode"]=>
          int(432)
          ["hashed_directory_umask"]=>
          int(504)
          ["cache_file_umask"]=>
          int(432)
        }
        ["_isTagDirChecked":protected]=>
        NULL
        ["_metadatasArray":protected]=>
        array(0) {
        }
        ["_directives":protected]=>
        array(3) {
          ["lifetime"]=>
          int(7200)
          ["logging"]=>
          bool(false)
          ["logger"]=>
          NULL
        }
      }
      ["_options":protected]=>
      array(9) {
        ["write_control"]=>
        bool(true)
        ["caching"]=>
        bool(true)
        ["cache_id_prefix"]=>
        string(5) "xxx"
        ["automatic_serialization"]=>
        bool(false)
        ["automatic_cleaning_factor"]=>
        int(0)
        ["lifetime"]=>
        int(7200)
        ["logging"]=>
        bool(false)
        ["logger"]=>
        NULL
        ["ignore_user_abort"]=>
        bool(false)
      }
      ["_lastId":"Zend_Cache_Core":private]=>
      string(37) "XX_DB_PDO_MYSQL_DDL_eav_attribute_1"
      ["_extendedBackend":protected]=>
      bool(true)
      ["_backendCapabilities":protected]=>
      array(6) {
        ["automatic_cleaning"]=>
        bool(true)
        ["tags"]=>
        bool(true)
        ["expired_read"]=>
        bool(true)
        ["priority"]=>
        bool(false)
        ["infinite_lifetime"]=>
        bool(true)
        ["get_list"]=>
        bool(true)
      }
    }
    ["_isDdlCacheAllowed":protected]=>
    bool(true)
    ["_ddlColumnTypes":protected]=>
    array(13) {
      ["boolean"]=>
      string(4) "bool"
      ["smallint"]=>
      string(8) "smallint"
      ["integer"]=>
      string(3) "int"
      ["bigint"]=>
      string(6) "bigint"
      ["float"]=>
      string(5) "float"
      ["decimal"]=>
      string(7) "decimal"
      ["numeric"]=>
      string(7) "decimal"
      ["date"]=>
      string(4) "date"
      ["timestamp"]=>
      string(9) "timestamp"
      ["datetime"]=>
      string(8) "datetime"
      ["text"]=>
      string(4) "text"
      ["blob"]=>
      string(4) "blob"
      ["varbinary"]=>
      string(4) "blob"
    }
    ["_ddlRoutines":protected]=>
    array(5) {
      [0]=>
      string(3) "alt"
      [1]=>
      string(3) "cre"
      [2]=>
      string(3) "ren"
      [3]=>
      string(3) "dro"
      [4]=>
      string(3) "tru"
    }
    ["_tempRoutines":protected]=>
    string(22) "#^\w+\s+temporary\s#im"
    ["_intervalUnits":protected]=>
    array(6) {
      ["YEARS"]=>
      string(4) "YEAR"
      ["MONTHS"]=>
      string(5) "MONTH"
      ["DAYS"]=>
      string(3) "DAY"
      ["HOURS"]=>
      string(4) "HOUR"
      ["MINUTES"]=>
      string(6) "MINUTE"
      ["SECOND"]=>
      string(6) "SECOND"
    }
    ["_queryHook":protected]=>
    array(2) {
      ["object"]=>
      object(Mage_Core_Model_Resource_Setup)#77 (9) {
        ["_resourceName":protected]=>
        string(14) "livechat_setup"
        ["_resourceConfig":protected]=>
        object(Mage_Core_Model_Config_Element)#124 (2) {
          ["setup"]=>
          object(Mage_Core_Model_Config_Element)#401 (1) {
            ["module"]=>
            string(14) "Zopim_Livechat"
          }
          ["connection"]=>
          object(Mage_Core_Model_Config_Element)#580 (1) {
            ["use"]=>
            string(10) "core_setup"
          }
        }
        ["_connectionConfig":protected]=>
        object(Mage_Core_Model_Config_Element)#35 (9) {
          ["host"]=>
          string
          ["username"]=>
          string
          ["password"]=>
          string
          ["dbname"]=>
          string(13)
          ["initStatements"]=>
          string(14) "SET NAMES utf8"
          ["model"]=>
          string(6) "mysql4"
          ["type"]=>
          string(9) "pdo_mysql"
          ["pdoType"]=>
          object(Mage_Core_Model_Config_Element)#580 (0) {
          }
          ["active"]=>
          string(1) "1"
        }
        ["_moduleConfig":protected]=>
        object(Mage_Core_Model_Config_Element)#70 (3) {
          ["active"]=>
          string(4) "true"
          ["codePool"]=>
          string(5) "local"
          ["version"]=>
          string(5) "0.5.0"
        }
        ["_callAfterApplyAllUpdates":protected]=>
        bool(false)
        ["_conn":protected]=>
        *RECURSION*
        ["_tables":protected]=>
        array(0) {
        }
        ["_setupCache":protected]=>
        array(0) {
        }
        ["_queriesHooked":protected]=>
        bool(true)
      }
      ["method"]=>
      string(17) "callbackQueryHook"
    }
    ["_pdoType":protected]=>
    string(5) "mysql"
    ["_numericDataTypes":protected]=>
    array(16) {
      [0]=>
      int(0)
      [1]=>
      int(1)
      [2]=>
      int(2)
      ["INT"]=>
      int(0)
      ["INTEGER"]=>
      int(0)
      ["MEDIUMINT"]=>
      int(0)
      ["SMALLINT"]=>
      int(0)
      ["TINYINT"]=>
      int(0)
      ["BIGINT"]=>
      int(1)
      ["SERIAL"]=>
      int(1)
      ["DEC"]=>
      int(2)
      ["DECIMAL"]=>
      int(2)
      ["DOUBLE"]=>
      int(2)
      ["DOUBLE PRECISION"]=>
      int(2)
      ["FIXED"]=>
      int(2)
      ["FLOAT"]=>
      int(2)
    }
    ["_config":protected]=>
    array(13) {
      ["host"]=>
      string
      ["username"]=>
      string
      ["password"]=>
      string
      ["dbname"]=>
      string
      ["initStatements"]=>
      string(14) "SET NAMES utf8"
      ["model"]=>
      string(6) "mysql4"
      ["type"]=>
      string(9) "pdo_mysql"
      ["pdoType"]=>
      string(0) ""
      ["active"]=>
      string(1) "1"
      ["charset"]=>
      NULL
      ["persistent"]=>
      bool(false)
      ["options"]=>
      array(3) {
        ["caseFolding"]=>
        int(0)
        ["autoQuoteIdentifiers"]=>
        bool(true)
        ["fetchMode"]=>
        int(2)
      }
      ["driver_options"]=>
      array(0) {
      }
    }
    ["_fetchMode":protected]=>
    int(2)
    ["_profiler":protected]=>
    object(Zend_Db_Profiler)#52 (4) {
      ["_queryProfiles":protected]=>
      array(0) {
      }
      ["_enabled":protected]=>
      bool(false)
      ["_filterElapsedSecs":protected]=>
      NULL
      ["_filterTypes":protected]=>
      NULL
    }
    ["_defaultProfilerClass":protected]=>
    string(16) "Zend_Db_Profiler"
    ["_connection":protected]=>
    object(PDO)#94 (0) {
    }
    ["_caseFolding":protected]=>
    int(0)
    ["_autoQuoteIdentifiers":protected]=>
    bool(true)
    ["_allowSerialization":protected]=>
    bool(true)
    ["_autoReconnectOnUnserialize":protected]=>
    bool(false)
  }
  ["_parts":protected]=>
  array(12) {
    ["straightjoin"]=>
    bool(false)
    ["distinct"]=>
    bool(false)
    ["columns"]=>
    array(1) {
      [0]=>
      array(3) {
        [0]=>
        string(13) "layout_update"
        [1]=>
        string(3) "xml"
        [2]=>
        NULL
      }
    }
    ["union"]=>
    array(0) {
    }
    ["from"]=>
    array(2) {
      ["layout_update"]=>
      array(4) {
        ["joinType"]=>
        string(4) "from"
        ["schema"]=>
        NULL
        ["tableName"]=>
        string(18) "core_layout_update"
        ["joinCondition"]=>
        NULL
      }
      ["link"]=>
      array(4) {
        ["joinType"]=>
        string(10) "inner join"
        ["schema"]=>
        NULL
        ["tableName"]=>
        string(16) "core_layout_link"
        ["joinCondition"]=>
        string(52) "link.layout_update_id=layout_update.layout_update_id"
      }
    }
    ["where"]=>
    array(5) {
      [0]=>
      string(33) "(link.store_id IN (0, :store_id))"
      [1]=>
      string(23) "AND (link.area = :area)"
      [2]=>
      string(29) "AND (link.package = :package)"
      [3]=>
      string(25) "AND (link.theme = :theme)"
      [4]=>
      string(50) "AND (layout_update.handle = :layout_update_handle)"
    }
    ["group"]=>
    array(0) {
    }
    ["having"]=>
    array(0) {
    }
    ["order"]=>
    array(1) {
      [0]=>
      array(2) {
        [0]=>
        string(24) "layout_update.sort_order"
        [1]=>
        string(3) "ASC"
      }
    }
    ["limitcount"]=>
    NULL
    ["limitoffset"]=>
    NULL
    ["forupdate"]=>
    bool(false)
  }
  ["_tableCols":protected]=>
  array(0) {
  }
}
Result 
string(0) ""

奇怪的是,在我的快速测试开发中,$ result也是空的? 真的不知道这一切意味着什么!

EDIT2: 在使用Magneto Debug查看实例化模型时,我注意到了这一点: 模型

Resource Name   Model Class Times Instantiated
catalog/category_flat   Mage_Catalog_Model_Category 32
cms/page    Mage_Cms_Model_Page 18
cms/block   Mage_Cms_Model_Block    5
catalog/attribute   Mage_Catalog_Model_Resource_Eav_Attribute   2
eav/entity_type Mage_Eav_Model_Entity_Type  2
core/url_rewrite    Mage_Core_Model_Url_Rewrite 2
index/process   Mage_Index_Model_Process            2
core/flag           Mage_Catalog_Model_Product_Flat_Flag    1
customer/group  Mage_Customer_Model_Group   1

但是:catalog/product Mage_Catalog_Model_Product 9不是shwon,即使有显示的产品,并且在快速商店中实例化。

0 个答案:

没有答案
相关问题