public function getById($id) { $cache = new MemoryCache(); $cacheParams = parent::getCacheDefinition(func_get_args(), __METHOD__); $result = $cache->get($cacheParams); if (!$result) { $result = self::getDao()->get($id); $cache->set($cacheParams, $result, 1); } return $result; }
public function execute() { $routing = new Routing(); try { $cache = new MemoryCache(); $route = $routing->getController($this->request->getUri()); $controller_name = $route->{"controller"}; $action = $route->{"action"}; $controller = new $controller_name(); $cache_params = $controller->getCacheDefinition(UriAnalyzer::getParameters($this->request->getUri()), $action); $content = $cache->get($cache_params); if (!$content) { $response = $controller->build($this->request, $action); $cache->set($cache_params, $response->getContent(), 1); return $response; } else { $response = new ResponseHttp($content); return $response; } } catch (\Exception $e) { echo $e->getMessage(); } }