RenderCache
class RenderCache implements RenderCacheInterface (View source)
| internal |
Wraps the caching logic for the render caching system.
Properties
| protected RequestStack | $requestStack | The request stack. |
|
| protected CacheFactoryInterface | $cacheFactory | The cache factory. |
|
| protected CacheContextsManager | $cacheContextsManager | The cache contexts manager. |
Methods
Constructs a new RenderCache object.
Gets the cached, pre-rendered element of a renderable element from cache.
Caches the rendered output of a renderable array.
Maps a #cache[max-age] value to an "expire" value for the Cache API.
Creates the cache ID for a renderable element.
Gets a cacheable render array for a render array and its rendered output.
Details
__construct(RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContextsManager $cache_contexts_manager)
Constructs a new RenderCache object.
array|false
get(array $elements)
Gets the cached, pre-rendered element of a renderable element from cache.
bool|null
set(array $elements, array $pre_bubbling_elements)
Caches the rendered output of a renderable array.
May be called by an implementation of \Drupal\Core\Render\RendererInterface while rendering, if the #cache property is set.
protected int
maxAgeToExpire(int $max_age)
Maps a #cache[max-age] value to an "expire" value for the Cache API.
protected string
createCacheID(array $elements)
Creates the cache ID for a renderable element.
Creates the cache ID string based on #cache['keys'] + #cache['contexts'].
array
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.