public function MemoryBackend::garbageCollection in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
- 9 core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::garbageCollection()
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::garbageCollection()
Cleans up expired flood events. This method is called automatically on cron run.
Overrides FloodInterface::garbageCollection
See also
File
- core/
lib/ Drupal/ Core/ Flood/ MemoryBackend.php, line 77
Class
- MemoryBackend
- Defines the memory flood backend. This is used for testing.
Namespace
Drupal\Core\FloodCode
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);
});
}
}
}