예제 #1
0
파일: Controller.php 프로젝트: yagrysha/mvc
 protected function setActionCache($data)
 {
     if ($this->app->conf['cache']['enabled'] && !empty($this->cacheConfig[$this->params['action']])) {
         CacheManager::get()->setSetialize($this->params + ['cacheGroup' => 'controller'], $data);
     }
 }
예제 #2
0
파일: App.php 프로젝트: yagrysha/mvc
 public function runController($params, $cacheTime = null)
 {
     $params = array_merge($this->conf['def_route'], $params);
     $cacheEnabled = $cacheTime && $this->conf['cache']['enabled'];
     if ($cacheEnabled) {
         $cacheKey = 'app/' . md5(serialize($params)) . $cacheTime;
         $cache = Cache::get();
         $ret = $cache->get($cacheKey, $cacheTime);
         if ($ret) {
             return $ret;
         }
     }
     $module = $params['module'] ? '\\' . ucfirst($params['module']) : '';
     $controller = ucfirst($params['controller']);
     $class = $this->conf['app_ns'] . "\\Controller{$module}\\{$controller}Controller";
     if (!class_exists($class)) {
         throw new Exception(Exception::TYPE_404);
     }
     $controller = new $class($this);
     if ($cacheEnabled) {
         $ret = $controller->run($params);
         $cache->set($cacheKey, $ret);
         return $ret;
     }
     return $controller->run($params);
 }