Read Replica just for API Requests #164
Unanswered
michaelrimbach
asked this question in
Help
Replies: 1 comment
-
Hey @michaelrimbach. Good question, and one that I'm sure others will have eventually, once they've reached a scale in their store where this is a benefit to them. Totally not testing this myself, but I'd do something like:
This way, anytime those conditions are met, the correct |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to load the read replica settings just for WP JSON / WooCommerce API requests? My plan is that all read requests from API calls go to the read replica, everything else should go to the master db.
I thought it should work like this:
if( ! empty( DATABASE_HOST_RR ) && ( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST ) || isset( $_GET['wc-api'] ) ) ) {
}
But I found out that the constant REST_REQUEST is not set when the ludicrousdb config is loaded.
Maybe the solution is to load the read replica settings via a custom plugin later (not in db-config.php file)?
Beta Was this translation helpful? Give feedback.
All reactions