Esempio n. 1
0
 /**
  * @param $userId
  *
  * @return UserEntity
  * @throws UserNotFoundException
  */
 public function findUserById($userId)
 {
     $redisCli = $this->getConnection();
     $user = $redisCli->hMGet('users:' . $userId, ['name']);
     if (!$user) {
         throw new UserNotFoundException("User {$userId} was not found");
     }
     $userEntity = new UserEntity();
     $userEntity->setId($userId);
     $userEntity->setName($user['name']);
     return $userEntity;
 }
 /**
  * @param $userId
  *
  * @return UserEntity
  * @throws UserNotFoundException
  */
 public function findUserById($userId)
 {
     $neo4jClient = $this->getConnection();
     $queryStr = 'MATCH friendsApi WHERE id(friendsApi) = {userId} return friendsApi.name as name, id(friendsApi) as id';
     $query = new Query($neo4jClient, $queryStr, ['userId' => $userId]);
     $rows = $query->getResultSet();
     if (!$rows->count()) {
         throw new UserNotFoundException("User {$userId} was not found");
     }
     $userEntity = new UserEntity();
     $userEntity->setId($rows[0][1]);
     $userEntity->setName($rows[0][0]);
     return $userEntity;
 }