public static function 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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!Cache.php/function/Cache::mergeMaxAges/8.1.x