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 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);
}
doc_Drupal
2016-10-29 08:49:10
Comments
Leave a Comment

Please login to continue.