$cacheConfig Configuration for the cache * @param CacheItemPoolInterface $cache */ public function __construct( array $cacheConfig = null, CacheItemPoolInterface $cache = null ) { $this->cache = $cache; $this->cacheConfig = array_merge([ 'lifetime' => 1500, 'prefix' => '', ], (array) $cacheConfig); } /** * Caches the result of onGce so the metadata server is not called multiple * times. * * @param callable $httpHandler callback which delivers psr7 request * @return bool True if this a GCEInstance, false otherwise */ public function onGce(callable $httpHandler = null) { if (is_null($this->cache)) { return GCECredentials::onGce($httpHandler); } $cacheKey = self::GCE_CACHE_KEY; $onGce = $this->getCachedValue($cacheKey); if (is_null($onGce)) { $onGce = GCECredentials::onGce($httpHandler); $this->setCachedValue($cacheKey, $onGce); } return $onGce; } }