function RenderCache::getMultiple

Overrides RenderCacheInterface::getMultiple

File

core/lib/Drupal/Core/Render/RenderCache.php, line 57

Class

RenderCache
Wraps the caching logic for the render caching system.

Namespace

Drupal\Core\Render

Code

public function getMultiple(array $multiple_elements) : array {
    if (empty($multiple_elements)) {
        return [];
    }
    $bin_map = [];
    foreach ($multiple_elements as $item_key => $elements) {
        if (!$this->isElementCacheable($elements)) {
            continue;
        }
        $bin_map[$elements['#cache']['bin'] ?? 'render'][$item_key] = [
            $elements['#cache']['keys'],
            CacheableMetadata::createFromRenderArray($elements),
        ];
    }
    $results = [];
    foreach ($bin_map as $bin => $items) {
        foreach ($this->cacheFactory
            ->get($bin)
            ->getMultiple($items) as $item_key => $cache) {
            if ($this->isCacheableForCurrentHttpMethod($cache->tags)) {
                $results[$item_key] = $cache->data;
            }
        }
    }
    return $results;
}

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