* @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 int UNIX timestamp */
protected $ejectionNextExpiry = INF;
// 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;