RefinableCacheableDependencyInterface
interface RefinableCacheableDependencyInterface implements CacheableDependencyInterface (View source)
Allows to add cacheability metadata to an object for the current runtime.
This must be used when changing an object in a way that affects its cacheability. For example, when changing the active translation of an entity based on the current content language then a cache context for that must be added.
Methods
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Adds cache contexts.
Adds cache tags.
Merges the maximum age (in seconds) with the existing maximum age.
Adds a dependency on an object: merges its cacheability metadata.
Details
string[]
getCacheContexts()
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.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
$this
addCacheContexts(array $cache_contexts)
Adds cache contexts.
$this
addCacheTags(array $cache_tags)
Adds cache tags.
$this
mergeCacheMaxAge(int $max_age)
Merges the maximum age (in seconds) with the existing maximum age.
The max age will be set to the given value if it is lower than the existing value.
$this
addCacheableDependency(CacheableDependencyInterface|object $other_object)
Adds a dependency on an object: merges its cacheability metadata.