You are here

public static function Cache::mergeMaxAges in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 $a: Max age value to merge.

int $b: Max age value to merge.

Return value

int The minimum max-age value.

9 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.

... See full list

File

core/lib/Drupal/Core/Cache/Cache.php, line 82
Contains \Drupal\Core\Cache\Cache.

Class

Cache
Helper methods for cache.

Namespace

Drupal\Core\Cache

Code

public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT) {

  // If one of the values is Cache::PERMANENT, return the other value.
  if ($a === Cache::PERMANENT) {
    return $b;
  }
  if ($b === Cache::PERMANENT) {
    return $a;
  }

  // If none or the values are Cache::PERMANENT, return the minimum value.
  return min($a, $b);
}