You are here

public function TypePluginManager::getCacheMaxAge in GraphQL 8.3

The maximum age for which this object may be cached.

Return value

int The maximum time in seconds that this object may be cached.

Overrides DefaultPluginManager::getCacheMaxAge

1 call to TypePluginManager::getCacheMaxAge()
TypePluginManager::setCachedDefinitions in src/Plugin/TypePluginManager.php
Sets a cache of plugin definitions for the decorated discovery class.

File

src/Plugin/TypePluginManager.php, line 107

Class

TypePluginManager

Namespace

Drupal\graphql\Plugin

Code

public function getCacheMaxAge() {
  $definitions = $this
    ->getDefinitions();
  $age = Cache::PERMANENT;
  foreach ($definitions as $definition) {
    if (!isset($definition['schema_cache_max_age'])) {
      continue;
    }

    // Bail out early if the cache max age is 0.
    if (($age = Cache::mergeMaxAges($age, $definition['schema_cache_max_age'])) === 0) {
      return $age;
    }
  }
  return $age;
}