Beispiel #1
0
 protected function setActionCache($data)
 {
     if ($this->app->conf['cache']['enabled'] && !empty($this->cacheConfig[$this->params['action']])) {
         CacheManager::get()->setSetialize($this->params + ['cacheGroup' => 'controller'], $data);
     }
 }
Beispiel #2
0
 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);
 }