コード例 #1
0
 /**
  *
  */
 public function testReadUserInfo()
 {
     if (extension_loaded('xdebug')) {
         $this->assertTrue(true);
         return;
     }
     $gameVersion = 'tw';
     $pool = PdoFactory::makePool($gameVersion);
     $shardIdList = ShardHelper::listShardId($gameVersion);
     $uidList = [474000, 474001, 474002];
     $userList = [];
     foreach ($shardIdList as $shardId) {
         $pdo = $pool->getByShardId($shardId);
         $generator = CommonInfoProvider::readUserInfo($pdo, $uidList, 1);
         foreach ($generator as $batchUserList) {
             array_walk($batchUserList, function (array $userInfo, $uid) use(&$userList) {
                 $userList[$uid] = $userInfo;
             });
         }
     }
     static::assertEquals($uidList, array_keys($userList));
     foreach ($userList as $user) {
         static::assertTrue(is_array($user));
         static::assertArrayHasKey('uid', $user);
         static::assertArrayHasKey('snsid', $user);
     }
 }
コード例 #2
0
 /**
  * @param array $uidList
  *
  * @return array
  */
 public function find(array $uidList)
 {
     if (count($uidList) > 500) {
         trigger_error('Max 500 users as input args');
     }
     $userList = [];
     $shardIdList = $this->pdoPool->listShardId();
     foreach ($shardIdList as $shardId) {
         $pdo = $this->pdoPool->getByShardId($shardId);
         if ($pdo === false) {
             continue;
         }
         $shardUserList = [];
         $batchReader = CommonInfoProvider::readUserInfo($pdo, $uidList);
         foreach ($batchReader as $batchUserList) {
             $batchDataSet = $this->appendPaymentDigest($batchUserList);
             foreach ($batchDataSet as $uid => $userInfo) {
                 $shardUserList[$uid] = $userInfo;
             }
         }
         $userList[$shardId] = $shardUserList;
     }
     return $userList;
 }