public function MemoryBackend::garbageCollection

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::garbageCollection()
  2. 9.x drupal/core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()

Implements Drupal\Core\Flood\FloodInterface::garbageCollection().

Overrides FloodInterface::garbageCollection

File

drupal/core/lib/Drupal/Core/Flood/MemoryBackend.php, line 60
Definition of Drupal\Core\Flood\MemoryBackend.

Class

MemoryBackend
Defines the memory flood backend. This is used for testing.

Namespace

Drupal\Core\Flood

Code

public function garbageCollection() {
  foreach ($this->events as $name => $identifiers) {
    foreach ($this->events[$name] as $identifier => $timestamps) {

      // Filter by key (expiration) but preserve key => value  associations.
      $this->events[$name][$identifier] = array_filter($timestamps, function () use (&$timestamps) {
        $expiration = key($timestamps);
        next($timestamps);
        return $expiration > microtime(true);
      });
    }
  }
}