Skip to content

shin1rosei/p5-Teng-Role-Replicated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Teng::Role::Replicated - Replicated database support for Teng

SYNOPSIS

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
}

DESCRIPTION

METHODS

force_master_scope

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.

AUTHOR

Shinichiro Sei <shin1rosei@kayac.com>

SEE ALSO

LICENSE

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages