Skip to content

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