Is it necessary to cache objects?
<p>For a project I have some objects, one method is to load the parent entity.</p>

<p>So I call the method like this:
$this->getDetails()->getEntity();</p>

<p>So the code of getEntity is:</p>

<pre><code> public function getEntity()
 {
  if (isset($this-&gt;entity)) {
   return $this-&gt;entity;
  } else {
   $mapper = new Crm_Mapper_Entity();
   return $this-&gt;entity = $mapper-&gt;find($this-&gt;customerId); 
  }
 }
</code></pre>

<p>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.</p>

<p>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?</p>

<p>Thanks</p>
