Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PageCache.php

function 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\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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal