function IconCollector::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(). If you are writing data to somewhere in addition to the cache item in ::set(), you should call static::updateCache() at the end of your ::set implementation. This avoids a race condition if another request starts with an empty cache before your ::set() call. For example: Drupal\Core\State\State.

Overrides CacheCollector::set

File

core/lib/Drupal/Core/Theme/Icon/IconCollector.php, line 37

Class

IconCollector
A CacheCollector implementation for building icons info.

Namespace

Drupal\Core\Theme\Icon

Code

public function set($key, $value) : void {
  $this->lazyLoadCache();
  $this->storage[$key] = $value;
  $this->persist($key);
  // Chances are very small but the key might have been marked for deletion.
  unset($this->keysToRemove[$key]);
}

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