Nette\Caching\Cache::clean PHP Method

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
    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);
    }

Usage Example

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;
     }
 }
All Usage Examples Of Nette\Caching\Cache::clean