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.

How do i use cache in ORM?

I want to use cache in the Model class deriectly.How do i write the code ?


Yes.I read that, but i am a little confused about 'modelsCache' service. Once you setup that service, how do i destroy cache when i update or delete models.Use events like beforeSave? And i want use \Phalcon\Cache\Backend\File CLASS in the Model's STATIC function find and findFirst, how do i setup that. @Karol Marcinkiewicz you're a kind person, thanks a lot. These questions are too naive, THANKS you again for your patient.

edited Oct '14

Think if you really need to cache ORM, maybe caching view layer will work better? Your cache key could be md5($SERVER['REQUESTURI'])

But if you need to cache ORM, you need to invalidate cache beforeSave(), or beforeUpdate() events like you told. This forum is cached, so best for you would be read source code.

Here is setup for File Backend Cache:
* - registered service in bootstrap
* - Base model class when you need caching * Look at *

Create your application that it works properly without caching, and then if it is needed fix bottleneck by cache views, views parts and ORM