cache = $cache; $this->provider = $provider; } public function getStructure(\databox $databox) { if (false !== ($status = $this->cache->fetch($this->get_cache_key($databox->get_sbas_id())))) { return new StatusStructure($databox, new ArrayCollection(json_decode($status, true))); } $structure = $this->provider->getStructure($databox); $this->cache->save($this->get_cache_key($databox->get_sbas_id()), json_encode($structure->toArray())); return $structure; } public function deleteStatus(StatusStructure $structure, $bit) { $databox = $structure->getDatabox(); $this->provider->deleteStatus($structure, $bit); $this->cache->save($this->get_cache_key($databox->get_sbas_id()), json_encode($structure->toArray())); return $structure; } public function updateStatus(StatusStructure $structure, $bit, array $properties) { $databox = $structure->getDatabox(); $this->provider->updateStatus($structure, $bit, $properties); // note : cache->save(...) should be ok but it crashes some callers, ex. adding a sb (?) $this->cache->delete($this->get_cache_key($databox->get_sbas_id())); return $structure; } private function get_cache_key($databox_id) { return sprintf('status_%s', $databox_id); } }