Doctrine 2 Cache:可以使用Repository :: find *()缓存吗? [英] Doctrine 2 Cache: Can I use cache with Repository::find*()?

查看:90
本文介绍了Doctrine 2 Cache:可以使用Repository :: find *()缓存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚进入缓存。从文档中,我可以使用缓存与查询,但是如何使用方法如

  $ em-> find('Application\\ \\ Models\project',1); 


解决方案

如果您搜索自动化,我认为awnser不,他们没有这样的事情。我正在寻找像我这样的东西。您可以在一个服务类的方法中包装find(...),getProjectById($ id),并在此方法中执行缓存。但是,您也需要一个save()方法,以便在刷新后清除特定ID的缓存。


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);

解决方案

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.

这篇关于Doctrine 2 Cache:可以使用Repository :: find *()缓存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆