You are here

protected function DataProducerProxy::maxAgeToExpire in GraphQL 8.4

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

Parameters

int $maxAge:

Return value

int A corresponding "expire" value.

See also

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

1 call to DataProducerProxy::maxAgeToExpire()
DataProducerProxy::cacheWrite in src/Plugin/GraphQL/DataProducer/DataProducerProxy.php
Store result values in cache.

File

src/Plugin/GraphQL/DataProducer/DataProducerProxy.php, line 365

Class

DataProducerProxy
A proxy class that lazy resolves data producers and has a result cache.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer

Code

protected function maxAgeToExpire($maxAge) {
  $time = $this->requestStack
    ->getMasterRequest()->server
    ->get('REQUEST_TIME');
  return $maxAge === Cache::PERMANENT ? Cache::PERMANENT : (int) $time + $maxAge;
}