NAME

DBIx::Fast::Transaction - Transaction management for DBIx::Fast

DESCRIPTION

Manages database transactions with support for nested transactions, savepoints, automatic deadlock retry, and performance statistics tracking. Transactions that exceed the slow threshold (5 seconds) emit a warning.

METHODS

do

my $result = $tx->do(sub { ... }, \%options);

Executes a code block inside a transaction. Supports nested calls, automatic commit/rollback, and deadlock retry. Options: max_retries (default 3), retry_delay (default 1 second).

savepoint

$tx->savepoint('my_savepoint');

Creates a named savepoint within an active transaction.

rollback_to

$tx->rollback_to('my_savepoint');

Rolls back to the named savepoint and removes any savepoints created after it.

get_stats

my $stats = $tx->get_stats();

Returns a hashref with transaction statistics: total_count, success_count, error_count, deadlock_count, total_duration, max_duration, and avg_duration.

reset_stats

Resets all transaction statistics counters to zero.

AUTHOR

Harun Delgado

LICENSE

This is free software under the Artistic License 2.0.