Hi all,
I think I tried to do the same thing. But it's not working for me...
First of all, if I save a resource in the manager I only want this resource to be deleted (or better refreshed) from the cache. So if I save one resource I don't want the whole cache to be cleared.
Is there a simple way to do that?
I tried to create a plugin for the OnDocFormSave event:
$resourceCache = $modx->cacheManager->getCacheProvider($modx->getOption('cache_resource_key', null, 'resource'));
$res = $modx->resource;
$resourceCache->delete($res->getCacheKey());
And when I save the resource I deactivate the clear cache for the resource. This is not the best idea because if I forget to deactivate the clear cache once, the whole cache will be cleared.
But the bigger problem is, that my code in the plugin doesn't work. The delete method returns false. getCacheKey returns "mgr/resources/3" for the resource with id 3. Looks pretty good, but delete doesn't work.
But isn't there an easier way to only update the cache for one resource???
Sounds stupid to me to delete the whole cache if only one resource is changed!!
Martin