1

I have a site that doesn't seem to be flushing memcached when the cache is flushed via the button "Flush Cache Storage". I have to manually log into the daemon by telnet and run flush_all to flush the cache

Am I misunderstanding something or is there some issue? I did check to make sure SELinux wasn't the culprit and it doesn't seem to be

Magento Enterprise 1.12.0.2 and my config is below.

<config>
    <global>
        <cache>
        <backend>memcached</backend>
        <memcached>
            <servers>
                <server>
                    <host><![CDATA[127.0.0.1]]></host>
                    <port><![CDATA[11211]]></port>
                    <persistent><![CDATA[1]]></persistent>
                </server>
            </servers>
            <compression><![CDATA[0]]></compression>
            <cache_dir><![CDATA[]]></cache_dir>
            <hashed_directory_level><![CDATA[]]></hashed_directory_level>
            <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
            <file_name_prefix><![CDATA[]]></file_name_prefix>
        </memcached>
        </cache>
        <install>
            <date><![CDATA[Tue, 05 Feb 2013 21:48:55 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[######################]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[]]></password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[files]]></session_save>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[development]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>
  • Would be interested in this as we are having similar issues in relation to load balanced server setups, we have resorted currently to using a bash script to restart memcache on git deploy – lukefowell May 30 '13 at 9:16
  • 1
    Just to confirm> "Flush Cache Storage" should work. It is the only cache manipulation option which works for memcached, but it should work. – benmarks May 30 '13 at 13:57
  • 1
    Did you try to clear cache using simpe php script? Does it work? – Dmytro Zavalkin Aug 15 '13 at 10:13
  • Note that memcached has command line option that disables "flush_all" command. Check ps -Aw x |grep memcached for -F option. – matt Dec 28 '13 at 10:29
  • 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 '14 at 23:55
1

How do you know the cache isn't being cleared? I had a similar problem today, but I was relying on the "curr_items" count in Memcached to test it, which isn't an accurate test.

I set up a Magento shell, which called:

Mage::app()->getCacheInstance()->flush();

This is the method that the "Flush Cache Storage" button calls in the Magento admin. I wanted to check that Memcached was really getting cleared.

I connected to Memcached using telnet, and monitored the "curr_items" count before and after clearing the cache. It barely changed (usually just dropped by one item).

Then I found this: http://www.couchbase.com/issues/browse/MB-2258

It says that the "curr_items" count doesn't drop, even when a (brutal) flush_all is executed directly on the Memcached server. The count only drops the next time someone tries to access a key which no longer exists.

True enough, that's what happened. My cache was being cleared as desired, but only when I refreshed a few pages for the first time, did the count drop (and then rise again, on subsequent requests).

I observed the same results when I ran flush_all from the telnet connection. The count remained unchanged, until I tried to access one of the former keys, at which point the count dropped by one.

0

Check your connection with the db in that config. Make sure that its the right database username, password and database name. If its not connecting with Magento then it wont listen to the flush cache storage button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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