gpt4 book ai didi

如果 REDIS 服务器故障转移,Magento 如何在运行时禁用 Redis 缓存

转载 作者:可可西里 更新时间:2023-11-01 11:25:03 24 4
gpt4 key购买 nike

我们遇到过 Redis 停机时间:无法在后台保存:fork:无法分配内存我们的网络有一段时间不能用了。如果 Redis 不可用,我想正确设置 Magento 以回退到磁盘文件缓存中。什么是最好的选择?我们正在运行 Magento 1.9.3.2 和 Redis 3.2.10,我们的 app/etc/local.xml 缓存和 session 设置是:

<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server>
<port>6379</port>
<persistent></persistent>
<database>12</database>
<password></password>
<force_standalone>0</force_standalone>
<connect_retries>1</connect_retries>
<read_timeout>10</read_timeout>
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_threshold>20480</compress_threshold>
<compression_lib>gzip</compression_lib>
<use_lua>0</use_lua>
</backend_options>
</cache>

<session_save>db</session_save>
<redis_session>
<host>127.0.0.1</host>
<port>6379</port>
<password></password>
<timeout>2.5</timeout>
<persistent></persistent>
<db>13</db>
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>
<log_level>1</log_level>
<max_concurrency>6</max_concurrency>
<break_after_frontend>5</break_after_frontend>
<break_after_adminhtml>30</break_after_adminhtml>
<first_lifetime>600</first_lifetime>
<bot_first_lifetime>60</bot_first_lifetime>
<bot_lifetime>7200</bot_lifetime>
<disable_locking>0</disable_locking>
<min_lifetime>60</min_lifetime>
<max_lifetime>2592000</max_lifetime>
</redis_session>

欢迎所有建议。

最佳答案

要以正确的方式修复它,您应该考虑为 redis 分配更多内存。还将您的缓存和 session 拆分为在不同端口上运行的两个不同的 redis 进程。 Magento 缓存不需要持久缓存,但是所有键都需要大量内存。还要查看您的 redis 配置中的驱逐策略。 https://redis.io/topics/lru-cache

如果您仍然对肮脏的回退感兴趣,您可以修补 Mage_Core_Model_App

应用程序/代码/核心/法师/核心/模型/App.php

 $this->_cache = Mage::getModel('core/cache', $options);

+ if ($this->_cache) {
+ try {
+ $this->_cache->load('somekey');
+ } catch (Exception $e) {
+ Mage::getConfig()->setNode('global/cache/backend', 'file');
+ return $this->getCache();
+ }
+ }

在方法_initCache中

关于如果 REDIS 服务器故障转移,Magento 如何在运行时禁用 Redis 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47071797/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com