Acme-Selection-RarestFirst

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

$selector->update( $peer_bitfield, 1 ); # peer joined
$selector->update( $peer_bitfield, -1); # peer left

# Pick the next best item to request
my $idx = $selector->pick( $my_bitfield );
```

# DESCRIPTION

`Acme::Selection::RarestFirst` implements the classic "rarest-first" algorithm used in distributed systems to ensure
high data availability. It prioritizes items that have the lowest count in the global set (the "swarm").

# METHODS

## `update( $bitfield, $delta )`

Increments or decrements the availability count for every item marked in the provided bitfield (which must support a
`get( $index )` method).

## `pick( $my_bitfield, [$priorities] )`

lib/Acme/Selection/RarestFirst.pod  view on Meta::CPAN

    # Update availability based on what peers have
    $selector->update( $peer_bitfield, 1 ); # peer joined
    $selector->update( $peer_bitfield, -1); # peer left

    # Pick the next best item to request
    my $idx = $selector->pick( $my_bitfield );

=head1 DESCRIPTION

C<Acme::Selection::RarestFirst> implements the classic "rarest-first" algorithm used in distributed systems to ensure
high data availability. It prioritizes items that have the lowest count in the global set (the "swarm").

=head1 METHODS

=head2 C<update( $bitfield, $delta )>

Increments or decrements the availability count for every item marked in the provided bitfield (which must support a
C<get( $index )> method).

=head2 C<pick( $my_bitfield, [$priorities] )>



( run in 0.956 second using v1.01-cache-2.11-cpan-e1769b4cff6 )