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

Unexpected Behavior with Redis Configuration Merging in Laravel 11 #50522

Closed
Michael4d45 opened this issue Mar 13, 2024 · 0 comments · Fixed by #50523
Closed

Unexpected Behavior with Redis Configuration Merging in Laravel 11 #50522

Michael4d45 opened this issue Mar 13, 2024 · 0 comments · Fixed by #50523
Labels

Comments

@Michael4d45
Copy link

Laravel Version

11.0.3

PHP Version

8.3.3

Database Driver & Version

No response

Description

I've encountered an unexpected behavior while upgrading my project to Laravel 11, specifically related to changes in how Redis configurations are handled.

In previous versions of Laravel, defining a Redis cluster required adding configurations within a 'clusters' key in the config/database.php file. However, with Laravel 11, the documentation suggests defining Redis clusters directly within the config/database.php file, alongside the default and cache configurations.

The issue arises when attempting to define a Redis cluster while also using the default and cache configurations. Despite specifying a cluster configuration, the default and cache configurations are merged in, potentially causing conflicts or unexpected behavior.

// Sample configuration illustrating the issue
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis'),
    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'redis'),
        'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
    ],
    'clusters' => [
        'default' => [
            // Redis cluster configurations
        ],
    ],
    // Adding 'cache' => null to prevent default cache configuration merging
    'cache' => null,
    // ...
],

Steps To Reproduce

Upgrade Laravel project to version 11.
Add a Redis cluster configuration as per the Laravel 11 documentation.
Notice that the default and cache configurations are still included, potentially conflicting with the cluster configuration.

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

Successfully merging a pull request may close this issue.

2 participants