W3cubDocs

/Drupal 8

public function CacheCollector::set

public CacheCollector::set($key, $value)

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 CacheCollectorInterface::set

File

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

Class

CacheCollector
Default implementation for CacheCollectorInterface.

Namespace

Drupal\Core\Cache

Code

public function set($key, $value) {
  $this->lazyLoadCache();
  $this->storage[$key] = $value;
  // The key might have been marked for deletion.
  unset($this->keysToRemove[$key]);
  $this->invalidateCache();

}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!CacheCollector.php/function/CacheCollector::set/8.1.x