You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
Always define your API-only read-only database server, maybe with a specific dataset value like wcapi
Use $wpdb->add_callback( 'wc_api_callback' ); to make yourself a custom callback
This way, anytime those conditions are met, the correct wcapi dataset is used for any query that might be related to a WooCommerce REST API request, regardless of where it might be coming from (internal, external, whatever.)
Reacted by Michael Rimbach, didit s.banuardi.n, Drew Jaynes and Luigi
Activity
JJJ commentedon Nov 5, 2017
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:
datasetvalue likewcapi$wpdb->add_callback( 'wc_api_callback' );to make yourself a custom callbackThis way, anytime those conditions are met, the correct
wcapidataset is used for any query that might be related to a WooCommerce REST API request, regardless of where it might be coming from (internal, external, whatever.)