[8.x] Ability to specify a separate lock connection #35621
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR allows us to specify a separate lock connection for the Redis and Database cache stores. Related: laravel/ideas#2404.
To use a separate lock connection, we may specify a
lock_connection
in ourconfig/cache.php
like so:Benefits
The Laravel Framework currently uses locks for several things:
WithoutOverlapping
middleware to avoid overlapping jobsPlus of course, locks may also be used in userland for application specific use cases.
The current lock connection is always the same as the cache connection. So, a
php artisan cache:clear
will also clear your locks. It's absolutely fine to clear cache in production and in fact, even a common deployment step. But clearing locks could mean breaking your unique jobs or session blocking. This PR introduces the ability to have a separate lock connection to make it possible to clear the cache without clearing locks.There are no breaking changes with this PR that's why it targets 8.x.