X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2FHashRing.php;h=21558f77b60c8e91e90055b0c829b718768adf53;hb=689c847a32e7fe8a0b3a559a88a627a252c5018e;hp=a4aabcd3fe50fc07e2dc26e0e8e41798387a46ca;hpb=a8a5f03b3b6653136c4dc5925d6bb2b806010725;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index a4aabcd3fe..21558f77b6 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -26,16 +26,16 @@ * @since 1.22 */ class HashRing { - /** @var Array (location => weight) */ + /** @var array (location => weight) */ protected $sourceMap = []; - /** @var Array (location => (start, end)) */ + /** @var array (location => (start, end)) */ protected $ring = []; /** @var HashRing|null */ protected $liveRing; - /** @var Array (location => UNIX timestamp) */ + /** @var array (location => UNIX timestamp) */ protected $ejectionExpiries = []; - /** @var integer UNIX timestamp */ + /** @var int UNIX timestamp */ protected $ejectionNextExpiry = INF; const RING_SIZE = 268435456; // 2^28 @@ -93,7 +93,7 @@ class HashRing { * Get the location of an item on the ring, as well as the next locations * * @param string $item - * @param integer $limit Maximum number of locations to return + * @param int $limit Maximum number of locations to return * @return array List of locations */ public function getLocations( $item, $limit ) { @@ -116,11 +116,12 @@ class HashRing { // If more locations are requested, wrap-around and keep adding them reset( $this->ring ); while ( count( $locations ) < $limit ) { - list( $location, ) = each( $this->ring ); + $location = key( $this->ring ); if ( $location === $primaryLocation ) { break; // don't go in circles } $locations[] = $location; + next( $this->ring ); } return $locations; @@ -152,7 +153,7 @@ class HashRing { * Remove a location from the "live" hash ring * * @param string $location - * @param integer $ttl Seconds + * @param int $ttl Seconds * @return bool Whether some non-ejected locations are left */ public function ejectFromLiveRing( $location, $ttl ) { @@ -218,7 +219,7 @@ class HashRing { * Get the location of an item on the "live" ring, as well as the next locations * * @param string $item - * @param integer $limit Maximum number of locations to return + * @param int $limit Maximum number of locations to return * @return array List of locations * @throws UnexpectedValueException */