1. 8.5.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  2. 8.0.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  3. 8.1.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  4. 8.2.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  5. 8.3.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  6. 8.4.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface
  7. 8.6.x core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php CacheableDependencyInterface

Defines an interface for objects which may be used by other cached objects.

All cacheability metadata exposed in this interface is bubbled to parent objects when they are cached: if a child object needs to be varied by certain cache contexts, invalidated by certain cache tags, expire after a certain maximum age, then so should any parent object.

Hierarchy

Expanded class hierarchy of CacheableDependencyInterface

All classes that implement CacheableDependencyInterface

Related topics

50 files declare their use of CacheableDependencyInterface
AccessResult.php in core/lib/Drupal/Core/Access/AccessResult.php
AccessResultTest.php in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
Contains \Drupal\Tests\Core\Access\AccessResultTest.
ArgumentPluginBase.php in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
BlockAccessControlHandler.php in core/modules/block/src/BlockAccessControlHandler.php
BlockPluginInterface.php in core/lib/Drupal/Core/Block/BlockPluginInterface.php

... See full list

File

core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php, line 15

Namespace

Drupal\Core\Cache
View source
interface CacheableDependencyInterface {

  /**
   * The cache contexts associated with this object.
   *
   * These identify a specific variation/representation of the object.
   *
   * Cache contexts are tokens: placeholders that are converted to cache keys by
   * the @cache_contexts_manager service. The replacement value depends on the
   * request context (the current URL, language, and so on). They're converted
   * before storing an object in cache.
   *
   * @return string[]
   *   An array of cache context tokens, used to generate a cache ID.
   *
   * @see \Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()
   */
  public function getCacheContexts();

  /**
   * The cache tags associated with this object.
   *
   * When this object is modified, these cache tags will be invalidated.
   *
   * @return string[]
   *   A set of cache tags.
   */
  public function getCacheTags();

  /**
   * The maximum age for which this object may be cached.
   *
   * @return int
   *   The maximum time in seconds that this object may be cached.
   */
  public function getCacheMaxAge();

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description Overrides
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyInterface::getCacheTags