You are here

protected function PageCache::get in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::get()

Returns a response object from the page cache.

Parameters

\Symfony\Component\HttpFoundation\Request $request: A request object.

bool $allow_invalid: (optional) If TRUE, a cache item may be returned even if it is expired or has been invalidated. Such items may sometimes be preferred, if the alternative is recalculating the value stored in the cache, especially if another concurrent request is already recalculating the same value. The "valid" property of the returned object indicates whether the item is valid or not. Defaults to FALSE.

Return value

\Symfony\Component\HttpFoundation\Response|false The cached response or FALSE on failure.

1 call to PageCache::get()
PageCache::lookup in core/modules/page_cache/src/StackMiddleware/PageCache.php
Retrieves a response from the cache or fetches it from the backend.

File

core/modules/page_cache/src/StackMiddleware/PageCache.php, line 283
Contains \Drupal\page_cache\StackMiddleware\PageCache.

Class

PageCache
Executes the page caching before the main kernel takes over the request.

Namespace

Drupal\page_cache\StackMiddleware

Code

protected function get(Request $request, $allow_invalid = FALSE) {
  $cid = $this
    ->getCacheId($request);
  if ($cache = $this->cache
    ->get($cid, $allow_invalid)) {
    return $cache->data;
  }
  return FALSE;
}