1

Joomla has a nice "Clear Cache" page that lists cached content and lets you delete it.

I'd like to allow cached content from my module to be deleted from there. I'm using Joomla's built-in cache methods to cache data:

$cache = JFactory::getCache();
$cache->setCaching( 1 );
$result = $cache->call('function', $data);

The files generated by this code are stored in /cache. For example:

List of files in the cache directory. There are several small php cache files with gibberish names, and a folder called "banners"

The folder at /cache/banners is where I would like the cache files to be stored. That's because in the "Clear Cache" page, only sub-directories seem to be clearable:

Joomla's "Clear Cache" page. There is only one selectable entry, "banners"

I've taken a look through Joomla's api, but I don't see any obvious methods for setting the cache directory. I do see some methods mentioning things like "cache groups", which seems close. Am I on the right track?

1 Answer 1

1

The cache group is what needs to be set, however you set it when constructing the cache object. Just change this:

$cache = JFactory::getCache();

... to this:

$cache = JFactory::getCache('banners');

There is more info about parameters that can be passed in Joomla's Factory api.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.