function PageCache::get
Same name in other branches
- 9 core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::get()
- 8.9.x core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::get()
- 10 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 317
Class
- PageCache
- Executes the page caching before the main kernel takes over the request.
Namespace
Drupal\page_cache\StackMiddlewareCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.