/**
  * {@inheritdoc}
  */
 public function getBySession(SessionEntity $session)
 {
     $key = RedisUtil::prefix($session->getId(), 'oauth_sessions');
     if (isset($this->cache[$key])) {
         $result = $this->cache[$key];
     } else {
         if (!($value = RedisCapsule::get($key))) {
             return;
         }
         $result = $this->cache[$key] = RedisUtil::unserialize($value);
     }
     return $this->get($result['client_id']);
 }
 /**
  * {@inheritdoc}
  */
 public function get($token)
 {
     $key = RedisUtil::prefix($token, 'oauth_refresh_tokens');
     if (isset($this->cache[$key])) {
         $result = $this->cache[$key];
     } else {
         if (!($value = RedisCapsule::get($key))) {
             return;
         }
         $result = $this->cache[$key] = RedisUtil::unserialize($value);
     }
     return (new RefreshTokenEntity($this->server))->setId($result['id'])->setExpireTime($result['expire_time'])->setAccessTokenId($result['access_token_id']);
 }
 /**
  * {@inheritdoc}
  */
 public function get($scope, $grantType = null, $clientId = null)
 {
     $key = RedisUtil::prefix($scope, 'oauth_scopes');
     if (isset($this->cache[$key])) {
         $result = $this->cache[$key];
     } else {
         if (!($value = RedisCapsule::get($key))) {
             return;
         }
         $result = $this->cache[$key] = RedisUtil::unserialize($value);
     }
     return (new ScopeEntity($this->server))->hydrate(['id' => $result['id'], 'description' => $result['description']]);
 }
 /**
  * {@inheritdoc}
  */
 public function getScopes(AccessTokenEntity $token)
 {
     $key = RedisUtil::prefix($token->getId(), 'oauth_access_token_scopes');
     if (isset($this->cache[$key])) {
         $result = $this->cache[$key];
     } else {
         $result = $this->cache[$key] = RedisUtil::map(RedisCapsule::smembers($key));
     }
     $response = [];
     foreach ($result as $row) {
         $key = RedisUtil::prefix($row['id'], 'oauth_scopes');
         if (isset($this->cache[$key])) {
             $scope = $this->cache[$key];
         } else {
             if (!($value = RedisCapsule::get($key))) {
                 continue;
             }
             $scope = $this->cache[$key] = RedisUtil::unserialize($value);
         }
         $response[] = (new ScopeEntity($this->server))->hydrate(['id' => $scope['id'], 'description' => $scope['description']]);
     }
     return $response;
 }