function FileParsingCacheCollectorBase::get

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

Overrides CacheCollector::get

File

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

Class

FileParsingCacheCollectorBase
Caches file parsing in a cache collector.

Namespace

Drupal\Core\Utility

Code

public function get($key) : array {
  $this->lazyLoadCache();
  if (isset($this->storage[$key]) && file_exists($key)) {
    // Ensure that items written within the same second as the current request
    // are not returned from cache since they may have been written twice with
    // different values.
    if ($this->storage[$key]['mtime'] === filemtime($key) && $this->storage[$key]['mtime'] < $this->time
      ->getRequestTime()) {
      return $this->storage[$key]['parsed'];
    }
  }
  return $this->resolveCacheMiss($key);
}

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