function Cache::mergeMaxAges
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeMaxAges()
- 8.9.x core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeMaxAges()
- 11.x core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeMaxAges()
Merges max-age values (expressed in seconds), finds the lowest max-age.
Ensures infinite max-age (Cache::PERMANENT) is taken into account.
Parameters
int ...: Max age values to merge.
Return value
int The minimum max-age value.
10 calls to Cache::mergeMaxAges()
- AccessResult::inheritCacheability in core/
lib/ Drupal/ Core/ Access/ AccessResult.php - Inherits the cacheability of the other access result, if any.
- ArgumentPluginBase::getCacheMaxAge in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php - The maximum age for which this object may be cached.
- BlockAccessControlHandler::mergeCacheabilityFromConditions in core/
modules/ block/ src/ BlockAccessControlHandler.php - Merges cacheable metadata from conditions onto the access result object.
- CacheableMetadata::merge in core/
lib/ Drupal/ Core/ Cache/ CacheableMetadata.php - Merges the values of another CacheableMetadata object with this one.
- CachePluginBase::getCacheMaxAge in core/
modules/ views/ src/ Plugin/ views/ cache/ CachePluginBase.php - Gets the max age for the current view.
File
-
core/
lib/ Drupal/ Core/ Cache/ Cache.php, line 69
Class
- Cache
- Helper methods for cache.
Namespace
Drupal\Core\CacheCode
public static function mergeMaxAges(...$max_ages) {
// Remove Cache::PERMANENT values to return the correct minimum value.
$max_ages = array_filter($max_ages, function ($max_age) {
return $max_age !== Cache::PERMANENT;
});
// If there are no max ages left return Cache::PERMANENT, otherwise return
// the minimum value.
return empty($max_ages) ? Cache::PERMANENT : min($max_ages);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.