我发现自己在我的存储库中经常做这样的事情:
protected $currencies;
public function findAll()
{
if (!isset($this->currencies))
{
$this->currencies = parent::findAll();
}
return $this->currencies;
}
因此,所有需要收集实体对象的服务都可以只调用findAll
存储库,而无需多次启动数据库查询/水化过程。
是对的还是我滥用了存储库模式?您在本地保存收藏的方式是什么?