lookupList() public method

Up to $requestedCount targets are returned, less if there are fewer in total.
public lookupList ( string $resource, integer $requestedCount ) : array
$resource string
$requestedCount integer The length of the list to return
return array List of targets
コード例 #1
0
ファイル: FlexihashTest.php プロジェクト: lcwxz1989/flexihash
 public function testFallbackPrecedenceWhenServerRemoved()
 {
     $mockHasher = new MockHasher();
     $hashSpace = new Flexihash($mockHasher, 1);
     $mockHasher->setHashValue(10);
     $hashSpace->addTarget('t1');
     $mockHasher->setHashValue(20);
     $hashSpace->addTarget('t2');
     $mockHasher->setHashValue(30);
     $hashSpace->addTarget('t3');
     $mockHasher->setHashValue(15);
     $this->assertEquals($hashSpace->lookup('resource'), 't2');
     $this->assertEquals($hashSpace->lookupList('resource', 3), ['t2', 't3', 't1']);
     $hashSpace->removeTarget('t2');
     $this->assertEquals($hashSpace->lookup('resource'), 't3');
     $this->assertEquals($hashSpace->lookupList('resource', 3), ['t3', 't1']);
     $hashSpace->removeTarget('t3');
     $this->assertEquals($hashSpace->lookup('resource'), 't1');
     $this->assertEquals($hashSpace->lookupList('resource', 3), ['t1']);
 }