credentials = $credentials; $this->cache = $cache; $this->cacheKey = $cacheKey; } /** * Attempt to get new credentials from cache or from the adapted object */ protected function refresh() { if (!$cache = $this->cache->fetch($this->cacheKey)) { // The credentials were not found, so try again and cache if new $this->credentials->getAccessKeyId(); if (!$this->credentials->isExpired()) { // The credentials were updated, so cache them $this->cache->save($this->cacheKey, $this->credentials, $this->credentials->getExpiration() - time()); } } else { // The credentials were found in cache, so update the adapter object // if the cached credentials are not expired if (!$cache->isExpired()) { $this->credentials->setAccessKeyId($cache->getAccessKeyId()); $this->credentials->setSecretKey($cache->getSecretKey()); $this->credentials->setSecurityToken($cache->getSecurityToken()); $this->credentials->setExpiration($cache->getExpiration()); } } } }