clean() public method

Conditions are: - Cache::PRIORITY => (int) priority - Cache::TAGS => (array) tags - Cache::ALL => TRUE
public clean ( array $conditions = NULL ) : void
$conditions array
return void
Exemplo n.º 1
0
 /**
  * @param Url $oldUrl
  * @param Url $newUrl
  * @return void
  * @throws \Exception
  */
 public function linkUrls(Url $oldUrl, Url $newUrl)
 {
     if ($oldUrl->getId() === null or $newUrl->getId() === null) {
         throw new UrlNotPersistedException();
     }
     try {
         $this->em->beginTransaction();
         $alreadyRedirectedUrls = $this->findByActualUrl($oldUrl->getId());
         /** @var Url $url */
         foreach ($alreadyRedirectedUrls as $url) {
             $url->setRedirectTo($newUrl);
             $this->em->persist($url);
             $this->cache->clean([Cache::TAGS => [$url->getCacheKey()]]);
         }
         $oldUrl->setRedirectTo($newUrl);
         $this->em->persist($oldUrl);
         $this->cache->clean([Cache::TAGS => [$oldUrl->getCacheKey()]]);
         $this->em->flush();
         $this->em->commit();
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         throw $e;
     }
 }
Exemplo n.º 2
0
 public function invalidateCache($onlyTranslation = FALSE)
 {
     if ($onlyTranslation) {
         $this->cache->clean(array(Cache::TAGS => static::TAG_TRANSLATION));
     } else {
         $this->cache->clean(array(Cache::ALL => TRUE));
     }
 }
Exemplo n.º 3
0
 /**
  * Delete single item from cache
  *
  * @param mixed $key   key
  * @param array $conds Conditions (optional)
  */
 public function deleteItem($key, $conds = null)
 {
     if ($conds) {
         $this->cache->clean($conds);
     } else {
         unset($this->cache[$key]);
     }
 }
Exemplo n.º 4
0
 /**
  * @param Page $page
  */
 private function removePageUrl(Page $page)
 {
     /** @var Url $url */
     $url = $this->urlFacade->getByPath($page->getUrlPath());
     if ($url !== null) {
         $this->cache->clean([Cache::TAGS => $url->getCacheKey()]);
         $this->em->remove($url);
     }
 }
Exemplo n.º 5
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($ns = $input->getOption('tag')) {
         $this->cache->clean(array(Cache::TAGS => $input->getOption('tag')));
         $output->writeln('Cache tags "' . implode(', ', $ns) . '" has been invalidated.');
     } else {
         $this->cache->clean();
         $output->writeln('Cache has been invalidated.');
     }
 }
 /**
  * @param ITemplateLocator
  * @param Cache
  * @param string|null
  * @param bool
  */
 public function __construct(ITemplateLocator $templateLocator, ICachingStorage $storage, $setupFingerprint = NULL, $onlyExistingFiles = FALSE)
 {
     $this->templateLocator = $templateLocator;
     $cache = new Cache($storage, 'Rixxi.TemplateLocator');
     if ($setupFingerprint !== $cache['setupFingerprint']) {
         $cache->clean(array(Cache::ALL => TRUE));
         $cache['setupFingerprint'] = $setupFingerprint;
     }
     $this->filesCache = $cache->derive('files');
     $this->layoutFilesCache = $cache->derive('layoutFiles');
     $this->componentFilesCache = $cache->derive('componentFiles');
     $this->onlyExistingFiles = $onlyExistingFiles;
 }
 /**
  * @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     $em = $eventArgs->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         $class = $em->getClassMetadata(get_class($entity))->name;
         $entities[$class][] = $uow->getSingleIdentifierValue($entity);
     }
     foreach ($uow->getScheduledEntityUpdates() as $entity) {
         $class = $em->getClassMetadata(get_class($entity))->name;
         $entities[$class][] = $uow->getSingleIdentifierValue($entity);
     }
     foreach ($uow->getScheduledEntityDeletions() as $entity) {
         $class = $em->getClassMetadata(get_class($entity))->name;
         $entities[$class][] = $uow->getSingleIdentifierValue($entity);
     }
     foreach ($entities as $class => $ids) {
         foreach ($ids as $id) {
             $this->cache->clean($this->getDependencies($class, $id));
         }
     }
 }
Exemplo n.º 8
0
 public function saveEvent(\Nette\Forms\Controls\Button $button)
 {
     $form = $button->getForm();
     $values = $form->getValues();
     $place = $this->context->createServiceEvents()->wherePrimary($values->id);
     $place->update($values);
     $this->presenter->flashMessage('Done', 'success');
     $cache = new Cache($this->context->getService('cacheStorage'));
     $cache->clean(array(Cache::TAGS => array('events', 'event', 'term', 'terms')));
     if ($this->presenter->isAjax()) {
         $this->redrawControl('content');
         $this->presenter->redrawControl('flash');
     } else {
         $this->redirect('this');
     }
 }
Exemplo n.º 9
0
 /**
  * Save dictionary
  * @param string
  */
 public function save($file)
 {
     if (!$this->loaded) {
         throw new Nette\InvalidStateException('Nothing to save, translations are not loaded.');
     }
     if (!isset($this->files[$file])) {
         throw new \InvalidArgumentException("Gettext file identified as '{$file}' does not exist.");
     }
     $dir = $this->files[$file];
     $path = "{$dir}/{$this->lang}.{$file}";
     $this->buildMOFile("{$path}.mo", $file);
     $this->buildPOFile("{$path}.po", $file);
     if (isset($this->sessionStorage->newStrings[$this->lang])) {
         unset($this->sessionStorage->newStrings[$this->lang]);
     }
     if ($this->productionMode) {
         $this->cache->clean(array('tags' => 'dictionary-' . $this->lang));
     }
 }
Exemplo n.º 10
0
 /**
  * Save dictionary
  * @param string
  */
 public function save($file)
 {
     if (!$this->loaded) {
         throw new Nette\InvalidStateException('Nothing to save, translations are not loaded.');
     }
     if (!isset($this->files[$file])) {
         throw new \InvalidArgumentException("Gettext file identified as '{$file}' does not exist.");
     }
     $dir = $this->files[$file];
     $path = "{$dir}/{$this->lang}.{$file}";
     $metadata = $this->fileManager->generateMetadata($file, $this->metadata);
     $newStrings = $this->debugMode === true && isset($this->sessionStorage->newStrings[$this->lang]) ? $this->sessionStorage->newStrings[$this->lang] : array();
     $this->fileManager->buildMOFile("{$path}.mo", $file, $metadata, $this->dictionary);
     $this->fileManager->buildPOFile("{$path}.po", $file, $metadata, $this->dictionary, $newStrings);
     if ($this->debugMode === true && isset($this->sessionStorage->newStrings[$this->lang])) {
         unset($this->sessionStorage->newStrings[$this->lang]);
     }
     if ($this->productionMode) {
         $this->cache->clean(array(Cache::TAGS => 'dictionary-' . $this->lang));
     }
 }
Exemplo n.º 11
0
 /**
  * @param $class
  * @param $entity
  * @param $mode
  */
 protected function invalidate($class, $entity, $mode)
 {
     if (defined("\\{$class}::CACHE")) {
         $this->cache->clean(array(Cache::TAGS => $class::CACHE));
     }
     if ($entity instanceof \CmsModule\Content\Entities\PageEntity || $entity instanceof \CmsModule\Content\Entities\ExtendedPageEntity && ($entity = $entity->page)) {
         $this->cache->clean(array(Cache::TAGS => array('pages', 'page-' . $mode, 'page-' . $entity->id)));
     } elseif ($entity instanceof \CmsModule\Content\Entities\RouteEntity || $entity instanceof \CmsModule\Content\Entities\ExtendedRouteEntity && ($entity = $entity->route)) {
         $this->cache->clean(array(Cache::TAGS => array('routes', 'route-' . $mode, 'route-' . $entity->id)));
     } elseif ($entity instanceof \CmsModule\Content\Elements\ElementEntity || $entity instanceof \CmsModule\Content\Elements\ExtendedElementEntity && ($entity = $entity->element)) {
         $this->cache->clean(array(Cache::TAGS => array('elements', 'element-' . $mode, 'element-' . $entity->id)));
         if ($entity->mode === $entity::MODE_LAYOUT) {
             foreach ($entity->layout->routes as $route) {
                 $this->cache->clean(array(Cache::TAGS => array('routes', 'route-update', 'route-' . $route->id)));
             }
         } elseif ($entity->mode === $entity::MODE_PAGE) {
             $this->cache->clean(array(Cache::TAGS => array('pages', 'page-update', 'page-' . $entity->page->id)));
         } elseif ($entity->mode === $entity::MODE_ROUTE) {
             $this->cache->clean(array(Cache::TAGS => array('routes', 'route-update', 'page-' . $entity->route)));
         } else {
             $this->cache->clean(array(Cache::TAGS => array('routes', 'route-update', 'pages', 'page-update')));
         }
     }
 }
Exemplo n.º 12
0
 /**
  * Remove all items cached by WebLoader
  *
  * @param array $conditions
  */
 public function clean(array $conditions = NULL)
 {
     parent::clean([self::TAGS => ['webloader']]);
 }
Exemplo n.º 13
0
 public function languageFormSuccess()
 {
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
     $cache = new Cache($this->cacheStorage, 'Nette.Configurator');
     $cache->clean();
     $this->redirect('Installation:');
 }
Exemplo n.º 14
0
 public function invalidateCache()
 {
     $this->cache->clean([Cache::ALL => TRUE]);
 }
 /**
  * @param string $namespace
  * @param string $name
  */
 public function clear($namespace, $name)
 {
     $this->cache->clean([Cache::TAGS => [$namespace . '/' . $name]]);
 }
Exemplo n.º 16
0
 /**
  * @param array $conditions
  * @return \Ark8\Security\Authorizators\CachingAuthorizator
  */
 public function clean(array $conditions = NULL)
 {
     $this->cache->clean($conditions);
     return $this;
 }
Exemplo n.º 17
0
 protected function cleanCache($namespace = '', $tags)
 {
     $cache = new Cache($this->context->getService('cacheStorage'));
     if (is_string($tags)) {
         $cache->clean(array(Cache::TAGS => array($tags)));
     }
     if (is_array($tags)) {
         $cache->clean(array(Cache::TAGS => $tags));
     }
 }
Exemplo n.º 18
0
 public function flush()
 {
     $this->cache->clean();
     return true;
 }
Exemplo n.º 19
0
 /**
  * Deletes all cache entries
  *
  * @return boolean    TRUE if the cache entry was successfully deleted, FALSE otherwise.
  */
 protected function doFlush()
 {
     $this->storage->clean(array(NCache::ALL => TRUE));
 }
Exemplo n.º 20
0
 public function handleSetUnDeleted($place_id)
 {
     $cache = new Cache($this->context->getService('cacheStorage'));
     $cache->clean(array(Cache::TAGS => array('subject', 'subjects', 'place', 'places')));
     $place = $this->context->createServicePlaces()->get($place_id);
     $place->update(array('deleted' => 0, 'deleted_time' => null));
     $this->redirect('this');
 }
Exemplo n.º 21
0
 public function invalidateCache()
 {
     $this->cache->clean(array(Cache::ALL => TRUE));
 }
Exemplo n.º 22
0
 public function saveDescription(Nette\Forms\Controls\SubmitButton $button)
 {
     $form = $button->getForm();
     try {
         $values = $form->getValues(TRUE);
         $categories = $values['categories'];
         if (count($categories) == 1 && $categories[0] == 1) {
             $form['categories']->addError('Vyberte prosím ještě jednu kategorii kromě Zdarma. Díky!');
             throw new \Nette\InvalidArgumentException('Vyberte prosím ještě jednu kategorii kromě Zdarma. Díky!');
         }
         unset($values['categories']);
         unset($values['rewrite']);
         //unset($values['type']);
         $this->id = $values['id'];
         if ($values['user_id'] == '') {
             $values['user_id'] = $this->user->id;
         }
         if (!$this->user->isInRole('administrator')) {
             $values['reviewed'] = 0;
         }
         $event = $this->context->createService('events')->wherePrimary($this->id);
         if ($event->count() == 1) {
             $event->update($values, true);
         } else {
             $pd = $this->context->createService('events')->insert($values);
             $this->id = $pd->id;
         }
         \dibi::begin();
         \dibi::query('DELETE FROM [event_x_category] WHERE [event_id]=%i', $this->id);
         foreach ($categories as $n) {
             \dibi::query('INSERT INTO [event_x_category] SET [event_id]=%i', $this->id, ', [category_id]=%i', $n);
         }
         \dibi::commit();
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     }
     if ($form->isSuccess()) {
         $session = $this->presenter->getSession(get_class($this));
         unset($session['form']);
         $cache = new Cache($this->context->getService('cacheStorage'));
         $cache->clean(array(Cache::TAGS => array('events', 'event', 'term', 'terms', 'calendar')));
         $this->presenter->flashMessage('Fantazie! Popis události luxusně uložen!', 'success');
         if (isset($form['saveNew']) && $form['saveNew']->isSubmittedBy()) {
             $this->presenter->redirect('EventsWizard:w2', array('event_id' => $this->id));
         } elseif ($form['save']->isSubmittedBy()) {
             $this->redirect('this');
         } elseif ($form['saveBack']->isSubmittedBy()) {
             if (isset($this->backlink)) {
                 $this->presenter->restoreRequest($this->backlink);
             }
             unset($this->backlink);
             $this->presenter->redirect('Events:event', array('event_id' => $this->id));
         }
     }
 }
Exemplo n.º 23
0
 private function cleanCache()
 {
     $this->cache->clean([Cache::TAGS => get_called_class()]);
 }
Exemplo n.º 24
0
 /**
  *
  * @param Nette\ArrayHash $values
  * @return int
  */
 public function edit($values)
 {
     $this->cache->clean([Cache::TAGS => ['settings']]);
     return $this->database->table(self::TABLE_NAME)->where(self::COLUMN_ID, $values['id'])->update($values);
 }
Exemplo n.º 25
0
 /**
  * @param string $tag
  */
 public function purgeCacheTag($tag)
 {
     $cache = new Cache($this->cacheStorage);
     $cache->clean([Cache::TAGS => [$tag]]);
 }
Exemplo n.º 26
0
 public function clearCache()
 {
     $this->cache->clean();
 }
Exemplo n.º 27
0
 protected function doFlush()
 {
     $this->cache->clean(array(NCache::TAGS => array('doctrine')));
 }
Exemplo n.º 28
0
 public function clean()
 {
     $this->stopsIdsCache->clean([Cache::ALL => true]);
     $this->serviceIdsCache->clean([Cache::ALL => true]);
     $this->tripsIdsCache->clean([Cache::ALL => true]);
 }
Exemplo n.º 29
0
 private function invalidateCache()
 {
     $this->cache->clean();
 }
Exemplo n.º 30
0
 /**
  * @return $this
  */
 public function clearCache()
 {
     $cache = new Cache($this->cacheStorage, $this->namespace);
     $cache->clean(array(Cache::ALL));
     return $this;
 }