php - Memcached - 为什么不存储数据?

标签 php magento zend-framework memcached

我实际上是想了解为什么 memcached 不存储给定 ID 的数据。

我正在使用基于 Zend Framework 1.11.1 的 Magento EE 1.11.2.0。
处理memcached的接口(interface)是Zend_Cache_Backend_Memcached
现在这里没有这么大的自定义代码,这是我保存缓存的自定义容器:

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;
}

我只是强制 magento 使用我的自定义 cache tag和一个固定的 lifetime (memcache 不支持自定义标签,所以我想这不是问题)也是我的 lifetime在 memcached 中没有使用,因为我可以看到使用了默认的。

一开始我认为这个问题是由一个过长的缓存 ID 引起的,但现在在减少它( <31 char )之后这对我没有帮助:

我可以看到 load()方法Zend_Cache_Backend_Memcached我的缓存 ID 总是返回 false。
save()方法返回true,就像它被缓存一样。

这是我的 local.xml 配置:
<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>

我还尝试检查 memcached 的条目,以查看我的 id 是否已使用此命令存储:
echo 'stats cachedump 35 35' | sudo nc -U /tmp/memcached.sock
  • 关于这个原因的任何想法?
  • 我该如何调试它? (我不能在 Zend_Cache_Backend_Memcached 下使用 xdebug)
  • 最佳答案

    您可以使用 -vv 重新启动 memcached 并查看交互。

    顺便说一句,memcache 的默认端口是 11211。仅供引用

    关于php - Memcached - 为什么不存储数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17768661/

    相关文章:

    php - 使用 php 群发邮件程序还是简单地使用 mail()?

    php - 带有准备语句的 SELECT 的 JSON 输出

    php - magento 的空白前端

    php - 使用 zend_navigation 的 zend headtitle

    php - Zend_Db_Table 子查询

    php - 只能在我的类中生效的自定义错误处理程序?

    javascript - 从选定的下拉列表中将值附加到文本区域而不删除以前的值

    php - 如何禁用 magento 中的自动发票生成?

    sorting - Magento 网格禁用排序和过滤

    php - 如何在 Zend Framework 中的 javascript 文件中使用翻译?