问题描述
我需要在一次 php 执行中使用 propel 从数据库中强制重新读取数据.我已经有一个有点hacky的解决方案:为相应的类调用init%modelName%,但想要更好的东西.
I need to force reread data from DB within one php execution, using propel. I already have a bit hacky solution: call init%modelName% for corresponding classes, but want something better.
是否有任何单个调用或服务配置选项?就像杀死整个实例池一样.
Is there any single call or service config option for that? Like killing whole instance pool.
关于服务:我们使用 symfony2 并且只在一种特定情况下不需要缓存,因此我们甚至可以为此创建单独的环境.
About service: we use symfony2 and don't need cache only in one specific case, hence we can create even separate environment for that.
推荐答案
您可以通过调用全局禁用实例池:Propel::disableInstancePooling()
(Propel::enableInstancePooling()
对启用实例池很有用).
You can globally disable the instance pooling by calling: Propel::disableInstancePooling()
(Propel::enableInstancePooling()
is useful to enable the instance pooling).
否则,您可以依赖包含生成方法的 PEER 类,例如 clearInstancePool()
和 clearRelatedInstancePool()
.
Otherwise, you can rely on PEER classes which contain generated methods like clearInstancePool()
, and clearRelatedInstancePool()
.
这篇关于清除推进缓存(实例池)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!