Teng::Role::Replicated - Replicated database support for Teng
package MyTeng;
use parent 'Teng';
use Any::Moose;
with 'Teng::Role::Replicated';
my $teng = MyTeng->new([
connect_info => [...], # master db connect info
slave_connect_info => [...], # slave db connect info
])
$teng->single(...); # for slave db
$teng->insert(...); # for master db
{
my $scope = $teng->force_master_scope;
$teng->search(...)->all; # for master db
$scope->end;
$teng->search(...)->all; # for slave db
}
{
my $txn = $teng->txn_scope;
$teng->search(...)->all; # for master db
$teng->insert(...); # for master db
$txn->commit;
$teng->search(...)->all; # for slave db
}
return Teng::Role::Replicated::ScopeGuard instance.
As long as this instance is alive or is not called "end" method, it does not executed SQL to slave.
Shinichiro Sei <[email protected]>
copyright (c) 2012 kayac inc. all rights reserved.
this program is free software; you can redistribute it and/or modify it under the same terms as perl itself.
the full text of the license can be found in the license file included with this module.