Skip to content

[5.x] Allow custom nocache db connection #11716

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

Merged
merged 11 commits into from
Apr 22, 2025

Conversation

macaws
Copy link
Contributor

@macaws macaws commented Apr 18, 2025

The Problem

Users cannot specify a separate database connection for the nocache_regions table without modifying Statamic core code. Sometimes, this table can get really big and you may not want to include it on frequent backups. You may also want to move this table specifically closer to the Statamic install to reduce latency.

The Solution

This PR adds a configuration option to allow specifying a different database connection for the nocache_regions table.

Backward Compatibility

This change is fully backward compatible as it defaults to the current behavior (using the default database connection) when no configuration is provided.

Usage Example

// In .env file
STATAMIC_NOCACHE_DB_CONNECTION=nocache

// Or in config/statamic/static_caching.php
'nocache_db_connection' => 'nocache',

// In config/database.php
        'nocache' => [
            'driver' => 'mysql',
            'host' => env('NOCACHE_DB_HOST', env('DB_HOST', '127.0.0.1')),
            'port' => env('NOCACHE_DB_PORT', env('DB_PORT', '3306')),
            'database' => env('NOCACHE_DB_DATABASE', 'nocache'),
            'username' => env('NOCACHE_DB_USERNAME', env('DB_USERNAME')),
            'password' => env('NOCACHE_DB_PASSWORD', env('DB_PASSWORD')),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

@macaws macaws changed the title Feature: nocache_regions custom db connection [5.x] Feature: nocache_regions custom db connection Apr 18, 2025
@jasonvarga jasonvarga changed the title [5.x] Feature: nocache_regions custom db connection [5.x] Allow custom nocache db connection Apr 22, 2025
@jasonvarga jasonvarga merged commit 69e758e into statamic:5.x Apr 22, 2025
25 checks passed
@macaws macaws deleted the feature/nocache_db_connection branch April 23, 2025 20:19
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