Is it necessary to cache objects?

Makaveli

New Member
For a project I have some objects, one method is to load the parent entity.So I call the method like this:$this->getDetails()->getEntity();So the code of getEntity is:\[code\] public function getEntity() { if (isset($this->entity)) { return $this->entity; } else { $mapper = new Crm_Mapper_Entity(); return $this->entity = $mapper->find($this->customerId); } }\[/code\]Is it necessary to load the entity into the attribute? Because when I want to load it on another place it shouldnt be calling the mapper again.Or is it that when it's loaded, the object is already in memory and I don't need to put it into the attribute?Thanks
 
Back
Top