DBIx-TransactionManager-Distributed

 view release on metacpan or  search on metacpan

lib/DBIx/TransactionManager/Distributed.pm  view on Meta::CPAN


    txn { dbh()->do('NOTIFY something') } 'category';

WARNING: This only applies transactions to known database handles. Anything else -
Redis, cache layers, files on disk - is out of scope. Transactions are a simple
L<DBI/begin_work> / L<DBI/commit> pair, there's no 2-phase commit or other
distributed transaction co-ordination happening here.

=cut

sub txn(&;@) {
    my ($code, @categories) = @_;
    die "Need a database category" unless @categories;
    _check_fork();
    my $wantarray = wantarray;
    for my $category (@categories) {
        if (my $count = () = extract_by { !defined($_) } @{$DBH{$category}}) {
            warn "Had $count database handles that were not released via release_dbh, probable candidates follow:\n";
            my %addr = map { ; refaddr($_) => 1 } @{$DBH{$category}};
            warn "unreleased dbh in $_\n" for sort delete @{$DBH_SOURCE{$category}}{grep !exists $addr{$_}, keys %{$DBH_SOURCE{$category}}};
        }



( run in 0.235 second using v1.01-cache-2.11-cpan-49f99fa48dc )