我正在编写一个使用一些自定义缓存机制的模块,我希望我的缓存可以在管理区域中与magento核心缓存一起清除.
此外,我想检查是否仅为我的模块启用了缓存,然后根据此选择是否进行缓存.
我相信这是可能的,但不知道如何.
Dre*_*ter 21
Magento让你很容易,基本上只是你的模块全局配置中的几行代码......
<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>
Run Code Online (Sandbox Code Playgroud)
检查缓存是否处于活动状态的逻辑将与以下内容相符......
$cacheGroup = 'namespace_module';
$useCache = Mage::app()->useCache($cacheGroup);
if (true === $useCache) {
// Cache is active
} else {
// Cache is not active
}
Run Code Online (Sandbox Code Playgroud)