jangaraev/eloquent-model-advisory-lock
eloquent-model-advisory-lock
Often you face the race conditions error when working with DB-intensive operations.
This package contains a trait with the method which helps to avoid that.
Usage
First do reference the trait in your model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Jangaraev\EloquentModelAdvisoryLock\AppliesAdvisoryLock;
class Foo extends Model
{
use AppliesAdvisoryLock;
// ...
}
This trait introduces the advisoryLock() method which receives
a callable to execute.
You then can use this method to wrap your DB intensive calls.
// wrap you DB-intensive operations as a callable to the advisoryLock call
static::advisoryLock(fn () => $this->coolRelationship()->firstOrCreate());
Related Packages
laravel-clickhouse/laravel-clickhouse
A ClickHouse based Eloquent model and Query builder for Laravel
130,611
233
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.0 | >=7.4 | ^7.0| | MIT | |
| 0.91 | >=7.4 | ^7.0| | MIT | |
| 0.9 | >=7.4 | ^7.0| | MIT |