function MemoryBackend::garbageCollection

Same name in this branch
  1. main core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
  2. 11.x core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::garbageCollection()
  3. 10 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
  4. 10 core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::garbageCollection()
  5. 9 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
  6. 9 core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::garbageCollection()
  7. 8.9.x core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
  8. 8.9.x core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::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/MemoryBackend.php, line 201

Class

MemoryBackend
Defines a memory cache implementation.

Namespace

Drupal\Core\Cache

Code

public function garbageCollection() {
  $requestTime = $this->time
    ->getRequestTime();
  $this->cache = array_filter($this->cache, function ($item) use ($requestTime) {
    return $item->expire == Cache::PERMANENT || $item->expire >= $requestTime;
  });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.