Drupal 8  8.0.2
CachePluginBase Class Reference
Inheritance diagram for CachePluginBase:

Public Member Functions

 getResultsKey ()
 
 summaryTitle ()
 
 cacheSet ($type)
 
 cacheGet ($type)
 
 cacheFlush ()
 
 postRender (&$output)
 
 generateResultsKey ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 alterCacheMetadata (CacheableMetadata $cache_metadata)
 
 getRowCacheTags (ResultRow $row)
 
 getRowCacheKeys (ResultRow $row)
 
 getRowId (ResultRow $row)
 
- Public Member Functions inherited from PluginBase
 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 filterByDefinedOptions (array &$storage)
 
 unpackOptions (&$storage, $options, $definition=NULL, $all=TRUE, $check=TRUE)
 
 destroy ()
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 validateOptionsForm (&$form, FormStateInterface $form_state)
 
 submitOptionsForm (&$form, FormStateInterface $form_state)
 
 query ()
 
 themeFunctions ()
 
 validate ()
 
 summaryTitle ()
 
 pluginTitle ()
 
 usesOptions ()
 
 globalTokenReplace ($string= '', array $options=array())
 
 getAvailableGlobalTokens ($prepared=FALSE, array $types=array())
 
 globalTokenForm (&$form, FormStateInterface $form_state)
 
 calculateDependencies ()
 
 getProvider ()
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 
- Public Member Functions inherited from DerivativeInspectionInterface
 getBaseId ()
 
 getDerivativeId ()
 

Data Fields

 $storage = array()
 
- Data Fields inherited from PluginBase
const INCLUDE_NEGOTIATED = 16
 
const INCLUDE_ENTITY = 32
 
const VIEWS_QUERY_LANGUAGE_SITE_DEFAULT = '***LANGUAGE_site_default***'
 
 $options = array()
 
 $view = NULL
 
 $displayHandler
 
 $definition
 

Protected Member Functions

 cacheExpire ($type)
 
 cacheSetMaxAge ($type)
 
 getDefaultCacheMaxAge ()
 
 prepareViewResult (array $result)
 
- Protected Member Functions inherited from PluginBase
 defineOptions ()
 
 setOptionDefaults (array &$storage, array $options)
 
 doFilterByDefinedOptions (array &$storage, array $options)
 
 viewsTokenReplace ($text, $tokens)
 
 listLanguages ($flags=LanguageInterface::STATE_ALL, array $current_values=NULL)
 
 getRenderer ()
 

Protected Attributes

 $resultsBin = 'data'
 
 $resultsKey
 
- Protected Attributes inherited from PluginBase
 $usesOptions = FALSE
 
 $renderer
 

Additional Inherited Members

- Static Public Member Functions inherited from PluginBase
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static preRenderAddFieldsetMarkup (array $form)
 
static preRenderFlattenData ($form)
 
static queryLanguageSubstitutions ()
 

Detailed Description

The base plugin to handle caching.

Member Function Documentation

alterCacheMetadata ( CacheableMetadata  $cache_metadata)

Alters the cache metadata of a display upon saving a view.

Parameters
\Drupal\Core\Cache\CacheableMetadata$cache_metadataThe cache metadata.
cacheExpire (   $type)
protected

Determine the expiration time of the cache type, or NULL if no expire.

Plugins must override this to implement expiration.

Parameters
$typeThe cache type, either 'query', 'result'.

Referenced by CachePluginBase\cacheGet().

Here is the caller graph for this function:

cacheFlush ( )

Clear out cached data for a view.

References Cache\invalidateTags().

Here is the call graph for this function:

cacheGet (   $type)

Retrieve data from the cache.

A plugin should override this to provide specialized caching behavior.

References Drupal\cache(), CachePluginBase\cacheExpire(), and CachePluginBase\generateResultsKey().

Here is the call graph for this function:

cacheSet (   $type)

Save data to the cache.

A plugin should override this to provide specialized caching behavior.

References Drupal\cache(), CachePluginBase\cacheSetMaxAge(), CachePluginBase\generateResultsKey(), CachePluginBase\getCacheTags(), Cache\PERMANENT, and CachePluginBase\prepareViewResult().

Here is the call graph for this function:

cacheSetMaxAge (   $type)
protected

Determine expiration time in the cache table of the cache type or CACHE_PERMANENT if item shouldn't be removed automatically from cache.

Plugins must override this to implement expiration in the cache table.

Parameters
$typeThe cache type, either 'query', 'result'.

References Cache\PERMANENT.

Referenced by CachePluginBase\cacheSet().

Here is the caller graph for this function:

generateResultsKey ( )

Calculates and sets a cache ID used for the result cache.

Returns
string The generated cache ID.

References Drupal\service().

Referenced by CachePluginBase\cacheGet(), and CachePluginBase\cacheSet().

Here is the call graph for this function:

Here is the caller graph for this function:

getCacheMaxAge ( )

Gets the max age for the current view.

Returns
int

References CachePluginBase\getDefaultCacheMaxAge(), and Cache\mergeMaxAges().

Here is the call graph for this function:

getCacheTags ( )

Gets an array of cache tags for the current view.

Returns
string[] An array of cache tags based on the current view.

References Drupal\entityManager(), and Cache\mergeTags().

Referenced by CachePluginBase\cacheSet().

Here is the call graph for this function:

Here is the caller graph for this function:

getDefaultCacheMaxAge ( )
protected

Returns the default cache max age.

Referenced by CachePluginBase\getCacheMaxAge().

Here is the caller graph for this function:

getResultsKey ( )

Returns the resultsKey property.

Returns
string The resultsKey property.
getRowCacheKeys ( ResultRow  $row)

Returns the row cache keys.

Parameters
\Drupal\views\ResultRow$rowA result row.
Returns
string[] The row cache keys.

References CachePluginBase\getRowId().

Here is the call graph for this function:

getRowCacheTags ( ResultRow  $row)

Returns the row cache tags.

Parameters
ResultRow$rowA result row.
Returns
string[] The row cache tags.

References Cache\mergeTags().

Referenced by CachePluginBase\getRowId().

Here is the call graph for this function:

Here is the caller graph for this function:

getRowId ( ResultRow  $row)

Returns a unique identifier for the specified row.

Parameters
\Drupal\views\ResultRow$rowA result row.
Returns
string The row identifier.

References CachePluginBase\getRowCacheTags().

Referenced by CachePluginBase\getRowCacheKeys().

Here is the call graph for this function:

Here is the caller graph for this function:

postRender ( $output)

Post process any rendered data.

This can be valuable to be able to cache a view and still have some level of dynamic output. In an ideal world, the actual output will include HTML comment based tokens, and then the post process can replace those tokens.

Example usage. If it is known that the view is a node view and that the primary field will be a nid, you can do something like this:

And then in the post render, create an array with the text that should go there:

strtr($output, array('', 'output for FIELD of nid 1');

All of the cached result data will be available in $view->result, as well, so all ids used in the query should be discoverable.

prepareViewResult ( array  $result)
protected

Prepares the view result before putting it into cache.

Parameters
\Drupal\views\ResultRow[]$result The result containing loaded entities.
Returns
[] $result The result without loaded entities.

Referenced by CachePluginBase\cacheSet().

Here is the caller graph for this function:

summaryTitle ( )

Return a string to display as the clickable title for the access control.

Implements ViewsPluginInterface.

References t().

Here is the call graph for this function:

Field Documentation

$storage = array()

Contains all data that should be written/read from cache.


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