Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I'm actually trying to understand why memcached is not storing data for a given Id.

I'm using Magento EE 1.11.2.0 that is based on Zend Framework 1.11.1.
The interface used to deal with Memcached is Zend_Cache_Backend_Memcached

Now there is not such big custom code here, this is my custom container that save the cache:

public function saveCache($blockContent)
{

    $lifeTime = 86400 * 30 * 6;
    $tags = array(
        My_Module_Model_PageCache_Container_Category_Blabla::CACHE_TAG
    );
    $cacheId = $this->_getCacheId();

    if ($cacheId !== false) {
        $this->_saveCache($blockContent, $cacheId, $tags, $lifeTime);
    }
    return $this;
}

I'm just forcing Magento to use my custom cache tag and a fixed lifetime ( Memcached doesn't support custom tag so I guess this is not the problem ) also my lifetime is not used in Memcached because I can see that the default one is used.

At the beginning I thought the issue was caused by a to long cache ID but now after reducing it ( <31 char ) this didn't help me:

I can see that the load() method Zend_Cache_Backend_Memcached return always false for my cache ids. While the save() method return true like if it was cached.

This is my local.xml configuration:

<cache>
        <slow_backend_store_data>1</slow_backend_store_data>
        <auto_refresh_fast_cache>0</auto_refresh_fast_cache>
        <backend>memcached</backend>
        <slow_backend>database</slow_backend>
        <memcached>
            <servers>
                <!--<server>-->
                <!--<host><![CDATA[127.0.0.1]]></host>-->
                <!--<port><![CDATA[11213]]></port>-->
                <!--<persistent><![CDATA[1]]></persistent>-->
                <!--</server>-->

                <server>
                    <host><![CDATA[unix:///tmp/memcached.sock]]></host>
                    <port><![CDATA[0]]></port>
                    <persistent><![CDATA[0]]></persistent>
                    <weight><![CDATA[2]]></weight>
                    <timeout><![CDATA[5]]></timeout>
                </server>
            </servers>
            <compression><![CDATA[0]]></compression>
            <hashed_directory_level><![CDATA[]]></hashed_directory_level>
            <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
            <file_name_prefix><![CDATA[]]></file_name_prefix>
        </memcached>
    </cache>
    <full_page_cache>
        <backend>memcached</backend>
        <slow_backend>database</slow_backend>
        <slow_backend_store_data><![CDATA[1]]></slow_backend_store_data>
        <memcached>
            <servers>
                <server>
                    <host><![CDATA[unix:///tmp/memcached.sock]]></host>
                    <port><![CDATA[0]]></port>
                    <persistent><![CDATA[0]]></persistent>
                    <weight><![CDATA[2]]></weight>
                    <timeout><![CDATA[10]]></timeout>
                    <retry_interval><![CDATA[10]]></retry_interval>
                    <status><![CDATA[1]]></status>
                    <stats_update_factor><![CDATA[1]]></stats_update_factor>
                </server>
            </servers>
        </memcached>
    </full_page_cache>

I also tried to check the entry of memcached to see if my id was stored or not with this command:

echo 'stats cachedump 35 35' | sudo nc -U /tmp/memcached.sock

  • Any idea about the reason of this ?
  • How can I debug it ? ( I cannot go under Zend_Cache_Backend_Memcached with xdebug)

There also a small things I don't understand:

  • Even if I specify my <cache_lifetime> in my placeholder config that value is not used ? ( that is why I'm overriding the save() method )
share|improve this question
    
Be careful with <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>. It's been replaced with hashed_directory_perm in later version of Zend (and therefore Magento.) –  Tyler V. Jun 6 at 23:56

1 Answer 1

here the issue is $lifetime and a relative bug in Zend_Cache_Backend_Memcached.

Memcached has a max lifetime of 30 days (2592000) so the limit I was using it was too big and that is why the data was not stored.

Sadly:

  1. Zend_Cache_Backend_Memcached::save() doesn't check if the limit is correct < 2592000

  2. the set() method on the memcached object return true even if it doesn't store the data $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.