Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

modelsCache cache invalidation

I'm currently working on optimizing our high-performance platform, and i do want to implement modelsCache, to cache resultsets... But i can't find a good way to cache & invalidate modelsCache dynamically?

What is the best way to cache & invalidate modelsCache service? Store unique keys some place and in afterUpdate/afterDelete invalidate cache manually?

Thank you



133.6k
Accepted
answer

Yea i guess, phalcon doesn't really have built-in mechanism for this. Though cache invalidation will always be hard, what if you for example use joins etc and you update only one model? Then you need to clean it too for joins etc.

You possibly could get more interested about varnish.

edited Sep '18

Yeah, my intention was to only cache findFirst/find functions... With joins it gets way too complicated... But really it seems like a half solution hm....

Not really sure Varnish could solve the problem... Api changes frequently :)