You are here

public function FileSystemBackend::invalidateAll in File Cache 8

Marks all cache items as invalid.

Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.

Overrides CacheBackendInterface::invalidateAll

See also

\Drupal\Core\Cache\CacheBackendInterface::deleteAll()

\Drupal\Core\Cache\CacheBackendInterface::invalidate()

\Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple()

File

src/Cache/FileSystemBackend.php, line 218

Class

FileSystemBackend
A cache backend that stores cache items as files on the file system.

Namespace

Drupal\filecache\Cache

Code

public function invalidateAll() {

  // Skip if the persisting cache strategy is used.
  if ($this->strategy === static::PERSIST) {
    return;
  }
  $this
    ->ensureCacheFolderExists();
  $iterator = $this
    ->getFileSystemIterator();
  foreach ($iterator as $filename) {
    if (is_file($filename)) {
      if ($item = $this
        ->getFile($filename)) {
        $this
          ->invalidateItem($item);
      }
    }
  }
}