public function __construct(array $configuration, Nextras\Orm\Model\IRepositoryLoader $repositoryLoader, Nextras\Orm\Model\MetadataStorage $metadataStorage, Nette\Caching\IStorage $cacheStorage) { parent::__construct($configuration, $repositoryLoader, $metadataStorage); $this->onFlush[] = function () use($cacheStorage) { $cacheStorage->clean([Nette\Caching\Cache::TAGS => $this->tags]); $this->tags = []; }; }
public function success(Form $form) { $values = $form->getValues(); if ($values['section'] === 'all') { $this->cacheStorage->clean(array(Cache::ALL => true)); $this->session->destroy(); } elseif ($values['section'] === 'cache') { $this->cacheStorage->clean(array(array(Cache::ALL => true))); } elseif ($values['section'] === 'sessions') { $this->session->destroy(); } }
/** * Reads the specified item from the cache or generate it. * * @param mixed key * @param callable * * @return mixed|NULL */ public function load($key, $fallback = null) { $data = $this->storage->read($this->generateKey($key)); if ($data === null && $fallback) { return $this->save($key, new Nette\Callback($fallback)); } return $data; }
/** * Removes items from the cache by conditions. * Conditions are: * - Cache::PRIORITY => (int) priority * - Cache::TAGS => (array) tags * - Cache::ALL => TRUE * @return void */ public function clean(array $conditions = NULL) { $conditions = (array) $conditions; if (isset($conditions[self::TAGS])) { $conditions[self::TAGS] = array_values((array) $conditions[self::TAGS]); } $this->storage->clean($conditions); }
protected function createLatte() { $latte = new Latte\Engine(); foreach ($this->helpers as $key => $callback) { $latte->addFilter($key, $callback); } foreach ($this->helperLoaders as $callback) { $latte->addFilter(NULL, function ($name) use($callback, $latte) { if ($res = call_user_func($callback, $name)) { $latte->addFilter($name, $res); } }); } if ($this->cacheStorage instanceof Nette\Caching\Storages\PhpFileStorage) { $latte->setTempDirectory($this->cacheStorage->getDir()); } return $latte; }
/** * Removes items from the cache by conditions. * Conditions are: * - Cache::PRIORITY => (int) priority * - Cache::TAGS => (array) tags * - Cache::ALL => TRUE * @return void */ public function clean(array $conditions = NULL) { $this->release(); $this->storage->clean((array) $conditions); }
/** * Removes items from the cache by conditions. * Conditions are: * - Cache::PRIORITY => (int) priority * - Cache::TAGS => (array) tags * - Cache::ALL => TRUE * @return void */ public function clean(array $conditions = NULL) { $this->key = $this->data = NULL; $this->storage->clean((array) $conditions); }
/** * @param \l10n\Translator\Translator $translator */ public function save(Translator $translator) { $language = $this->getLanguage(); $this->storage->write($language->getIso639_1(), ['translated' => $translator->getTranslated(), 'untranslated' => $translator->getUntranslated()], []); }