function CacheCollectorHelper::set

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php \Drupal\Tests\Core\Cache\CacheCollectorHelper::set()
  2. 10 core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php \Drupal\Tests\Core\Cache\CacheCollectorHelper::set()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php \Drupal\Tests\Core\Cache\CacheCollectorHelper::set()

Implements \Drupal\Core\Cache\CacheCollectorInterface::set().

This is not persisted by default. In practice this means that setting a value will only apply while the object is in scope and will not be written back to the persistent cache. This follows a similar pattern to static vs. persistent caching in procedural code. Extending classes may wish to alter this behavior, for example by adding a call to persist().

Overrides CacheCollector::set

File

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

Class

CacheCollectorHelper
Helper class to test the cache collector.

Namespace

Drupal\Tests\Core\Cache

Code

public function set($key, $value) {
    parent::set($key, $value);
    $this->persist($key);
}

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