Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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()}() ...");
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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();
 }
Exemplo n.º 8
0
 public function reset()
 {
     parent::reset();
     $this->_cachedData = [];
     Cache::delete('model-metadata');
 }
Exemplo n.º 9
0
 public static function clearAssetsCache()
 {
     static::$cachedAssets = [];
     Cache::delete('assets');
 }
Exemplo n.º 10
0
 public static function clearCache()
 {
     $environment = static::environment();
     is_file($cacheFile = storagePath('cache/config-' . $environment . '.php')) and unlink($cacheFile);
     Cache::delete('db_configs_' . $environment);
 }
Exemplo n.º 11
0
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);
Exemplo n.º 12
0
 public function removePendingConfirmationData()
 {
     Cache::delete('reg-pc-' . Session::get('pending-confirm'));
     Session::remove('pending-confirm');
     return $this;
 }
Exemplo n.º 13
0
 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;
 }