如何在Magento中找到memcached密钥的来源

时间:2015-06-23 14:48:38

标签: php magento caching memcached

我们使用memcached运行Magento EE 1.13作为我们的" fast"缓存和redis用于"慢"缓存。我们有一个特定的memcached密钥,每秒获得大约70个get请求,但是0%命中。这只发生在我们的生产站点上,该站点有多个前端服务器和一个单独的数据库服务器。

似乎从未设置此特定密钥,但我们无法找到密钥的来源。该密钥使用md5哈希" AA_B1B5D70089938E5C32F61E616FD3908D",因此无法缩小范围。

我可以在哪里查找此密钥的来源?

1 个答案:

答案 0 :(得分:0)

我能够弄清楚这一点。在app / code / core / Mage / Core / Model / App.php中,寻找:

public function loadCache($id)
{
    return $this->_cache->load($id);
}

在此功能中,您要添加临时支票:

public function loadCache($id)
{
    if (strstr($id, 'b1b5d70')) {
        $currentUrl = Mage::helper('core/url')->getCurrentUrl();
        $cacheId = $this->_cache->load($id);
        $stack = Varien_Debug::backtrace(true, true);
        Mage::log("Mage_Core_Model_App: " . $id, null, "memcacheKeys.log", true);
        Mage::log($currentUrl, null, "memcacheKeys.log", true);
        Mage::log($cacheId, null, "memcacheKeys.log", true);
        Mage::log($stack, null, "memcacheKeys.log", true);
    }
    return $this->_cache->load($id);
}

我们在这里检查部分memcached密钥'b1b5d70'。此时密钥尚未转换为大写。在local.xml中定义的前缀“AA_”尚未添加。

保存到日志中的回溯应该告诉您生成密钥的位置。就我而言,它追溯到'app / code / core / Mage / Catalog / Block / Product / Price.php'。