public function find($id, $useCache = true) { if ($useCache && empty($this->objectByIdCache)) { $this->findAll(); } return parent::find($id, $useCache); }
public function find($id, $useCache = true) { if (!$useCache) { return parent::find($id, false); } if (!isset($this->objectByIdCache[$id])) { $dataFromCache = $this->cache->fetch($this->getCacheKey($id)); if ($dataFromCache) { return $this->restoreFromCache($dataFromCache); } } $object = parent::find($id, $useCache); if ($object) { $this->storeInCache($object); } return $object; }