class ContextCacheKeys
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/Context/ContextCacheKeys.php \Drupal\Core\Cache\Context\ContextCacheKeys
- 8.9.x core/lib/Drupal/Core/Cache/Context/ContextCacheKeys.php \Drupal\Core\Cache\Context\ContextCacheKeys
- 11.x core/lib/Drupal/Core/Cache/Context/ContextCacheKeys.php \Drupal\Core\Cache\Context\ContextCacheKeys
A value object to store generated cache keys with its cacheability metadata.
Hierarchy
- class \Drupal\Core\Cache\CacheableMetadata implements \Drupal\Core\Cache\RefinableCacheableDependencyInterface uses \Drupal\Core\Cache\RefinableCacheableDependencyTrait
- class \Drupal\Core\Cache\Context\ContextCacheKeys extends \Drupal\Core\Cache\CacheableMetadata
Expanded class hierarchy of ContextCacheKeys
2 files declare their use of ContextCacheKeys
- RendererTestBase.php in core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTestBase.php - VariationCacheTest.php in core/
tests/ Drupal/ Tests/ Core/ Cache/ VariationCacheTest.php
File
-
core/
lib/ Drupal/ Core/ Cache/ Context/ ContextCacheKeys.php, line 10
Namespace
Drupal\Core\Cache\ContextView source
class ContextCacheKeys extends CacheableMetadata {
/**
* The generated cache keys.
*
* @var string[]
*/
protected $keys;
/**
* Constructs a ContextCacheKeys object.
*
* @param string[] $keys
* The cache context keys.
*/
public function __construct(array $keys) {
// Domain invariant: cache keys must be always sorted.
// Sorting keys warrants that different combination of the same keys
// generates the same cache cid.
// @see \Drupal\Core\Render\RenderCache::createCacheID()
sort($keys);
$this->keys = $keys;
}
/**
* Gets the generated cache keys.
*
* @return string[]
* The cache keys.
*/
public function getKeys() {
return $this->keys;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
CacheableDependencyTrait::$cacheContexts | protected | property | Cache contexts. | ||
CacheableDependencyTrait::$cacheMaxAge | protected | property | Cache max-age. | ||
CacheableDependencyTrait::$cacheTags | protected | property | Cache tags. | ||
CacheableDependencyTrait::setCacheability | protected | function | Sets cacheability; useful for value object constructors. | ||
CacheableMetadata::applyTo | public | function | Applies the values of this CacheableMetadata object to a render array. | 1 | |
CacheableMetadata::createFromObject | public static | function | Creates a CacheableMetadata object from a depended object. | 1 | |
CacheableMetadata::createFromRenderArray | public static | function | Creates a CacheableMetadata object with values taken from a render array. | 1 | |
CacheableMetadata::getCacheContexts | public | function | The cache contexts associated with this object. | Overrides CacheableDependencyTrait::getCacheContexts | |
CacheableMetadata::getCacheMaxAge | public | function | The maximum age for which this object may be cached. | Overrides CacheableDependencyTrait::getCacheMaxAge | |
CacheableMetadata::getCacheTags | public | function | The cache tags associated with this object. | Overrides CacheableDependencyTrait::getCacheTags | |
CacheableMetadata::merge | public | function | Merges the values of another CacheableMetadata object with this one. | 1 | |
CacheableMetadata::setCacheContexts | public | function | Sets cache contexts. | ||
CacheableMetadata::setCacheMaxAge | public | function | Sets the maximum age (in seconds). | ||
CacheableMetadata::setCacheTags | public | function | Sets cache tags. | ||
ContextCacheKeys::$keys | protected | property | The generated cache keys. | ||
ContextCacheKeys::getKeys | public | function | Gets the generated cache keys. | ||
ContextCacheKeys::__construct | public | function | Constructs a ContextCacheKeys object. | ||
RefinableCacheableDependencyTrait::addCacheableDependency | public | function | 1 | ||
RefinableCacheableDependencyTrait::addCacheContexts | public | function | |||
RefinableCacheableDependencyTrait::addCacheTags | public | function | |||
RefinableCacheableDependencyTrait::mergeCacheMaxAge | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.