You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
The Laravel Framework currently uses locks for several things:
The WithoutOverlapping middleware to avoid overlapping jobs
Unique jobs (PR pending)
Session blocking
Additionally, some Laravel users use Cache::lock in their apps.
The current lock implementation is tied with the cache driver. There are numerous drawbacks to this approach:
There is no distinction between the lock driver and cache driver. So, for example, there's no way to use the Redis cache and the database lock in tandem. With the current implementation, both have to originate from the same cache driver (unless you new up a DatabaseLock, however with this approach you cannot reap the benefits of dependency injection).
Cache is meant to store data that is temporarily stored in memory for frequent access. However, the same data is meant to be "immune" to cache clears. That is not the case with locks. So imagine running php artisan cache:clear only to break your session blocking or unique jobs.
How do we make lock a first citizen?
Implement a LockServiceProvider that maps the Lock interface to the concrete lock implementation via a LockManager and config/lock.php. This way we can separate the database / connection for lock and a php artisan cache:clear will not clear the lock and also, there's a clear distinction between implementation of the lock vs the cache.
Implement a Lock facade.
I think this would be a clean way to solve the problems described above. Thoughts?
The Laravel Framework currently uses locks for several things:
WithoutOverlapping
middleware to avoid overlapping jobsAdditionally, some Laravel users use
Cache::lock
in their apps.The current lock implementation is tied with the cache driver. There are numerous drawbacks to this approach:
php artisan cache:clear
only to break your session blocking or unique jobs.How do we make lock a first citizen?
LockServiceProvider
that maps theLock
interface to the concrete lock implementation via aLockManager
andconfig/lock.php
. This way we can separate thedatabase
/connection
for lock and aphp artisan cache:clear
will not clear the lock and also, there's a clear distinction between implementation of the lock vs the cache.Lock
facade.I think this would be a clean way to solve the problems described above. Thoughts?
Ping: @royduin
The text was updated successfully, but these errors were encountered: