Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Ability to specify a separate lock connection #35621

Merged
merged 1 commit into from
Dec 16, 2020
Merged

[8.x] Ability to specify a separate lock connection #35621

merged 1 commit into from
Dec 16, 2020

Conversation

paras-malhotra
Copy link
Contributor

@paras-malhotra paras-malhotra commented Dec 15, 2020

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 our config/cache.php like so:

    'stores' => [
        'database' => [
            'driver' => 'database',
            'table' => 'cache',
            'connection' => null,
            'lock_connection' => 'lock',
        ],
        'redis' => [
            'driver' => 'redis',
            'connection' => 'cache',
            'lock_connection' => 'lock',
        ],
    ]

Benefits

The Laravel Framework currently uses locks for several things:

  1. The WithoutOverlapping middleware to avoid overlapping jobs
  2. Unique jobs
  3. Session blocking

Plus 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants