magento如何提出缓存键名称? [英] How does magento come up with cache key names?

查看:44
本文介绍了magento如何提出缓存键名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我的问题在这里:在安装时刷新Magento Redis缓存的问题基于单独的后端服务器太具体了,基于它获得的视图数量很少,所以我要问一个更简单,更笼统的问题.

I think my question here: Problems flushing Magento Redis Cache on an installation with a separate backend server is a little too specific, based on the small number of views it's getting, so I'm asking a simpler, more general question.

我的问题的详细信息在链接的问题中.但是要点是,如果我尝试从管理区域刷新缓存或刷新magento缓存,它将尝试清除看起来不存在的类似"zc:ti:403_FPC"的内容.相反,它们被命名为"zc:ti:109_FPC"等等.存在一些403键,但还有更多109键.

The details of my problem are in the linked question. But the gist of it is that if I try to refresh a cache or flush magento cache from the admin area, it tries to clear stuff that looks like "zc:ti:403_FPC" which does not exist. Instead, they are named "zc:ti:109_FPC" and the like. Some 403 keys exist, but there are many more 109s.

我怀疑该问题是由管理员位于单独的服务器和不同的子域(admin.example.com)上引起的.因为当应用程序服务器创建并清除键时,它们似乎将其命名为109,而管理服务器则创建了403键.也许有多个应用服务器的问题.或使用redis.

My suspicion is that the problem is caused by having the admin on a separate server and a different subdomain (admin.example.com). Because when the app servers make and clear keys they seem to name them 109, while the admin server makes 403 keys. Or maybe the problem having multiple app servers. Or using redis.

由于我的实际问题过于具体,如果有人可以告诉我保存名称时如何命名以及检索名称时使用什么名称,这将是一个好的开始.谢谢.

Since my real problem is too specific, it would be a good start if someone could tell me how the names are made when they are saved, and what names are used when they are retrieved. Thanks.

我很快就测试了一些东西.似乎使用管理员来刷新缓存调用

I tested out something really quickly. It seems that using the admin to refresh caches calls

Mage::app()->getCacheInstance()->clean() etc.

getCacheInstance()看起来像:

getCacheInstance() looks like:

/**
* Get core cache model
*
* @return Mage_Core_Model_Cache
*/
public function getCacheInstance()
  {
      if (!$this->_cache) {
          $this->_initCache();
      }
      return $this->_cache;
  }

我曾经尝试做过一次

Mage::app()->getCache()->clean()

它似乎起作用了!我需要再戳一点以确保.getCache看起来像这样:

And it seemed to work! I need to poke around a little bit more to be sure. getCache looks like this:

/**
       * Retrieve cache object
       *
       * @return Zend_Cache_Core
       */
      public function getCache()
      {
          if (!$this->_cache) {
              $this->_initCache();
          }
          return $this->_cache->getFrontend();
      }

请问有什么理由会使用getCacheInstance而不是getCache来刷新缓存?有什么理由为什么这只会影响我而不是其他所有人?

Is there any reason why one would use getCacheInstance over getCache for refreshing the caches? Is there any reason why this would only affect me and not everyone else?

再次

之所以起作用,是因为它发送了flushdb命令.

It only worked because it sent a flushdb command.

再次

我一直在闲逛,我在Zend/Cache/Core.php中遇到了一些有趣的东西.我找到了一个名为"cache_id_prefix"的选项.听起来很有希望.当我在管理服务器上运行以下命令时:

I've been poking around, and I came upon some interesting stuff in Zend/Cache/Core.php. I found an option called 'cache_id_prefix'. It sounded promising. When I ran the following on my admin server:

<?php 
require_once('/var/www/html/app/Mage.php');
$cip = Mage::app()->getCache()->getOption('cache_id_prefix');
echo $cip;
?>

我得到了"403_"-正是我期望的值.我在应用服务器上尝试了此操作,并获得了"109_".现在,我只需要找到使用setOption()设置这些选项的位置.

I got "403_" - exactly the value that I expected. I tried it on the app server and got "109_". Now, I just need to find where these options are set with setOption().

推荐答案

在以下位置找到了答案: http://blog.nexcess.net/2011/05/21/clearing-the-cache-in-magento/

Found the answer at: http://blog.nexcess.net/2011/05/21/clearing-the-cache-in-magento/

如您所见,缓存文件名有一个独特的模式.Magento对Zend Cache的实现为所有文件添加了前缀"mage",后跟一个id前缀(技术上:前3个字符从您的app/etc/目录的路径的md5哈希中)...

As you can see, there’s a distinct pattern to the cache file names. Magento’s implementation of the Zend Cache prefixes all files with "mage", followed by an id prefix (technically: the first 3 characters from an md5 hash of the path to your app/etc/ directory)...

这很可能是我的答案.我的管理服务器的文档根目录位于默认的/var/www/html.应用程序服务器位于弹性beantalk上,其根源为/var/app/current.

That is most likely my answer. My admin server has a document root at the default /var/www/html. The app servers are on elastic beanstalk and have their roots at /var/app/current.

这篇关于magento如何提出缓存键名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆