function FileParsingCacheCollectorBase::updateCache

Same name and namespace in other branches
  1. main core/lib/Drupal/Core/Utility/FileParsingCacheCollectorBase.php \Drupal\Core\Utility\FileParsingCacheCollectorBase::updateCache()

Writes a value to the persistent cache immediately.

Parameters

bool $lock: (optional) Whether to acquire a lock before writing to cache. Defaults to TRUE.

Overrides CacheCollector::updateCache

File

core/lib/Drupal/Core/Utility/FileParsingCacheCollectorBase.php, line 62

Class

FileParsingCacheCollectorBase
Caches file parsing in a cache collector.

Namespace

Drupal\Core\Utility

Code

public function updateCache($lock = TRUE) : void {
  // Look for files cached longer than three months ago and remove them from
  // the cache item if they no longer exist.
  $three_months_ago = $this->time
    ->getCurrentTime() - 90 * 86400;
  foreach ($this->storage as $key => $item) {
    if ($item['mtime'] <= $three_months_ago && !file_exists($key)) {
      $this->delete($key);
    }
  }
  parent::updateCache($lock);
}

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