Kazuhiro Osawa > Data-Model-0.00008 > Data::Model::Transaction

Download:
Data-Model-0.00008.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source  

NAME ^

Data::Model::Transaction - transaction manager for Data::Model

SYNOPSIS ^

  sub foo {
      my $is_die = shift;
  
      my $model = Your::Model->new;
      my $txn = $model->txn_scope; # start transaction
  
      my $row = $txn->lookup( user => 1 ); # $model->lookup doesn't work.
      $row->name('transaction name');
      $txn->update( $row ); # update
      return if $is_die; # rollback
      if ($is_die) {
          $txn->rollback; # explicitly rollback
          return;
      }

      $txn->commit; # commit
  }

  foo(1); # rollback
  foo(0); # commit

lookup, lookup_multi, get, get_multi, set, replace, set_multi, update, update_direct, delete, delete_direct, delete_multi and txn_scope and txn_begin derived from DataModel are not usable temporarily.

When you use these methods, please carry out via the instance which txn_scope returns.

SEE ALSO ^

Data::Model

AUTHOR ^

Kazuhiro Osawa <yappo <at> shibuya <döt> pl>

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: