You are here

protected function FileSystemBackend::doDeleteAll in File Cache 8

Deletes all cache items in the bin.

2 calls to FileSystemBackend::doDeleteAll()
FileSystemBackend::deleteAll in src/Cache/FileSystemBackend.php
Deletes all cache items in a bin.
FileSystemBackend::removeBin in src/Cache/FileSystemBackend.php
Remove a cache bin.

File

src/Cache/FileSystemBackend.php, line 331

Class

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

Namespace

Drupal\filecache\Cache

Code

protected function doDeleteAll() {
  $this
    ->ensureCacheFolderExists();
  $iterator = $this
    ->getFileSystemIterator();
  foreach ($iterator as $filename) {

    // We are dealing with a flat list of files. If there are any folders
    // present these are user managed, skip them.
    // @todo We should split up the files over multiple folders to avoid
    //   having too many files in a single folder, which affects performance.
    // @see https://www.drupal.org/project/filecache/issues/3001324
    if (is_file($filename)) {
      $this->fileSystem
        ->unlink($filename);
    }
  }
}