function CacheCollector::lazyLoadCache

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Cache/CacheCollector.php \Drupal\Core\Cache\CacheCollector::lazyLoadCache()
  2. 10 core/lib/Drupal/Core/Cache/CacheCollector.php \Drupal\Core\Cache\CacheCollector::lazyLoadCache()
  3. 9 core/lib/Drupal/Core/Cache/CacheCollector.php \Drupal\Core\Cache\CacheCollector::lazyLoadCache()
  4. 8.9.x core/lib/Drupal/Core/Cache/CacheCollector.php \Drupal\Core\Cache\CacheCollector::lazyLoadCache()

Loads the cache if not already done.

8 calls to CacheCollector::lazyLoadCache()
AliasPrefixList::lazyLoadCache in core/modules/path_alias/src/AliasPrefixList.php
CacheCollector::delete in core/lib/Drupal/Core/Cache/CacheCollector.php
CacheCollector::get in core/lib/Drupal/Core/Cache/CacheCollector.php
CacheCollector::set in core/lib/Drupal/Core/Cache/CacheCollector.php
Implements \Drupal\Core\Cache\CacheCollectorInterface::set().
FileParsingCacheCollectorBase::get in core/lib/Drupal/Core/Utility/FileParsingCacheCollectorBase.php

... See full list

1 method overrides CacheCollector::lazyLoadCache()
AliasPrefixList::lazyLoadCache in core/modules/path_alias/src/AliasPrefixList.php

File

core/lib/Drupal/Core/Cache/CacheCollector.php, line 332

Class

CacheCollector
Default implementation for CacheCollectorInterface.

Namespace

Drupal\Core\Cache

Code

protected function lazyLoadCache() {
  if ($this->cacheLoaded) {
    return;
  }
  // The cache was not yet loaded, set flag to TRUE.
  $this->cacheLoaded = TRUE;
  if ($cache = $this->cache
    ->get($this->getCid())) {
    $this->storage = $cache->data;
    // Retain the loaded data so that ::updateCache() can detect whether the
    // cache item changed during the request. The fingerprint is computed
    // lazily there, and only when there is data to write back, so that
    // requests that only read from the collector do not pay for hashing.
    $this->loadedData = $cache->data;
  }
}

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