public function fire() { $clearAll = true; if ($this->input->getOption('config-only')) { $clearAll = false; Config::clearCache(); $this->info('Config cache cleared.'); } if ($this->input->getOption('meta-only')) { $clearAll = false; Db::clearMetadata(); $this->info('Model metadata cleared.'); } if ($this->input->getOption('locale-only')) { $clearAll = false; I18n::clearCache(); $this->info('Locale cache cleared.'); } if ($this->input->getOption('assets-only')) { $clearAll = false; View::clearAssetsCache(); $this->info('Assets cache cleared.'); } if ($clearAll) { Cache::flush(); Config::clearCache(); $this->info('Cache cleared.'); } Events::fire('cache:after_clear', $this); }
public function setUp() { $_SERVER['SCRIPT_NAME'] = '/index.php'; $this->di = Di::getDefault(); Cache::flush(); Config::clearCache(); PHPUnit_Framework_TestCase::setUp(); $class = get_class($this); Log::debug("Running {$class}::{$this->getName()}() ..."); }
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); }
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; }
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; }
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; }
public function setUp() { $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId(); /* @var Di $di */ $di = $this->di = Di::getDefault(); Events::register($di); DiFix::register($di); Db::register($di); Cache::register($di); Log::register($di); Config::register($di); Counter::register($this->di); Aliases::register($di); I18n::register($di); Cookies::register($di); Session::register($di); Cache::flush(); Config::clearCache(); parent::setUp(); $class = get_class($this); Log::debug("================== Running {$class}::{$this->getName()}() ... =================="); Timer::start(); }
public function reset() { parent::reset(); $this->_cachedData = []; Cache::delete('model-metadata'); }
public static function clearAssetsCache() { static::$cachedAssets = []; Cache::delete('assets'); }
public static function clearCache() { $environment = static::environment(); is_file($cacheFile = storagePath('cache/config-' . $environment . '.php')) and unlink($cacheFile); Cache::delete('db_configs_' . $environment); }
use Phalcon\Version; use Phwoolcon\Aliases; use Phwoolcon\Cache; use Phwoolcon\Config; use Phwoolcon\Cookies; use Phwoolcon\Db; use Phwoolcon\DiFix; use Phwoolcon\Events; use Phwoolcon\I18n; use Phwoolcon\Log; use Phwoolcon\Queue; use Phwoolcon\Router; use Phwoolcon\Session; use Phwoolcon\Util\Counter; use Phwoolcon\View; $_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId(); Events::register($di); DiFix::register($di); Db::register($di); Cache::register($di); Log::register($di); Config::register($di); Counter::register($di); Aliases::register($di); Router::register($di); I18n::register($di); Cookies::register($di); Session::register($di); View::register($di); Queue::register($di); $loader->registerNamespaces(Config::get('app.autoload.namespaces', []), true);
public function removePendingConfirmationData() { Cache::delete('reg-pc-' . Session::get('pending-confirm')); Session::remove('pending-confirm'); return $this; }
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; }