Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function get($key)
 {
     if (!array_key_exists($key, $this->memory)) {
         $value = $this->cache->get($key);
         // don't cache false values (meaning non-existing)
         if (false === $value) {
             return $value;
         }
         $this->memory[$key] = $value;
     }
     return $this->memory[$key];
 }
Exemplo n.º 2
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 read($sessionId)
 {
     return $this->cache->get($this->prefix . $sessionId) ?: '';
 }
Exemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function fetch($id, array $options = null)
 {
     return $this->cache->get($id);
 }
Exemplo n.º 5
0
 /**
  * @inheritdoc
  */
 protected function doFetch($id)
 {
     $result = $this->cache->get($id);
     return null === $result ? false : $result;
 }
Exemplo n.º 6
0
 /**
  * @inheritdoc
  */
 protected function doFetch($id)
 {
     return $this->cache->get($id);
 }