TTransactional
Helper trait for transactional operations
Tags
Table of Contents
Methods
- atomic() : mixed
- Run an atomic database operation
- atomicRetry() : mixed
- Wrapper around atomic() to retry after a retryable exception occurred
Methods
atomic()
Run an atomic database operation
protected
atomic(callable $fn, IDBConnection $db) : mixed
- Commit if no exceptions are thrown, return the callable result
- Revert otherwise and rethrows the exception
Parameters
- $fn : callable
- $db : IDBConnection
Tags
Return values
mixed —the result of the passed callable
atomicRetry()
Wrapper around atomic() to retry after a retryable exception occurred
protected
atomicRetry(callable $fn, IDBConnection $db[, int $maxRetries = 3 ]) : mixed
Certain transactions might need to be retried. This is especially useful in highly concurrent requests where a deadlocks is thrown by the database without waiting for the lock to be freed (e.g. due to MySQL/MariaDB deadlock detection)
Parameters
- $fn : callable
- $db : IDBConnection
- $maxRetries : int = 3
Tags
Return values
mixed —the result of the passed callable