Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 682 Bytes

README.md

File metadata and controls

45 lines (33 loc) · 682 Bytes

Laravel ACID API

Installation

composer require anourvalar/laravel-atom

Usage

Action after transaction commit

Atom::onCommit(function () {
    dispatch(new Job());
});

Action after transaction rollBack

Atom::onRollBack(function () {
    Storage::delete('file.jpg');
});

Pessimistic lock

Atom::lock('user');
Atom::lockUser($user->id); // equals to: Atom::lock('user', $user->id);

Optimistic lock

try {
    Atom::strategy('optimistic_transaction')->lock('week_report');
} catch (\AnourValar\LaravelAtom\Exceptions\OptimisticTransactionException $e) {
    // already in progress..
}