We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Flushing ORM Cache

I'm trying to implement ORM Caching and I had a few questions on the flushing of the cache when related records get changed.

For this I have two examples:

1). I have a calendaritem object and a checkin object. Checkins are assigned to calendar items. When doing a particular API call, I return back all calendaritems for today and each calendaritem record has the checkins for that calendaritem.

I'm using ORM caching here. When a new checkin occurs (via the API and using the same model), the ORM cache seems to undestnad the this checkin has been cached with the calendaritem query - and when I requery the api call, it will correctly update and show the new checkin - essentially breaking or flushing the cache.k

2). I have a track object and a trackitem object. In almost the exact same fashion as above, I have an API endpoint that's returning all tracks and showing all related trackitems. When I add a trackitem via the API (using the API) it does NOT update the next call to GET tracks, like I would expect.

My question is this: What is telling the ORM to flush cache, if anything? Is it the related records? I cannot find any documentation on such a topic?

Using a Cacheable model like this: https://github.com/phalcon/cphalcon/blob/master/unit-tests/models/Cacheable/Model.php

It will create a new key for every incoming paramter on the query. Sort order, limits, etc.
Can the ORM Caching be smart enough to know data / objects realted to many different keys have been changed and thus need to be flushed?

BTW - When the lifetime runs out, the cache will reset correct with the new trackitems as expected.