I am currently developing an application framework and looking for ways to optimize performance. My setup is based on the CakePHP framework , but I believe that my question applies to any technology stack, as it relates to data caching.
Take a typical post-author relationship, which is represented by two tables in my db. When I query the database for a specific blog post, at the same time, CakePHP's built-in ORM function also selects the author of the post, comments for the post, etc. All this is returned as one large nested array, which I store in the cache using a unique identifier for the corresponding blog post.
When updating a blog post, it is a childβs game to destroy the cache for the post and restore it with the following query.
But what happens when not the main object is updated (in this case, the blog post), but rather some of the related data? For example, a comment may be deleted, or the author may update his avatar. Are there any approaches (patterns) that I could consider to keep track of updates to related data, and apply updates to my cache accordingly?
I am curious to find out if you encounter similar problems and how you managed to overcome the barrier. Feel free to present an abstract perspective if you use a different stack at your end. Your views are very grateful, thank you very much!