Magento cash caching with admin switch

I am writing a module that uses some kind of custom caching mechanism, and I would like my caching to be accessible for cleaning in the administration area along with the main Magento caching.

I would also like to check if caching is enabled only for my module, and then select caching or not based on this.

I am sure that this is possible, but I do not know how to do it.

+7
source share
1 answer

Magento makes this very easy for you, in fact, just a few lines of code in your global config & hellip;

<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 to check if your cache is active or not will follow these lines: & hellip;

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

All Articles