You are here

public function DatabaseBackend::garbageCollection in Zircon Profile 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::garbageCollection()
  2. 8 core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::garbageCollection()
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Cache/DatabaseBackend.php \Drupal\Core\Cache\DatabaseBackend::garbageCollection()

Performs garbage collection on a cache bin.

The backend may choose to delete expired or invalidated items.

Overrides CacheBackendInterface::garbageCollection

File

core/lib/Drupal/Core/Cache/DatabaseBackend.php, line 332
Contains \Drupal\Core\Cache\DatabaseBackend.

Class

DatabaseBackend
Defines a default cache implementation.

Namespace

Drupal\Core\Cache

Code

public function garbageCollection() {
  try {
    $this->connection
      ->delete($this->bin)
      ->condition('expire', Cache::PERMANENT, '<>')
      ->condition('expire', REQUEST_TIME, '<')
      ->execute();
  } catch (\Exception $e) {

    // If the table does not exist, it surely does not have garbage in it.
    // If the table exists, the next garbage collection will clean up.
    // There is nothing to do.
  }
}