Magento自定义缓存与管理开关 [英] Magento Custom Caching with admin switch
问题描述
我正在编写一个使用自定义缓存机制的模块,我希望可以从管理区域以及核心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对您来说非常容易,基本上是模块全局config…
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屋!