Memcached - Why data is not stored?

I'm actually trying to understand why memcached does not store data for an identifier.

I am using Magento EE 1.11.2.0 based on Zend Framework 1.11.1. The interface used to work with memcached is Zend_Cache_Backend_Memcached

Now there is no such big custom code here, this is my custom container that saves 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 just force magento to use my custom cache tag and fixed lifetime (memcache does not support the special tag, so I think this is not a problem), also my lifetime not used in memcached because I see that it is used by default.

At the beginning, I thought that the problem was caused by a long cache identifier, but now after its reduction (<31 char) this did not help me:

I see that the load() method of Zend_Cache_Backend_Memcached always returns false for cache identifiers. Although the save() method returns true, as if it were 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 checking the memcached entry to see if my id was saved or not using this command:

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

  • Any idea on the reason for this?
  • How can I debug it? (I cannot go under Zend_Cache_Backend_Memcached using xdebug)
+4
source share
2 answers

here is the problem: $ lifetime and relative error in Zend_Cache_Backend_Memcached.

Memcached has a maximum lifetime of 30 days (2592000), so the restriction I used was too big and therefore the data was not saved.

Unfortunately:

  • Zend_Cache_Backend_Memcached :: save () does not validate the limit <2592000

  • The set () method of the memcached object returns true even if it does not save the data $ result = @ $ this → _ memcache-> set ($ id, array ($ data, time (), $ lifetime), $ flag, $ lifetime) ;

+3
source

You can restart memcached with -vv and look at the interactions.

BTW, the default port for memcache is 11211. FYI

+2
source

Source: https://habr.com/ru/post/1492533/


All Articles