core/cache/mycmp/subfolder/files.cache.php
$modx->getCacheManager();
$modx->cacheManager->refresh(array('mycmp' => array('subfolder' => array())));Is this necessary?It really depends on where you call it, but it doesn't hurt anything and ensures that the instance is loaded if it isn't already.
$modx->getCacheManager();
Though that will work with the default xPDOFileCache, beware that in order to do this with other cache implementations you need to pass an option. I recommend calling this option if you intend to delete multiple keys as this is not supported natively in many caching systems and some do not provide any way to iterate keys via a path. The option is ignored by xPDOFileCache, so it does no harm to call it. Just be aware that certain cache implementations may not support this behavior or it may be more expensive than the file system implementation in terms of execution time.
@Shaun; thanks for your reply, I have looked in the cachemanager class but didnt find that, I'm gonna try that!
$modx->cacheManager->delete('path/to/many/things', array(
'multiple_object_delete' => true
));public function delete($key, $options = array()) {
$return= false;
if ($cache = $this->getCacheProvider($this->getOption(xPDO::OPT_CACHE_KEY, $options), $options)) {
$return= $cache->delete($key, $options);
}
return $return;
}$modx->cacheManager->delete('path/to/cache/file');