NAME
DBIx::DBHResolver::Strategy::Remainder - Key based sharding strategy.
SYNOPSIS
use DBIx::DBHResolver;
my $r = DBIx::DBHResolver->new;
$r->config(+{
clusters => +{
diary_master => [qw/diary001_master diary002_master diary003_master diary004_master/]
},
connect_info => +{
diary001_master => +{ ... },
diary002_master => +{ ... },
diary003_master => +{ ... },
diary004_master => +{ ... },
}
});
my $dbh_001 = $r->connect( 'diary_master', +{ key => 4, strategy => 'Remainer' } ); # key % 4 == 0
my $dbh_002 = $r->connect( 'diary_master', +{ key => 5, strategy => 'Remainer' } ); # key % 4 == 1
my $dbh_003 = $r->connect( 'diary_master', +{ key => 6, strategy => 'Remainer' } ); # key % 4 == 2
my $dbh_004 = $r->connect( 'diary_master', +{ key => 7, strategy => 'Remainer' } ); # key % 4 == 3
DESCRIPTION
DBIx::DBHResolver::Strategy::Remainder is key based sharding strategy depends on remainder divided key by number of nodes.
METHOD
connect_info( $resolver, $node, $args )
AUTHOR
Kosuke Arisawa <arisawa@gmail.com>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.