Skip to content
Discussion options

You must be logged in to vote

There is no separate datacenter API to enable. Add each server to the same logical dataset and use lower read or write numbers for the connections that should be preferred in that location:

$wpdb->add_database( array(
	'host'    => 'local-replica.example',
	'user'    => DB_USER,
	'password'=> DB_PASSWORD,
	'name'    => DB_NAME,
	'dataset' => 'global',
	'write'   => 0,
	'read'    => 1,
) );

$wpdb->add_database( array(
	'host'    => 'remote-primary.example',
	'user'    => DB_USER,
	'password'=> DB_PASSWORD,
	'name'    => DB_NAME,
	'dataset' => 'global',
	'write'   => 1,
	'read'    => 2,
) );

Lower positive numbers are tried first; servers at the same priority are shuffled. Deploy prioritie…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JJJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #48 on June 12, 2024 21:56.