function VariationCache::maxAgeToExpire

Same name in other branches
  1. 10 core/lib/Drupal/Core/Cache/VariationCache.php \Drupal\Core\Cache\VariationCache::maxAgeToExpire()

Maps a max-age value to an "expire" value for the Cache API.

Parameters

int $max_age: A max-age value.

Return value

int A corresponding "expire" value.

See also

\Drupal\Core\Cache\CacheBackendInterface::set()

1 call to VariationCache::maxAgeToExpire()
VariationCache::set in core/lib/Drupal/Core/Cache/VariationCache.php

File

core/lib/Drupal/Core/Cache/VariationCache.php, line 238

Class

VariationCache
Wraps a regular cache backend to make it support cache contexts.

Namespace

Drupal\Core\Cache

Code

protected function maxAgeToExpire($max_age) {
    if ($max_age !== Cache::PERMANENT) {
        return (int) $this->requestStack
            ->getMainRequest()->server
            ->get('REQUEST_TIME') + $max_age;
    }
    return $max_age;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.