I recently made a plugin that tries to keep the existing cache warm. It does this by listening to the
elements.onBeforeSaveElement event, grabbing the id of that element and finding all the paths in the
craft_templatecaches table then calls them with Guzzle.
The part I'm struggling with is the element id - when the event fires I just get the id of the element that first fired, in most cases the Entry. How do I ensure I get all of the correct
cacheIds from the
craft_templatecacheelements table? I only have the one element id, is there a way of ensuring I have all of the involved element ids?
I tried getting element ids from
sourceId but still don't seem to be able to replicate the same kind of behaviour that the native cache clearing does. When I save an entry I get a bunch of element ids in the DeleteStaleTemplateCaches Task settings but can't find a way to get that same set of ids before the element saves.
I feel like I'm missing something fundamental ...