MemoryBackend::garbageCollection

public MemoryBackend::garbageCollection()

Cleans up expired flood events. This method is called automatically on cron run.

Overrides FloodInterface::garbageCollection

See also

system_cron()

File

core/lib/Drupal/Core/Flood/MemoryBackend.php, line 74

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);
      });
    }
  }
}
doc_Drupal
2016-10-29 09:25:45
Comments
Leave a Comment

Please login to continue.