3 namespace Drupal\Core\Cache;
6 * Defines an interface for objects which may be used by other cached objects.
8 * All cacheability metadata exposed in this interface is bubbled to parent
9 * objects when they are cached: if a child object needs to be varied by certain
10 * cache contexts, invalidated by certain cache tags, expire after a certain
11 * maximum age, then so should any parent object.
15 interface CacheableDependencyInterface {
18 * The cache contexts associated with this object.
20 * These identify a specific variation/representation of the object.
22 * Cache contexts are tokens: placeholders that are converted to cache keys by
23 * the @cache_contexts_manager service. The replacement value depends on the
24 * request context (the current URL, language, and so on). They're converted
25 * before storing an object in cache.
28 * An array of cache context tokens, used to generate a cache ID.
30 * @see \Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()
32 public function getCacheContexts();
35 * The cache tags associated with this object.
37 * When this object is modified, these cache tags will be invalidated.
40 * A set of cache tags.
42 public function getCacheTags();
45 * The maximum age for which this object may be cached.
48 * The maximum time in seconds that this object may be cached.
50 public function getCacheMaxAge();