CacheableDependencyInterface.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Core\Cache;
  3. /**
  4. * Defines an interface for objects which may be used by other cached objects.
  5. *
  6. * All cacheability metadata exposed in this interface is bubbled to parent
  7. * objects when they are cached: if a child object needs to be varied by certain
  8. * cache contexts, invalidated by certain cache tags, expire after a certain
  9. * maximum age, then so should any parent object.
  10. *
  11. * @ingroup cache
  12. */
  13. interface CacheableDependencyInterface {
  14. /**
  15. * The cache contexts associated with this object.
  16. *
  17. * These identify a specific variation/representation of the object.
  18. *
  19. * Cache contexts are tokens: placeholders that are converted to cache keys by
  20. * the @cache_contexts_manager service. The replacement value depends on the
  21. * request context (the current URL, language, and so on). They're converted
  22. * before storing an object in cache.
  23. *
  24. * @return string[]
  25. * An array of cache context tokens, used to generate a cache ID.
  26. *
  27. * @see \Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()
  28. */
  29. public function getCacheContexts();
  30. /**
  31. * The cache tags associated with this object.
  32. *
  33. * When this object is modified, these cache tags will be invalidated.
  34. *
  35. * @return string[]
  36. * A set of cache tags.
  37. */
  38. public function getCacheTags();
  39. /**
  40. * The maximum age for which this object may be cached.
  41. *
  42. * @return int
  43. * The maximum time in seconds that this object may be cached.
  44. */
  45. public function getCacheMaxAge();
  46. }