带有管理开关的 Magento 自定义缓存 [英] Magento Custom Caching with admin switch

查看:32
本文介绍了带有管理开关的 Magento 自定义缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用一些自定义缓存机制的模块,我希望我的缓存可以从管理区域以及核心 Magento 缓存中清除.

I am writing a module that uses some custom caching mechanism and i would like for my caching to be clearable from in the admin area along with the core Magento caching.

此外,我想检查是否仅为我的模块启用了缓存,然后根据此选择是否进行缓存.

Also I would like to check if the caching is enabled for my module only and then choose to do caching or not based on this.

我确信这是可能的,但不知道如何.

I am sure this is possible but do not know how.

推荐答案

Magento 使这对你来说非常容易,本质上只是你模块全局配置中的几行代码…

Magento makes this very easy for you, essentially just a few lines of code in your modules global config…

<global>
    <!-- Other global config -->
    <cache>
        <types>
            <namespace_module module="namespace_module" translate="label description">
                <label>Your modules cache label</label>
                <description>Description of your modules cache</description>
                <tags>YOUR_MODULES_CACHE_TAGS</tags>
            </namespace_module>
        </types>
    </cache>
    <!-- Other global config -->
</global>

<小时>

检查缓存是否处于活动状态的逻辑将遵循以下内容…


The logic for checking if your cache is active or not would be along the lines of the following…

$cacheGroup = 'namespace_module';
$useCache = Mage::app()->useCache($cacheGroup);
if (true === $useCache) {
    // Cache is active
} else {
    // Cache is not active
}

这篇关于带有管理开关的 Magento 自定义缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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