function 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.