當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::clean方法代碼示例

本文整理匯總了PHP中Nette\Caching\Cache::clean方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::clean方法的具體用法?PHP Cache::clean怎麽用?PHP Cache::clean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Caching\Cache的用法示例。


在下文中一共展示了Cache::clean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: linkUrls

 /**
  * @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;
     }
 }
開發者ID:blitzik,項目名稱:CMS,代碼行數:31,代碼來源:UrlLinker.php

示例2: invalidateCache

 public function invalidateCache($onlyTranslation = FALSE)
 {
     if ($onlyTranslation) {
         $this->cache->clean(array(Cache::TAGS => static::TAG_TRANSLATION));
     } else {
         $this->cache->clean(array(Cache::ALL => TRUE));
     }
 }
開發者ID:racinmat,項目名稱:Translation,代碼行數:8,代碼來源:CatalogueCompiler.php

示例3: deleteItem

 /**
  * 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]);
     }
 }
開發者ID:ixtrum,項目名稱:file-manager,代碼行數:14,代碼來源:Caching.php

示例4: removePageUrl

 /**
  * @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);
     }
 }
開發者ID:blitzik,項目名稱:CMS,代碼行數:12,代碼來源:PageRemover.php

示例5: execute

 /**
  * @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.');
     }
 }
開發者ID:svobodni,項目名稱:web,代碼行數:13,代碼來源:CacheCommand.php

示例6: __construct

 /**
  * @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;
 }
開發者ID:rixxi,項目名稱:template-locator,代碼行數:19,代碼來源:CachedTemplateLocator.php

示例7: onFlush

 /**
  * @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));
         }
     }
 }
開發者ID:venne,項目名稱:data-transfer,代碼行數:26,代碼來源:CacheInvalidationListener.php

示例8: saveEvent

 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');
     }
 }
開發者ID:soundake,項目名稱:pd,代碼行數:16,代碼來源:AdminToolsEventControl.php

示例9: save

 /**
  * 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));
     }
 }
開發者ID:salamek,項目名稱:gettexttranslator,代碼行數:23,代碼來源:Gettext.php

示例10: save

 /**
  * 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));
     }
 }
開發者ID:klimesf,項目名稱:gettext-translator,代碼行數:25,代碼來源:Gettext.php

示例11: invalidate

 /**
  * @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')));
         }
     }
 }
開發者ID:svobodni,項目名稱:web,代碼行數:29,代碼來源:PageListener.php

示例12: clean

 /**
  * Remove all items cached by WebLoader
  *
  * @param array $conditions
  */
 public function clean(array $conditions = NULL)
 {
     parent::clean([self::TAGS => ['webloader']]);
 }
開發者ID:lohini,項目名稱:webloader,代碼行數:9,代碼來源:Cache.php

示例13: languageFormSuccess

 public function languageFormSuccess()
 {
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
     $cache = new Cache($this->cacheStorage, 'Nette.Configurator');
     $cache->clean();
     $this->redirect('Installation:');
 }
開發者ID:svobodni,項目名稱:web,代碼行數:9,代碼來源:InstallationPresenter.php

示例14: invalidateCache

 public function invalidateCache()
 {
     $this->cache->clean([Cache::ALL => TRUE]);
 }
開發者ID:kdyby,項目名稱:translation,代碼行數:4,代碼來源:CatalogueCompiler.php

示例15: clear

 /**
  * @param string $namespace
  * @param string $name
  */
 public function clear($namespace, $name)
 {
     $this->cache->clean([Cache::TAGS => [$namespace . '/' . $name]]);
 }
開發者ID:josefzajac,項目名稱:Nette-ImagesManager,代碼行數:8,代碼來源:CachedStorage.php


注:本文中的Nette\Caching\Cache::clean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。