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

View cache to use only when fault

Hi, I have a doubt how to implement a view cache to use only when there is a problem in controller with my backend. This is the scenario. The controller makes connection to backend and caches the result (modelscache). Because the view changes based on location of the client I want to cache the view only to serve when connection to backed fails. So when all is alive I use modelscache to get data and then I apply view to serve the result (based on location of client) but if connection to my backend fails I'd like to serve a copy of view (of couse it could be not right based on client location). Example:

Client 1 ---->connection backend ok-----> his result view
Client 2 ---->connection backend ok-----> his result view
Client 3 ---->connection backend ok-----> his result view
Client 4 ---->connection backend FAIL -----> I serve the most recent a copy of view between client 1 or 2 or 3

Each client should save the view (suppose key XXX which is always the same) but nobody should use it if all is alive.

Any idea how to do it?



2.0k

OK... reading forum I discovered how to do it.

Phalcon\Mvc\View\Simple

Thanks