Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine 2 Cache: Can I use cache with Repository::find*()?

I am new to caching. From the docs, I can use caching with queries, but what about methods like

$em->find('Application\Models\project', 1);
like image 696
Jiew Meng Avatar asked Oct 24 '22 21:10

Jiew Meng


1 Answers

If you search for an automatism, i think the awnser is no, their is no such thing. I was searching for something like this my self. You can wrap find(...) in a method of a service class, getProjectById($id) and do caching inside this method your self. But then you need a save() method too, to clear-cache for specific id after flushing.

like image 55
Christian Steinmann Avatar answered Oct 31 '22 09:10

Christian Steinmann