You are here

public function CacheCollectorHelper::resolveCacheMiss in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php \Drupal\Tests\Core\Cache\CacheCollectorHelper::resolveCacheMiss()
  2. 9 core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php \Drupal\Tests\Core\Cache\CacheCollectorHelper::resolveCacheMiss()

Resolves a cache miss.

When an offset is not found in the object, this is treated as a cache miss. This method allows classes using this implementation to look up the actual value and allow it to be cached.

Parameters

string $key: The offset that was requested.

Return value

mixed The value of the offset, or NULL if no value was found.

Overrides CacheCollector::resolveCacheMiss

File

core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php, line 36

Class

CacheCollectorHelper
Helper class to test the cache collector.

Namespace

Drupal\Tests\Core\Cache

Code

public function resolveCacheMiss($key) {
  $this->cacheMisses++;
  if (isset($this->cacheMissData[$key])) {
    $this->storage[$key] = $this->cacheMissData[$key];
    $this
      ->persist($key);
    return $this->cacheMissData[$key];
  }
}