3

today I realized that the Magento doest a lot of same requests to my memcached server, it's requesting the key Zend_LocaleC_en_GB_currencynumber_ . Do you anyone know where is it generated and how can I improve it? It's probably somehow related to rendering of price box but I dont see reason why it's 50 times in a page. Thanks, Jaro.

Edited: So far I did quick fix Zend_Cache_Backend_Memcached::load

public function load($id, $doNotTestCacheValidity = false)
{
    if ( isset($GLOBALS[$id]) ) {
        return $GLOBALS[$id];
    }

    $tmp = $this->_memcache->get($id);
    if (is_array($tmp) && isset($tmp[0])) {
        $GLOBALS[$id] = $tmp[0];
        return $tmp[0];
    }
    return false;
}

It's not nice but seems to be working. At least many of requests agains memcached server disappeared. Jaro.

4

1 回答 1

2

It is one of the known issues in Zend Framework community. It even was reported as an improvement for 1.0.3 release (http://framework.zend.com/issues/browse/ZF-2311).

You fix make sense for Magento where a lot of calls to Zend_Currency is performed and connection to memcached having some limitations or slow enough.

For instance on most of the projects we are using memcached and haven't experienced too big loss in page load time with this calls.

However you can fix it in Magento to make a workaround with ZF:

  1. Rewrite core/locale model in your module

  2. Override currency() method

    public function currency($currency)
    {
         if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) {
            $currencyObject = parent::currency($currency);
            $currencyObject->setFormat(array(
                'format' => Zend_Locale_Data::getContent($this->getLocale(), 'currencynumber')
            ));
            return $currencyObject;
         }
         return parent::currency($currency);
    }
    
于 2012-08-15T20:50:08.523 回答