コード例 #1
0
ファイル: CacheTest.php プロジェクト: phwoolcon/phwoolcon
 public function testExistsAndKeys()
 {
     $cacheKey = 'test.exists';
     $exists = Cache::exists($cacheKey);
     $this->assertFalse($exists);
     Cache::set($cacheKey, 'foo');
     $exists = Cache::exists($cacheKey);
     $this->assertTrue($exists);
     // Bug in version < 3.0.2: query keys with prefix in file cache
     if ($_SERVER['PHWOOLCON_PHALCON_VERSION'] >= 3000200) {
         $keys = Cache::queryKeys($cacheKey);
     } else {
         $keys = Cache::queryKeys();
     }
     $this->assertNotEmpty($keys);
 }
コード例 #2
0
ファイル: Config.php プロジェクト: phwoolcon/phwoolcon
 public static function all()
 {
     $environment = PhwoolconConfig::environment();
     if (null === ($config = Cache::get($key = 'db_configs_' . $environment))) {
         $db = Db::connection();
         $db->tableExists('config') or static::createConfigTable();
         $config = [];
         /* @var static $row */
         foreach (static::find() as $row) {
             $value = json_decode($row->getData('value'), true);
             $config[$row->getData('key')] = $value;
         }
         Cache::set($key, $config, Cache::TTL_ONE_MONTH);
     }
     return $config;
 }
コード例 #3
0
ファイル: SsoSite.php プロジェクト: phwoolcon/auth
 public static function getSitesData()
 {
     if (null === static::$_sites && null === (static::$_sites = Cache::get($cacheKey = 'sso.sites'))) {
         /* @var static $site */
         $data = [];
         foreach (static::find() as $site) {
             if (!($url = $site->getData('site_url')) || !($host = parse_url($url, PHP_URL_HOST))) {
                 continue;
             }
             $site->setData('host', $host);
             $data[$host] = $site->getData();
         }
         static::$_sites = $data;
         Cache::set($cacheKey, $data);
     }
     return static::$_sites;
 }
コード例 #4
0
ファイル: Controller.php プロジェクト: phwoolcon/phwoolcon
 public function setBrowserCache($pageId = null, $type = null, $ttl = Cache::TTL_ONE_WEEK)
 {
     $pageId or $pageId = $this->request->getURI();
     $cacheKey = md5($pageId);
     $content = $this->response->getContent();
     $eTag = $this->getContentEtag($content);
     switch ($type) {
         case static::BROWSER_CACHE_ETAG:
             Cache::set('fpc-etag-' . $cacheKey, $eTag, $ttl);
             break;
         case static::BROWSER_CACHE_CONTENT:
             Cache::set('fpc-content-' . $cacheKey, $content, $ttl);
             break;
         default:
             Cache::set('fpc-etag-' . $cacheKey, $eTag, $ttl);
             Cache::set('fpc-content-' . $cacheKey, $content, $ttl);
             break;
     }
     $this->setBrowserCacheHeaders($eTag, $ttl);
     return $this;
 }
コード例 #5
0
ファイル: InCache.php プロジェクト: phwoolcon/phwoolcon
 /**
  * Writes the meta-data to files
  *
  * @param string $key
  * @param array  $data
  */
 public function write($key, $data)
 {
     $this->_cachedData[$key] = $data;
     Cache::set('model-metadata', $this->_cachedData, Cache::TTL_ONE_MONTH);
 }
コード例 #6
0
ファイル: View.php プロジェクト: phwoolcon/phwoolcon
 public static function assets($collectionName)
 {
     static::$instance or static::$instance = static::$di->getShared('view');
     $view = static::$instance;
     $useCache = $view->config['options']['assets_options']['cache_assets'];
     if (!$view->assets) {
         $view->assets = static::$di->getShared('assets');
         $useCache and static::$cachedAssets = Cache::get('assets');
     }
     $type = substr($collectionName, strrpos($collectionName, '-') + 1);
     $view->isAdmin() and $collectionName = 'admin-' . $collectionName;
     if ($useCache && isset(static::$cachedAssets[$collectionName])) {
         return static::$cachedAssets[$collectionName];
     }
     $view->loadAssets($view->config['assets']);
     $view->loadAssets($view->config['admin']['assets'], true);
     ob_start();
     try {
         switch ($type) {
             case 'js':
                 $view->assets->outputJs($collectionName);
                 break;
             case 'css':
                 $view->assets->outputCss($collectionName);
                 break;
         }
     } catch (Exception $e) {
         Log::exception($e);
     }
     // @codeCoverageIgnoreEnd
     $assets = ob_get_clean();
     static::$cachedAssets[$collectionName] = $assets;
     $useCache and Cache::set('assets', static::$cachedAssets);
     return $assets;
 }
コード例 #7
0
ファイル: AdapterTrait.php プロジェクト: phwoolcon/auth
 /**
  * @param User  $user
  * @param array $credential
  * @return $this
  */
 public function pushPendingConfirmation($user, array $credential)
 {
     $user->setData('login', $login = $credential['login'])->setData('confirm_class', get_called_class());
     $data = $user->getData();
     Session::set('pending-confirm', $key = md5($login));
     Cache::set('reg-pc-' . $key, $data, $this->options['register']['confirmation_code_ttl']);
     return $this;
 }
コード例 #8
0
ファイル: I18n.php プロジェクト: phwoolcon/phwoolcon
 public function loadLocale($locale, $force = false)
 {
     if (isset($this->locale[$locale]) && !$force) {
         return $this;
     }
     $useCache = $this->options['cache_locale'];
     $cacheKey = 'locale.' . $locale;
     if ($useCache && !$force && ($cached = Cache::get($cacheKey))) {
         $this->locale[$locale] = $cached;
         return $this;
     }
     $packages = [];
     $combined = [];
     foreach (glob($this->localePath . '/' . $this->currentLocale . '/*.php') as $file) {
         $package = pathinfo($file, PATHINFO_FILENAME);
         $combined = array_merge($combined, $packages[$package] = (array) (include $file));
     }
     $this->locale[$locale] = compact('combined', 'packages');
     $useCache and Cache::set($cacheKey, $this->locale[$locale]);
     return $this;
 }