CacheableInterface.php 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
<?php
/**
 * @file
 * Contains \Drupal\Core\CacheableInterface
 */

namespace Drupal\Core\Cache;

/**
 * Defines an interface for objects which are potentially cacheable.
 */
interface CacheableInterface {

  /**
   * The cache keys associated with this potentially cacheable object.
   *
   * @return array
   *   An array of strings or cache constants, used to generate a cache ID.
   */
  public function getCacheKeys();

  /**
   * The cache tags associated with this potentially cacheable object.
   *
   * @return array
   *  An array of cache tags.
   */
  public function getCacheTags();

  /**
   * The bin to use for this potentially cacheable object.
   *
   * @return string
   *   The name of the cache bin to use.
   */
  public function getCacheBin();

  /**
   * 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();

  /**
   * Indicates whether this object is cacheable.
   *
   * @return bool
   *   Returns TRUE if the object is cacheable, FALSE otherwise.
   */
  public function isCacheable();

}