/** * Fetches all the settings * * @return array */ private function getSettings() { if (!$this->cache->isCached('settings')) { $this->cache->cache('settings', $this->getAllSettingsFromDatabase()); } return $this->cache->getFromCache('settings'); }
/** * Fetches all the needed data and caches it in our statistics array * * @param int $startDate * @param int $endDate * @return array */ private function getData($startDate, $endDate) { $dateRange = $startDate . '-' . $endDate; if (!$this->cache->isCached($dateRange)) { $this->cache->cache($dateRange, json_encode(array('metrics' => $this->getMetrics($startDate, $endDate), 'visitGraphData' => $this->collectVisitGraphData($startDate, $endDate), 'pageViews' => $this->collectMostVisitedPagesData($startDate, $endDate), 'sourceGraphData' => $this->collectSourceGraphData($startDate, $endDate)))); } return json_decode($this->cache->getFromCache($dateRange), true); }
/** * 清除缓存 * @return type */ public function actionClearcache() { $app = \Yii::$app->request->get('app', ''); if (!$app) { return $this->redirect('cache'); } Cache::clearCache($app); return $this->redirect('cache'); }