Magento - Magento 缓存

发布于 2024-09-24 04:02:21 字数 177 浏览 2 评论 0原文

我正在使用内存缓存。

我想了解 Magento 缓存中存储了什么以及如何存储?

magento 是否将缓存变量存储在网站范围或商店范围内?

我已经用谷歌搜索并搜索了代码,但无法得出任何结论,

如果有人可以指导我正确的链接和路径,

谢谢&问候, 索拉布

I am using memcache.

I want to understand what is stored in Magento cache and how?

Do magento stores cache variable with website scope or store scope?

I have googled and greped the code but couldnt conclude anything,

Please if someone can direct me to correct links and path

Thanks & Regards,
Saurabh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

枉心 2024-10-01 04:02:21

如果您转到管理区域的缓存管理部分,您可以看到它缓存的内容(配置、布局配置、块 html 输出、翻译、eav 类型等)。我不是 Magento 缓存机制方面的专家,但这里有一些随机的花絮可能会有所帮助(也许)。 (另请注意,我只熟悉 Magento 1.3.x,而不熟悉 1.4.x,因此情况可能会发生变化)。

缓存实际上存储在var/cache目录中。其中有大量目录(mage--0、mage--1、mage--2),每个目录都有缓存文件。执行 ls var/cache/mage*/* 查看所有文件。

配置 - 配置的来源多种多样。您的 app/etc/local.xml 和所有 config.xml 文件(位于每个模块的 etc 目录中)组合在一起以形成一个大的配置对象。然后 Magento 从 core_config_data 表中读取以更新配置对象。然后将配置写入缓存文件,以便下次发出请求时不需要打开大量配置文件并访问数据库。不知何故,这些信息被存储在 var/cache 下的一堆文件中。要获得一些见解,请执行 ls var/cache/mage*/*CONF*

布局 - 这很像配置... app/design/frontendOrAdminhtml/yournamespace/layout/ 目录中有一堆 xml 文件,所有这些文件都合并到一个布局配置对象中,然后缓存在缓存目录中。

块 HTML - 缓存块生成的实际 html。每个块都能够决定它将被缓存多长时间。

最后,为了(不是真正)回答您关于缓存是否是每个网站或商店的问题,我真的不能说,因为我还没有需要设置多网站/多商店商店。看起来可能有一些商店/网站特定的文件,但我看不出它们确实是以逻辑方式组织的。例如,在我的一个实例中,我看到一个 var/cache/mage--f/mage---LAYOUT_FRONTEND_STORE0_DEFAULT_BLANK_SEO 文件和一个 var/cache/mage--f/mage---LAYOUT_FRONTEND_STORE1_DEFAULT_BLANK_SEO...但话又说回来,我仅配置了一个存储,并且这两个文件具有相同的内容。祝你好运!

If you go to the Cache Management section of the admin area you can see what it caches (configuration, layout configuration, block html output, translations, eav types, etc). I am no expert on Magento's caching mechanisms but here are a few random tidbits that might be helpful (maybe). (Also note that I am only familiar with Magento 1.3.x, not 1.4.x so things could have changed).

The caching is actually stored in the var/cache directory. There are a ton of directories in there (mage--0, mage--1, mage--2) and each directory has the cache files. Do a ls var/cache/mage*/* to see all the files.

Configuration - This source for the configuration is varied. Your app/etc/local.xml, and all of the config.xml files (that are in each module's etc dir) are combined together to make one big configuration object. Then Magento reads from the core_config_data table to update the configuration object. Then the configuration is written to a cache file so that next time a request is made it doesn't need to open a ton of config files and hit the database. Somehow this info gets stored in a bunch of files under var/cache. For some insight do a ls var/cache/mage*/*CONF*.

Layout - This is a lot like the configuration... there are a bunch of xml files in the app/design/frontendOrAdminhtml/yournamespace/layout/ directory and all these are merged into one layout configuration object, then cached in the cache directory.

Block HTML - The actual html generated by a block is cached. Each block is able to decide how long it is going to be cached.

Lastly, to (not really) answer your question about if the cache is per website or store, I can't really say since I haven't had the need to setup a multi-website/multi-store shop yet. It looks like there may be some store/website-specific files, but I can't see that they are really organized in a logical way. For example, in one of my instances I see a var/cache/mage--f/mage---LAYOUT_FRONTEND_STORE0_DEFAULT_BLANK_SEO file and a var/cache/mage--f/mage---LAYOUT_FRONTEND_STORE1_DEFAULT_BLANK_SEO... but then again, I only have one store configured and those two files have the same contents. Good luck with that!

弥枳 2024-10-01 04:02:21

提供的一些非常出色的 memcached 分析和报告工具

您还可以使用http://code 。 google.com/p/memcached/wiki/工具

You could also use some of the very great memcached analysis and reporting tools available

http://code.google.com/p/memcached/wiki/Tools

不…忘初心 2024-10-01 04:02:21

我想出的最佳解决方案是使用二级缓存。
请参阅 app/etc/local.xml.additional 以了解如何将 memcached 服务器节点放入其中。请注意,在 标记内,您必须具有 等标记,封装每个 memcached 节点的设置。

<cache>
    <backend>memcached</backend>
    <slow_backend>database</slow_backend>
</cache>

这样所有的缓存都是共享的。

要按照我的方式清除它是:
1.关闭apache
2.连接到mysql并连接到magento数据库并运行truncate core_cache;截断 core_cache_tag。
3. 然后我反弹 memcached 节点。
4. 我重新启动 apache,但将其保留在负载均衡器之外,直到我至少点击一次以生成 APC 操作码缓存。否则负载可能会冲破屋顶。

这一切看起来很极端,但我发现它对我有用。使用后端清除缓存确实很慢。 core_cache 表中有大约 10 万个条目,core_cache_tag 中有接近 100 万个条目。如果我不这样做,有时我会表现出奇怪的行为。

The best solution I have come up with is to use a two level cache.
Consult app/etc/local.xml.additional to see how to put memcached server nodes in there. Note that within the <servers> tag you will have to have tags like <server1> and <server2> encapsulating each memcached node's settings.

<cache>
    <backend>memcached</backend>
    <slow_backend>database</slow_backend>
</cache>

In this way all cache is shared.

To clear it the way I do it is to:
1. shut down apache
2. connect to mysql and connect to the magento db and run truncate core_cache; truncate core_cache_tag.
3. I then bounce the memcached nodes.
4. I restart apache but I keep it out of the load balancer until I have hit it at least once to generate the APC opcode cache. Otherwise the load can shot up through the roof.

This all seems extreme but I have found it works for me. Clearing cache using the backend is REALLY slow. I have around 100k entries in the core_cache table and close to 1 million entries in core_cache_tag. If I don't do it this way sometimes I get strange behavior.

烟织青萝梦 2024-10-01 04:02:21

./app/etc/local/xml 中的 Memcache 配置将决定 Memcache 实际缓存的内容。

如果您仅使用单级缓存(不带 ),那么 Magento 会将其缓存(全部)存储在 Memcache 中。

但是没有定义slow_backend - 它正在缓存内容,没有cache_tags - 即。没有区分缓存项的能力,

例如。配置、块、布局、翻译等。

因此,如果没有定义,您就无法单独刷新缓存,事实上,您几乎总是必须依赖“刷新缓存存储”才能真正看到更新生效。

我们在这里写了一篇很好的文章,涵盖了您的问题 - http://www.sonassi.com/knowledge-base/magento-knowledge-base/what-is-memcache-actually-caching-in-magento/

Your Memcache configuration in ./app/etc/local/xml will dictate what Memcache is actually caching.

If you are only using a the single-level cache (without ), then Magento will store its cache (in its entirety) in Memcache.

HOWEVER without the slow_backend defined - it is caching content, without cache_tags - ie. without the ability to differentiate cache items

Eg. configuration, block, layouts, translations etc.

So, without the defined, you cannot refresh caches individually, in-fact, you'll almost always have to rely on "Flush Cache Storage" to actually see updates take effect.

We wrote a nice article here which covers your very issue - http://www.sonassi.com/knowledge-base/magento-knowledge-base/what-is-memcache-actually-caching-in-magento/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文