Drupal 8  8.0.2
RenderCache Class Reference
Inheritance diagram for RenderCache:

Public Member Functions

 __construct (RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContextsManager $cache_contexts_manager)
 
 get (array $elements)
 
 set (array &$elements, array $pre_bubbling_elements)
 
 getCacheableRenderArray (array $elements)
 

Protected Member Functions

 maxAgeToExpire ($max_age)
 
 createCacheID (array &$elements)
 

Protected Attributes

 $requestStack
 
 $cacheFactory
 
 $cacheContextsManager
 

Detailed Description

Wraps the caching logic for the render caching system.

Constructor & Destructor Documentation

__construct ( RequestStack  $request_stack,
CacheFactoryInterface  $cache_factory,
CacheContextsManager  $cache_contexts_manager 
)

Constructs a new RenderCache object.

Parameters
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack.
\Drupal\Core\Cache\CacheFactoryInterface$cache_factoryThe cache factory.
\Drupal\Core\Cache\Context\CacheContextsManager$cache_contexts_managerThe cache contexts manager.

References Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

createCacheID ( array &  $elements)
protected

Creates the cache ID for a renderable element.

Creates the cache ID string based on cache['keys'] + cache['contexts'].

Parameters
array&$elementsA renderable array.
Returns
string The cache ID string, or FALSE if the element may not be cached.

References CacheableMetadata\createFromRenderArray().

Referenced by RenderCache\get(), and RenderCache\set().

Here is the call graph for this function:

Here is the caller graph for this function:

get ( array  $elements)

{Gets the cached, pre-rendered element of a renderable element from cache.

Parameters
array$elementsA renderable array.
Returns
array|false A renderable array, with the original element and all its children pre- rendered, or FALSE if no cached copy of the element is available.
See Also
::render()
::set()
}

Implements RenderCacheInterface.

References RenderCache\createCacheID(), and Drupal\requestStack().

Here is the call graph for this function:

getCacheableRenderArray ( array  $elements)

{Gets a cacheable render array for a render array and its rendered output.Given a render array and its rendered output (HTML string), return an array data structure that allows the render array and its associated metadata to be cached reliably (and is serialization-safe).If Drupal needs additional rendering metadata to be cached at some point, consumers of this method will continue to work. Those who only cache certain parts of a render array will cease to work.

Parameters
array$elementsA render array, on which ::render() has already been invoked.
Returns
array An array representing the cacheable data for this render array.
}

Implements RenderCacheInterface.

References Element\children(), SafeMarkup\isSafe(), and Element\properties().

Referenced by RenderCache\set(), and PlaceholderingRenderCache\set().

Here is the call graph for this function:

Here is the caller graph for this function:

maxAgeToExpire (   $max_age)
protected

Maps a cache[max-age] value to an "expire" value for the Cache API.

Parameters
int$max_ageA cache[max-age] value.
Returns
int A corresponding "expire" value.
See Also
::set()

References Cache\PERMANENT, and Drupal\requestStack().

Referenced by RenderCache\set().

Here is the call graph for this function:

Here is the caller graph for this function:

set ( array &  $elements,
array  $pre_bubbling_elements 
)

{Caches the rendered output of a renderable array.May be called by an implementation of while rendering, if the cache property is set.

Parameters
array$elementsA renderable array.
array$pre_bubbling_elementsA renderable array corresponding to the state (in particular, the cacheability metadata) of $elements prior to the beginning of its rendering process, and therefore before any bubbling of child information has taken place. Only the cache property is used by this function, so the caller may omit all other properties and children from this array.
Returns
bool|null Returns FALSE if no cache item could be created, NULL otherwise.
See Also
::get()
}

Implements RenderCacheInterface.

References RenderCache\createCacheID(), CacheableMetadata\createFromRenderArray(), RenderCache\getCacheableRenderArray(), RenderCache\maxAgeToExpire(), Cache\mergeTags(), and Drupal\requestStack().

Here is the call graph for this function:


The documentation for this class was generated from the following file: