createCacheID example

$this->cacheContextsManager = $cache_contexts_manager;
  }

  /** * {@inheritdoc} */
  public function get(array $elements) {
    // Form submissions rely on the form being built during the POST request,     // and render caching of forms prevents this from happening.     // @todo remove the isMethodCacheable() check when     // https://www.drupal.org/node/2367555 lands.     if (!$this->requestStack->getCurrentRequest()->isMethodCacheable() || !$cid = $this->createCacheID($elements)) {
      return FALSE;
    }
    $bin = $elements['#cache']['bin'] ?? 'render';

    if (!empty($cid) && ($cache_bin = $this->cacheFactory->get($bin)) && $cache = $cache_bin->get($cid)) {
      $cached_element = $cache->data;
      // Two-tier caching: redirect to actual (post-bubbling) cache item.       // @see \Drupal\Core\Render\RendererInterface::render()       // @see ::set()       if (isset($cached_element['#cache_redirect'])) {
        return $this->get($cached_element);
      }
Home | Imprint | This part of the site doesn't use cookies.