Copied!

A class to implement caching for calls to GCECredentials::onGce. This class is used automatically when you pass a Psr\Cache\CacheItemPoolInterface cache object to ApplicationDefaultCredentials::getCredentials.

$sysvCache = new Google\Auth\SysvCacheItemPool();
$creds = Google\Auth\ApplicationDefaultCredentials::getCredentials(
    $scope,
    null,
    null,
    $sysvCache
);
CloneableInstantiable
Constants
public Google\Auth\GCECache::GCE_CACHE_KEY = 'google_auth_on_gce_cache'
Methods
public __construct(?array $cacheConfig = NULL, ?Psr\Cache\CacheItemPoolInterface $cache = NULL)
 
  • param array $cacheConfig Configuration for the cache
  • param \CacheItemPoolInterface $cache
public onGce(?callable $httpHandler = NULL)
 

Caches the result of onGce so the metadata server is not called multiple times.

  • param callable|null $httpHandler callback which delivers psr7 request
  • return bool True if this a GCEInstance, false otherwise
Properties
private $cache = NULL
 
  • var ?\CacheItemPoolInterface
private $cacheConfig = NULL
 
  • var array
private $maxKeyLength = 64
 
  • var int
Methods
private getCachedValue( $k)
 

Gets the cached value if it is present in the cache when that is available.

  • param mixed $k
  • return mixed
private getFullCacheKey( $key)
 
  • param null|string $key
  • return null|string
private setCachedValue( $k, $v)
 

Saves the value in the cache when that is available.

  • param mixed $k
  • param mixed $v
  • return mixed
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration