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 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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With