Пример #1
0
 /**
  * @inheritdoc
  */
 public function set($key, $value, $ttl = 0)
 {
     $res = $this->cache->set($key, $value, $ttl);
     if ($res === true) {
         $this->memory[$key] = $value;
     } else {
         unset($this->memory[$key]);
     }
     return $res;
 }
Пример #2
0
 /**
  * @test
  * @expectedException \GuzzleHttp\Exception\ClientException
  */
 public function it_fails_with_failed_reathentication()
 {
     $this->cache->set($this->getTokenKey(), $this->getTokenJson());
     $client = $this->factory->createClient($this->tenant);
     Server::enqueue([new Response(403), new Response(401)]);
     try {
         $client->request('get', '/foo');
     } catch (ClientException $e) {
         // original request should not have repeated
         $this->assertCount(2, Server::received());
         throw $e;
     }
 }
Пример #3
0
 /**
  * Returns a token to use for the keystone service. Uses cached instance
  * whenever possible.
  *
  * @param bool $forceNew Whether to force creating a new token
  *
  * @return Token
  */
 public function getToken($forceNew = false)
 {
     $tokenName = $this->getCacheKey();
     // see if token is in cache
     if (!$forceNew && ($cachedToken = $this->cache->get($tokenName))) {
         $this->logger->debug('Obtained token from cache');
         $token = $this->createToken($cachedToken);
     }
     if (!isset($token) || !$token instanceof Token || $token->isExpired()) {
         // cache the token and set it to expire 5 seconds before the
         // expiration date, to avoid any concurrence errors.
         $token = $this->requestToken();
         $this->cache->set($tokenName, json_encode($token), $token->getExpirationDate()->getTimestamp() - time() - 5);
     }
     // cache token properties
     $this->endpointUrl = $this->getEndpointUrlFromToken($token);
     $this->tokenId = $token->getId();
     return $token;
 }
 /**
  * {@inheritdoc}
  */
 public function write($sessionId, $data)
 {
     return $this->cache->set($this->prefix . $sessionId, $data, $this->ttl);
 }
Пример #5
0
 /**
  * @inheritdoc
  */
 public function save($id, $data, $lifeTime = false, array $options = null)
 {
     return $this->cache->set($id, $data, $lifeTime);
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 protected function doSave($id, $data, $lifeTime = false)
 {
     return $this->cache->set($id, $data, $lifeTime);
 }