function PageCache::set
Same name in other branches
- 8.9.x core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::set()
- 10 core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::set()
- 11.x core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::set()
Stores a response object in the page cache.
Parameters
\Symfony\Component\HttpFoundation\Request $request: A request object.
\Symfony\Component\HttpFoundation\Response $response: The response to store in the cache.
int $expire: One of the following values:
- CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
- A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.
array $tags: An array of tags to be stored with the cache item. These should normally identify objects used to build the cache item, which should trigger cache invalidation when updated. For example if a cached item represents a node, both the node ID and the author's user ID might be passed in as tags. For example array('node' => array(123), 'user' => array(92)).
1 call to PageCache::set()
- PageCache::storeResponse in core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php - Stores a response in the page cache.
File
-
core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php, line 334
Class
- PageCache
- Executes the page caching before the main kernel takes over the request.
Namespace
Drupal\page_cache\StackMiddlewareCode
protected function set(Request $request, Response $response, $expire, array $tags) {
$cid = $this->getCacheId($request);
$this->cache
->set($cid, $response, $expire, $tags);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.