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

Support Setting the Database Instance via an Environment Variable #272

Closed
timnolte opened this issue Apr 10, 2020 · 2 comments · Fixed by #273
Closed

Support Setting the Database Instance via an Environment Variable #272

timnolte opened this issue Apr 10, 2020 · 2 comments · Fixed by #273
Milestone

Comments

@timnolte
Copy link
Contributor

This would be in order to support multiple servers connecting to the same Redis instance. Using just the WP_CACHE_KEY_SALT is not enough when you end up calling the wp_flush_cache() method as it will remove everything in the DB instance not just those items with the specified WP_CACHE_KEY_SALT.

@timnolte
Copy link
Contributor Author

You mention using

$redis_server = array(
     'host'     => '127.0.0.1',
     'port'     => 6379,
     'auth'     => '12345',
     'database' => 0, // Optionally use a specific numeric Redis database. Default is 0.
 );

when not on Pantheon but it's just as easy to use/setup the Pantheon environment variables when using a VPS. In the code you aren't allowing for the selection of a database, with a fallback default, to make this usable without that custom code. I can't use that custom code when using a Composer-based managed WordPress instance.

@timnolte
Copy link
Contributor Author

So as I was going back to check any other cases where the $redis_server array was being used I discovered that there is a filter that could be used in this case wp_redis_prepare_client_connection_callback

@danielbachhuber danielbachhuber added this to the 1.0.1 milestone Apr 14, 2020
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 a pull request may close this issue.

2 participants