CacheableDependencyInterface::getCacheMaxAge

public CacheableDependencyInterface::getCacheMaxAge() The maximum age for which this object may be cached. Return value int The maximum time in seconds that this object may be cached. File core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php, line 50 Class CacheableDependencyInterface Defines an interface for objects which may be used by other cached objects. Namespace Drupal\Core\Cache Code public function getCacheMaxAge();

CacheableDependencyInterface::getCacheContexts

public CacheableDependencyInterface::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. Return value string[] An array of cache context tokens, used to gener

Cache::validateTags

public static Cache::validateTags(array $tags) Validates an array of cache tags. Can be called before using cache tags in operations, to ensure validity. Parameters string[] $tags: An array of cache tags. Throws \LogicException Deprecated Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)'); File core/lib/Drupal/Core/Cache/Cache.php, line 103 Class Cache Helper methods for cache. Namespace Drupal\Core\Cache Code public static function validateTags(array $ta

CacheableDependencyInterface

Defines an interface for objects which may be used by other cached objects. All cacheability metadata exposed in this interface is bubbled to parent objects when they are cached: if a child object needs to be varied by certain cache contexts, invalidated by certain cache tags, expire after a certain maximum age, then so should any parent object. Hierarchy interface \Drupal\Core\Cache\CacheableDependencyInterface Related topics Cache API Information about the Drupal Cache API File core/lib/

Cache::PERMANENT

Indicates that the item should never be removed unless explicitly deleted. File core/lib/Drupal/Core/Cache/Cache.php, line 17 Class Cache Helper methods for cache. Namespace Drupal\Core\Cache Code const PERMANENT = CacheBackendInterface::CACHE_PERMANENT;

Cache::mergeContexts

public static Cache::mergeContexts(array $a = [], array $b = []) Merges arrays of cache contexts and removes duplicates. Parameters array $a: Cache contexts array to merge. array $b: Cache contexts array to merge. Return value string[] The merged array of cache contexts. File core/lib/Drupal/Core/Cache/Cache.php, line 30 Class Cache Helper methods for cache. Namespace Drupal\Core\Cache Code public static function mergeContexts(array $a = [], array $b = []) { $cache_contexts = array

Cache::mergeMaxAges

public static Cache::mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT) Merges max-age values (expressed in seconds), finds the lowest max-age. Ensures infinite max-age (Cache::PERMANENT) is taken into account. Parameters int $a: Max age value to merge. int $b: Max age value to merge. Return value int The minimum max-age value. File core/lib/Drupal/Core/Cache/Cache.php, line 77 Class Cache Helper methods for cache. Namespace Drupal\Core\Cache Code public static function merge

Cache::mergeTags

public static Cache::mergeTags(array $a = [], array $b = []) Merges arrays of cache tags and removes duplicates. The cache tags array is returned in a format that is valid for \Drupal\Core\Cache\CacheBackendInterface::set(). When caching elements, it is necessary to collect all cache tags into a single array, from both the element itself and all child elements. This allows items to be invalidated based on all tags attached to the content they're constituted from. Parameters array $a: Cache tag

Cache::getBins

public static Cache::getBins() Gets all cache bin services. Return value \Drupal\Core\Cache\CacheBackendInterface[] An array of cache backend objects keyed by cache bins. File core/lib/Drupal/Core/Cache/Cache.php, line 154 Class Cache Helper methods for cache. Namespace Drupal\Core\Cache Code public static function getBins() { $bins = array(); $container = \Drupal::getContainer(); foreach ($container->getParameter('cache_bins') as $service_id => $bin) { $bins[$bin] = $

Cache API

Information about the Drupal Cache API Basics Note: If not specified, all of the methods mentioned here belong to \Drupal\Core\Cache\CacheBackendInterface. The Cache API is used to store data that takes a long time to compute. Caching can either be permanent or valid only for a certain timespan, and the cache can contain any type of data. To use the Cache API: Request a cache object through \Drupal::cache() or by injecting a cache service. Define a Cache ID (cid) value for your data. A cid is a