function RenderCache::set
Same name in other branches
- 9 core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::set()
- 8.9.x core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::set()
- 11.x core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::set()
1 call to RenderCache::set()
- PlaceholderingRenderCache::set in core/
lib/ Drupal/ Core/ Render/ PlaceholderingRenderCache.php
1 method overrides RenderCache::set()
- PlaceholderingRenderCache::set in core/
lib/ Drupal/ Core/ Render/ PlaceholderingRenderCache.php
File
-
core/
lib/ Drupal/ Core/ Render/ RenderCache.php, line 81
Class
- RenderCache
- Wraps the caching logic for the render caching system.
Namespace
Drupal\Core\RenderCode
public function set(array &$elements, array $pre_bubbling_elements) {
// Avoid setting cache items on POST requests, this ensures that cache items
// with a very low hit rate won't enter the cache. All render elements
// except forms will still be retrieved from cache when available.
if (!$this->requestStack
->getCurrentRequest()
->isMethodCacheable() || !$this->isElementCacheable($elements)) {
return FALSE;
}
$bin = $elements['#cache']['bin'] ?? 'render';
$cache_bin = $this->cacheFactory
->get($bin);
$data = $this->getCacheableRenderArray($elements);
$cache_bin->set($elements['#cache']['keys'], $data, CacheableMetadata::createFromRenderArray($data)->addCacheTags([
'rendered',
]), CacheableMetadata::createFromRenderArray($pre_bubbling_elements));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.