本文整理汇总了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;
}
}
示例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));
}
}
示例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]);
}
}
示例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);
}
}
示例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.');
}
}
示例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;
}
示例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));
}
}
}
示例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');
}
}
示例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));
}
}
示例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));
}
}
示例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')));
}
}
}
示例12: clean
/**
* Remove all items cached by WebLoader
*
* @param array $conditions
*/
public function clean(array $conditions = NULL)
{
parent::clean([self::TAGS => ['webloader']]);
}
示例13: languageFormSuccess
public function languageFormSuccess()
{
if (function_exists('opcache_reset')) {
opcache_reset();
}
$cache = new Cache($this->cacheStorage, 'Nette.Configurator');
$cache->clean();
$this->redirect('Installation:');
}
示例14: invalidateCache
public function invalidateCache()
{
$this->cache->clean([Cache::ALL => TRUE]);
}
示例15: clear
/**
* @param string $namespace
* @param string $name
*/
public function clear($namespace, $name)
{
$this->cache->clean([Cache::TAGS => [$namespace . '/' . $name]]);
}